Communication / 1 / 5
API styles
One screen of a food-delivery app, "My orders", built with REST, then GraphQL, with gRPC between services. Where each style fetches too much or too little, and the habits every API needs: cursor pagination, versioning and idempotency keys.
- 12 min
- Beginner
- 12 steps
- Calls per screen
- 1
- Screen load
- 180 ms
- Data per screen
- 0.1 MB
- Double orders
- 0 /day
- request
- reply
- redelivery
- duplicate
- lost
Numbers are a model scenario, not measurements
The real request
Phone app → REST APIRequest
GET /v1/orders?limit=20 HTTP/1.11
Host: api.example.com
Response
HTTP/1.1 200 OK
{
"data": 2[
{
"id": "ord_981",
"status": "delivered",
"total": 84000,
"restaurant_id": 3"r_7",
"address": { ... },
"items": 4[ ... ]
}
]
}
GET— Reading only. Safe to repeat and easy to cache.data— The list itself. Keeping it under a key leaves room for paging info next to it.restaurant_id— Only an ID. The screen needs the name, which is not here.items— Bulky fields the screen never shows, sent on every load anyway.
Course: 42 lessons
01 Foundations
02 Scaling
03 Data & storage
04 Communication
05 Reliability
06 Architecture
07 Security
08 Shipping
09 Whole systems
10 Business processes