Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter exbm

    (@exbm)

    I have looked into this: correct me if I am wrong but can I add more Rest endpoints by extending the WPCOM_JSON_API_Endpoint class then extending that with a another class that defines the callback function. then constructing that class with the arguments of my new endpoint.. will this automatically update the url rewrites?

    I couldn’t find in the code where you define the url_rewrites..

    As far as I can tell it works like this:

    XML_RPC method added json_api that initializes the JSON_API class with the url used to access the xml method. then that’s passed to the endpoints array and calls the appropriate endpoint callback method? I am assuming that you use url_rewrite to change the rest uri to the xmlrpc.php and setting the method json_api?

    Plugin Contributor Beau Lebens

    (@beaulebens)

    Hi exbm: Right now it’s not possible to extend the API, but we’re looking at the best way to allow plugin authors to do that.

    The reason you can’t find anything about the rewrites in the plugin is that the API is actually designed to operate through a central server/host (which is hosted by WordPress.com), so all of that information is hosted by us. This makes it easier for people implementing against the API (they only need to point to one endpoint), but it means that that server needs to be aware of all possible URLs. In your case, if you wanted to write a custom endpoint then the WordPress.com server would need to know about it (which it doesn’t) so that it could relay those requests through to your Jetpack site.

    So API requests are made against public-api.wordpress.com, which then either executes them against a blog hosted on WordPress.com, or relays those requests (as XML-RPC) to a Jetpack site. All requests that the Jetpack site sees come in as XML-RPC, even if they were actually originally made as REST/JSON.

    Once we figure out a good way to allow plugins to extend the API, we’ll have documentation up at http://developer.wordpress.com/

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Extend Jetpack Rest API’ is closed to new replies.