Index

Free, with Google

Keep going, free.

A free account opens lessons 2 and 3 of every track, 33 more lessons, and keeps your progress and review cards on every device.

Start free with Google

A chalk plan

Open everything on chalk.

Every lesson, board, video, lab and paper, and the full review decks. Yearly is $39/year.

See plansStart free instead

API design: the contract other people's code stands on

Chapters

Narration

At the stall a deal was a sentence across the counter and nobody wrote it down. A published interface is the opposite of that. It is a promise in writing to callers you will never meet, including code somebody shipped three years ago and has not opened since. It still runs tonight. Which is why you can add to that promise almost freely, and almost never take anything away. Here is the whole discipline in one payload: an id, a name, a total. Rename that name field to something tidier and every caller written against the old word stops finding it. The field is not missing, it is invisible, and the failure lands in their code rather than yours. Now try the other edit. Add a field instead, and the old caller reads the keys it already knows and ignores the one it has never heard of. Same file, opposite outcome. Additive is free. Subtractive is an outage with a date on it. Three styles, and the question is fit, not best. REST puts resources at URLs and speaks plain text over ordinary HTTP, so everything can call it and caches understand it, and you pull a whole object down to read two fields of it. gRPC compiles one strict schema into both sides and goes binary on the wire: small, fast, and unreadable in a browser tab. GraphQL lets the caller ask for exactly the fields it wants from a single endpoint, which fixes the fetching and hands you a caching problem instead. Real systems run all three. gRPC between your own services, REST or GraphQL at the edge. When a change really is breaking, you stop arguing and cut a second version. Old callers keep hitting version one and keep getting the shape they were written against. New callers get version two. Both are live, both are on call, and version one is only allowed to die once its traffic does, measured, not assumed. One chat platform retired four separate endpoints this way and replaced them with a single one, and the old four kept answering the whole time it took. Pagination is a contract too, and one of the two options quietly lies. Offset says give me page three: skip twenty, take ten. Simple, slower the deeper you go, and wrong the moment somebody inserts a row above your window. Everything shifts down by one, so the next page repeats a row you already read and silently drops another. A cursor names the last row you actually saw and asks for whatever comes after it. Insert above it all you like. The cursor still points at the same row, and the page after it is still the page after it. Retries are not optional, because the network drops answers as well as requests. A caller sends a charge, the reply is lost on the way back, the caller tries again, and now there are two charges and one furious customer. Give that call an idempotency key and the second attempt returns the first result instead of doing the work twice. Then make failure legible: four hundreds are the caller's fault, five hundreds are yours, and a four twenty nine has to say how long to wait. And the network is not free, so ask once for a lot instead of forty times for a little. So an interface is not a file you generate. It is a promise, and other people's code is standing on it. Design it for the callers you will never meet, and for the day you have to change it anyway.

Saved in this browser, and to your account when you sign in.