API Content Structures Pros and Cons
From today on I will write down notes of what I’ve learned from the book “Build APIS You Won’t Hate”.
Today the topic is about the response content structure.
The famous JSON-API suggests to use
plural key for both single resources and resource collections.
- consistent response, always very same structure
- could be confusing to human when first time see it
Twitter uses another strategy instead, it will give you single thing or collection of things when you asked differently.
- minimalistic response
- no possibility for pagination or other meta info
Ask for one, get one.
Ask for more, get more, namespaced.
- Space for pagination and other meta info
- Simplistic response with extra namespace
- Single item has no other way than embedding to have meta info
always with name space, also when other object wrapped within.
- generic root scope
- easily wrapping other meta info into
- any? :)