API Design
-
1
Thinking in resources: what REST actually is
REST is constraints, not JSON over HTTP: address resources, let methods decide the action, send hypermedia links to what's next and more.
Start →
-
2
HTTP methods: what each verb promises
A method's promise about safety and idempotency decides when a retry is safe, when a cache is legal, and PUT versus POST.
Start →
-
3
Status codes and error design: how an API says NO
The status code tells machines whose fault the failure was and whether to retry. The error body tells a developer what to fix, and it is never an apology.
Start →
-
4
Authentication: proving who is calling
Authentication asks who you are and authorization asks what you may do. Authentication methods differ mainly in where the identity state lives.
Start →
-
5
Authorization: a route check is not an object check
A role check at the route is needed but not enough. The most common API breach is never asking whether this user owns object 123.
Unlock →
-
6
The browser enforces CORS, not your server
The browser runs the same-origin policy to protect its users. And CORS headers tell the browser which origins may read the reply, but requests from curl, POSTMAN don't go through that check.
Start →
-
7
API security: three families of mistakes, not a top ten list
Real breaches come from missing checks, leaked fields and trusted input.
Start →
-
8
Designing a list endpoint is designing a small query language
Pagination, filtering, sorting and field selection are one problem. Offset paging drifts and slows down. A cursor pins your position to a stable key.
Unlock →
-
9
HTTP caching: infrastructure you do not own, working for you
Declare freshness with Cache-Control and identity with ETag, and caches serve your traffic. The hard part is invalidation.
Start →
-
10
Conditional requests: the lost update and the fix HTTP already has
Two clients read one row and both write it back, and the slower write silently erases the faster one. If-Match makes that loss a loud 412.
Unlock →
-
11
Rate limiting shares capacity fairly, and the algorithm decides how
A limiter protects a shared resource from any one caller, malicious or just retrying badly. The algorithm decides which bursts get through.
Start →
-
12
Versioning an API: changing the contract you already published
Only a breaking change needs a new version, and most changes are additive. The deprecation lifecycle matters far more than where the version number goes.
Start →
-
13
Async APIs and webhooks: when the work takes longer than the request
Do not keep the connection open. Return 202 with a job the client can poll, or send a webhook to whoever needs to know and handle every delivery problem.
Start →
-
14
Real-time APIs: step up from polling only for a clear reason
Poll while the delay is acceptable. Push with SSE when only the server has new data, and open a WebSocket only when the client sends messages back.
Unlock →
-
15
File uploads: do the bytes go through your API or skip it?
Every upload design makes one choice: the bytes go through your API or skip it. A signed URL gives permission to upload, but your API still keeps control.
Unlock →
-
16
Who controls the response shape
In REST the server decides the response shape, in GraphQL the client builds it, and in gRPC a compiled contract sets it. The trade-offs come from who decides the shape.
Start →
-
17
The API gateway: what belongs at the edge
A gateway exists so auth, rate limiting, routing and TLS are implemented once at the edge rather than copied into every service.
Unlock →
-
18
Scale and availability: what statelessness makes possible, and what still fails
Holding no session is what lets the servers scale out. For availability, the other half, assume parts fail and stop one failure from spreading.
Start →
-
19
Service boundaries: chains, events, and sagas
Every call you add multiplies the risk. Events decouple services but data agrees later, and a saga replaces a transaction with compensations that undo earlier steps.
Unlock →
-
20
Testing APIs: three different questions
Three suites, three questions: behaviour, compatibility, capacity. The contract test is the one only an API needs.
Start →
-
21
Documentation: the docs come from the spec, not a hand-written copy
Hand-written docs are a second copy of what the code does, and copies go out of date. A spec that generates the reference, clients and checks cannot go out of date.
Start →
-
22
Observability: percentiles, one request id, and the signal that changes first
An average describes a request nobody made. A percentile describes real requests, one request id builds the trace, and saturation is the first signal to change.
Unlock →