Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for WP-API /wp-json endpoints. #11

Merged
merged 1 commit into from
Feb 11, 2016
Merged

Conversation

timmyc
Copy link
Contributor

@timmyc timmyc commented Feb 11, 2016

This PR is part of the project to integrate the WP-API with the WordPress.com API. WP-API endpoints will utilize the following endpoint structure on WordPress.com:

/wp-json/{ site }/{ namespace }/{ version }/{ endpoint }

For example a "core" endpoint for post types would be:

/wp-json/{ site }/wp/v2/types

There has been some discussion about this URL structure ( and some of its oddities ) already, and here is a quick synopsis that @nylen provided:

- /wp-json is the default URL prefix for all REST URLs in core: rest_url_prefix. Everything that uses core’s REST scaffolding has this URL prefix and I think it is best to use the default.
- We need to add /sites/%s because we want to serve requests for all sites from a single domain, rather than from each site’s domain like WP-API does by default.
- wp/v2 is the WP-API namespace for the core endpoints. So far there’s also oembed/1.0. Plugins can add their own namespaces – I imagine we’ll have wpcom/v2 or similar for WPCOM-specific endpoints like store. More info in the WP-API discovery docs.
- Then finally the path to the endpoint itself like/posts or /types.

With the version being further down the path, the other libraries like wpcom.js will need to be aware of how to properly build the paths depending on API version as well - this PR just adjusts the base path to be ready for WP-API v2 endpoints.

/cc @retrofox

@timmyc timmyc self-assigned this Feb 11, 2016
@retrofox
Copy link
Contributor

small question by the way:

We need to add /sites/%s because we want to serve requests for all sites from a single domain, rather than from each site’s domain.

So the parameter into the url always will be a domain and It never will be a site id?

@retrofox
Copy link
Contributor

Can we add a simple example here ? Do we have already defined some endpoint working for that?
Just let me know if I can you.

@retrofox
Copy link
Contributor

Anyway LGTM

retrofox added a commit that referenced this pull request Feb 11, 2016
Add support for WP-API /wp-json endpoints.
@retrofox retrofox merged commit 7b1faa8 into master Feb 11, 2016
@timmyc
Copy link
Contributor Author

timmyc commented Feb 11, 2016

@retrofox my plan is to try and build out an endpoint in wpcom.js to utilize this - so that could serve as an example. There still is a bit of chatter/discussion around the path - so it could change still - though so many things are already in motion it might not change.

So the parameter into the url always will be a domain and It never will be a site id?

I'm fairly certain slug/ID will be interchangeable here - but will verify

@TooTallNate TooTallNate deleted the add/v2-support branch February 11, 2016 17:25
@retrofox
Copy link
Contributor

@retrofox my plan is to try and build out an endpoint in wpcom.js to utilize this - so that could serve as an example. There still is a bit of chatter/discussion around the path - so it could change still - though so many things are already in motion it might not change.

👍

What do you think to apply these changes in wpcom-proxy-request handler as well?

@timmyc
Copy link
Contributor Author

timmyc commented Feb 11, 2016

What do you think to apply these changes in wpcom-proxy-request handler as well?

So far the path logic for apiVersioning for the proxy is done in the rest-proxy js itself - there is a diff on wpcom going for that change currently.

@retrofox
Copy link
Contributor

oh cool. Thanks!

El jue., 11 feb. 2016 a las 19:41, Timmy Crawford (notifications@github.com)
escribió:

What do you think to apply these changes in wpcom-proxy-request handler as
well?

So far the path logic for apiVersioning for the proxy is done in the
rest-proxy js itself - there is a diff on wpcom going for that change
currently.


Reply to this email directly or view it on GitHub
#11 (comment)
.

@retrofox
Copy link
Contributor

So far the path logic for apiVersioning for the proxy is done in the rest-proxy js itself - there is a diff on wpcom going for that change currently.

oh, nice. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants