Include default functions and methods

Put this code in the top of your api page, it will call in the functions, but you need to tell wordpress NOT to try and draw a page as well

define('WP_USE_THEMES', false); // Tell wordpress not to draw out a page
require('/path/to/public_html/wp-load.php'); // load wordpress functions