Skip to content

.tip

· one of the small things

Wrap list responses in an object, not a bare array

GET /items answering [{ "id": "itm_8f2a" }] works until the day you need to send a cursor, a total or a deprecation warning next to the list. There is nowhere to put it, so the fix becomes a second version of the endpoint.

{ "items": [{ "id": "itm_8f2a" }], "next_cursor": "MjAyNi0wOS0yMg" }

An object has room to grow, and a client that ignores keys it does not know keeps working when you add one. The nesting costs one line in the client today and saves the version bump later.

api-designhttp