Develop REST API using WordPress for Android app [closed]

Hopefully someone will extend on my answer….

The critical part of the rest API that is already in core is the registration and routing of endpoints which should look like (taken from http://v2.wp-api.org/extending/adding/)

`/**
 * Grab latest post title by an author!
 *
 * @param array $data Options for the function.
 * @return string|null Post title for the latest,
     
 * or null if none.
 */
function my_awesome_func( $data ) {
    $posts = get_posts( array(
        'author' => $data['id'],
    ) );`

    if ( empty( $posts ) ) {
        return null;
    }

    return $posts[0]->post_title;
}

add_action( 'rest_api_init', function () {
    register_rest_route( 'myplugin/v1', '/author/(?P<id>\d+)', array(
        'methods' => 'GET',
        'callback' => 'my_awesome_func',
    ) );
} );

Based on this pattern you can just handle your API in whatever way you prefer.

I advice against using the core rest API, unless you need information in vanilla wordpress format. The wordpress rest API does both too much and too little for what most non trivial APIs will do, and it is just better to isolate your logic.