lundi 28 août 2017

RESTful API Multiple Query Strings over multiple Resources for Filtering

Let´s assume there is an entity companies and an entity nations. A company can belong to many nations and a nation can have multiple companies. So there is a intermediate table memberships with different roles for the companies e.g. a company is a manufacturer in a nation and another company is for example a supplier in a nation. A nation can have multiple status like is_active etc.

Now we want to fetch all nations from a specific company where the role is manufacturer and the state of the nation is is_active = false.

How could a RESTful API endpoint look for this use case? Is it allowed to filter over multiple resources? Some ideas:

GET /companies/{id}/nations?role=manufacturer&is_active=false

GET /memberships/{id}/nations?role=manufacturer&is_active=false




Aucun commentaire:

Enregistrer un commentaire