docs-v2 icon indicating copy to clipboard operation
docs-v2 copied to clipboard

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

Open sheriffderek opened this issue 9 years ago • 1 comments

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!

sheriffderek avatar Apr 23 '16 17:04 sheriffderek

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!

BE-Webdesign avatar Apr 23 '16 20:04 BE-Webdesign