Best way to make a JSON API from WordPress?

I dont know how to edit question, I found this:
but this way I cannot specify my requests, is there any way to modify this code so that I can specify it?

 function check_api_data() {    
  if(isset($_GET['api']) ) {
  if ($_GET['api'] == 'json'){
           $args = array(  
               'post_status' => 'publish', 
               'nopaging'    => true,
               'orderby'     => 'title',
               'order'       => 'ASC'
           );
           $query = new WP_Query( $args ); // $query is the WP_Query Object
           $posts = $query->get_posts();   // $posts contains the post objects

           $output = array();
           foreach( $posts as $post ) {    // Pluck the id and title attributes
               $output[] = array( 
                'id' => $post->ID, 
                'title' => $post->post_title, 
                'content' => $post ->post_content,
                'imageurl' => wp_get_attachment_url( get_post_thumbnail_id($post->ID) )
                );
           }
           echo json_encode( $output );
       }
   exit();
   }  
}