How to create a json API for my custom post type

The question seems a bit vague, there a lot of steps creating an API, but I’ll try to resume:

  1. Create an interaction page (You can use the wp-ajax or a page template)
  2. Code the function which will read parameters and execute the code
  3. Output only the result to browser. You can output json with a code line like:

echo json_encode( $result );

error code: 523