REST API including / filtering additional fields / resources / collections

I am developing a REST API using Zend Framework 1.12.3. It would be useful to have a parameter in order to be able to return additional information for the return (other collections / resources or parent / child resources).

eg. http://api.example.com/project/:id?include=Company,Company.users

where Company, Company.users represent the company to which the project is assigned, and the users of this company, and therefore these two collections are included in an answer that would not otherwise have been included.

I read briefly about this (Restricting the fields returned by the API here http://www.vinaysahni.com/best-practices-for-a-pragmatic-restful-api#limiting-fields ), but I would like to know more.

Are there any best practice recommendations regarding this issue? Do you have any example governing this?

Have you ever encountered a similar problem (including fields, filter fields, etc.) and how did you solve it?

+4
source share
1 answer

Some examples of syntax used to select fields / select fields in the wild:

We wanted to provide similar functionality on our APIs and went with a similar syntax to the Facebook field extension. Unfortunately, there are not many libraries to help with this, so we are promoting our own implementation. (There is yoga for Java and shona for scala is in its early stages, but none of them will help you with PHP).

+2
source

All Articles