Chapter 4 of 10All chapters
Chapter 4 of 10
REST and its alternatives
Shapes an API can take.
REST in practice
Resources get URLs, actions get HTTP methods, and collections get plural nouns. /orders/42/items is readable, guessable and cacheable, which is most of the value.
- Keep verbs out of paths: POST /orders, not /createOrder.
- Nest only one level deep. Deeper hierarchies become unusable.
The others
GraphQL lets the client ask for exactly the fields it wants, at the cost of a more complicated server. gRPC is compact and fast between services. Both solve real problems that REST handles awkwardly.