AlgoViz

REST

easy 26 min

REST is a style for network APIs: everything worth naming gets an address, and a small shared set of HTTP methods acts on it.

When it comes up

The moments this idea belongs in a design interview, and the moments it does not.

Signals

When it comes up

You hearSayBecause
Public API, many partnersREST with OpenAPIEveryone can call it
Read heavy, same data for allGET with Cache-ControlThe CDN answers most of it
Two people edit one thingETag and If-MatchNo silent overwrite
Payments over mobilePOST with an idempotency keyA repeat must not charge twice
Chat or live positionsNot plain RESTThe server must push
Every screen differsConsider GraphQLFixed shapes fit badly

Choices

Explain your choices

How should the client change the end time of a booking?

BreaksGET /updateBooking with parameters
How
A link that writes.
Limit
GET is safe by contract. Prefetching, crawlers and retries would change bookings.
Choose when
Never.
WorksPUT the whole booking
How
Send every field.
Limit
An older client drops fields that it does not know, and a second editor's change is lost.
Choose when
Small resources owned by one client.
StrongPATCH with If-Match
How
Merge patch with the new end time and the ETag. 412 if the version moved on, 422 if the seat is taken.
Limit
Clients must handle 412.
Choose when
Shared resources that several clients edit.

Can I retry this?