API Child Objects

60 views
Skip to first unread message

Andy Thurgood

unread,
May 9, 2013, 5:35:15 AM5/9/13
to api-...@googlegroups.com

Hello, 

I'm working on the design of a new read only API and i wanted to grab some opinions on how best to represent the following data structure via API resources.

So the following parent --> child structure Exists

Countries --> Regions --> Authorities --> Establishments

I've set each of these types as resources in the API so...

GET api/Countries - returns a list of countries
GET api/Countries/1 - returns a single country by Id

Now my question is should i also include a child link here to prompt consumers to grab child data so..

GET api/Countries/1/regions - returns a list of regions in country 1

I didn't want to go any further into the hierarchy, but felt if I prompted the consumer by exposing the next child resource they would be able to pick up the structure as the response data will include links to the resource, so in the above example a region item would have a link to api/region/1.

I also have some queries regarding returning a full object graph vs a list of links vs provided basic or detail options as well as how to handle search functionality but i wanted to get the overall structure correct first.

Many thanks

Andy

Abraham Williams

unread,
May 9, 2013, 5:13:56 PM5/9/13
to api-...@googlegroups.com
You shouldn't need more path hierarchy than /parent/id/child as each time you start specifying a child resource with an ID you can bump it to be the parent.

E.g.

GET api/Authorities
GET api/Authorities/1
GET api/Authorities/1/Establishments
GET api/Establishments
GET api/Establishments/1


Abraham
--
This email is: [ ] shareable [x] ask first [ ] private



Andy

--
You received this message because you are subscribed to the Google Groups "API Craft" group.
To unsubscribe from this group and stop receiving emails from it, send an email to api-craft+...@googlegroups.com.
Visit this group at http://groups.google.com/group/api-craft?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages