WP-API / docs-v2

Documentation for version 2 of the API
http://v2.wp-api.org
58 stars 76 forks source link

Add examples of how to write endpoints with filters and other parameters etc #142

Open sheriffderek opened 8 years ago

sheriffderek commented 8 years ago

As a generalist, I appreciate the agnostic approach in how the $ curl -X OPTIONS -i http://demo.wp-api.org/wp-json/wp/v2/posts examples look, but I don't see any examples of any more complex queries.

/posts?filter[posts_per_page]=20

What if I want to see 5 posts of a certain category if written by a particular author?

@BE-Webdesign pointed out that "Both those params support csv listed ID's." /wp-json/wp/v2/posts?author=1&categories=1

I'm personally using the API with Ember js.

I'm trying to work out some serialization between the wp-api's REST style and get it into a json-api setup - but the Docs are less help than Stack Overflow when it comes to things like filters as far as references I can look at.

Any thoughts on that? Am I looking in the wrong places? I see the parameters - but no examples of them in action. Is there a general query code style that is already assumed? Is the syntax the same as general query strings? https://en.wikipedia.org/wiki/Query_string

Thanks!

BE-Webdesign commented 8 years ago

I see the parameters - but no examples of them in action. Is there a general query code style that is already assumed? Is the syntax the same as general query strings?

You can pass via query strings, body params, etc. The API is based around HTTP so any sort of data sent via HTTP can be used in the API, depending on what you are trying to accomplish.

I agree that more examples of queries and examples using the API in general would be extremely beneficial. If anyone would like to help out please make pull requests for the docs site!