The question seems a bit vague, there a lot of steps creating an API, but I’ll try to resume:
- Create an interaction page (You can use the wp-ajax or a page template)
- Code the function which will read parameters and execute the code
- Output only the result to browser. You can output json with a code line like:
echo json_encode( $result );