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

Filter the output of JSON #18

Open
zenliver opened this issue May 20, 2018 · 2 comments
Open

Filter the output of JSON #18

zenliver opened this issue May 20, 2018 · 2 comments

Comments

@zenliver
Copy link

zenliver commented May 20, 2018

Thank you for creating such an excellent wordpress REST API plugin, it enhances the output of JSON.This feature helps me a lot:

the official API:

/wp-json/wp/v2/posts?categories=5

this outputs only category 5's posts not including its children categories posts

and better-rest-endpoints API:

/wp-json/better-rest-endpoints/v1/posts?category=5

this outputs all posts of category 5 including all its children categories posts

appreciate for your excellent works!

Now I have a little suggestion about filtering the output of JSON.

Can we add a filter parameter to the API's endpoints to filter the output of JSON? For example:

if wen can use:

/wp-json/better-rest-endpoints/v1/posts?category=5&fields=id,title,date

(query string &fields=id,title,date is added)

to output only the id title date fields, thus the JSON output will be much smaller.

Many thanks! Wish you a happy life!

@erwstout
Copy link
Member

Hi @zenliver thanks for the issue. I think this could be a great idea. I might not be able to get to it for a little bit but I'll definitely take a look into how we could accomplish it. Feel free to make a PR if you have any ideas. I know that something like this might be coming to the official Rest API soon (https://core.trac.wordpress.org/ticket/43874)

@zenliver
Copy link
Author

zenliver commented May 22, 2018

@erwstout Thank you for your answer!

The json fields filtering of official API has been already resolved by an excellent plugin WP REST API - filter fields, but the official API still has something not good.

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

No branches or pull requests

2 participants