api-design

  • REST API schema is not documentation, it is validation

    The schema attached to a route looks like a description for humans. Core uses it to validate and sanitise the request before the callback runs, which means an…

  • Deep pagination is the wrong shape of question

    from=10000&size=10 makes every shard produce 10,010 hits and the coordinating node sort 50,050 of them to return ten. The cost grows with the offset, which is why there…

  • A CDN in front of an API needs a Vary header

    A cache keys on the URL. If the response depends on anything else — an Accept header, a language, an authorisation token — the cache will serve one…

  • Route model binding with a custom key per route

    getRouteKeyName() changes the binding column for a model everywhere, which is wrong when the admin addresses an order by id and the customer addresses it by reference. An…

  • A contract test for the API you depend on

    Mocking an upstream service makes the suite fast and guarantees nothing about the upstream still behaving that way. A contract test is a small suite that runs against…

  • HTTP caching headers the application controls

    A reverse proxy or CDN caches what the response tells it to cache, which means the decision belongs in the application and usually is not made at all…

  • Events describe what happened, commands ask for something

    Both end up on the same bus and they are opposites. A command is addressed to one handler and may be refused; an event is a statement of…

  • API resources replaced the transformer package

    Shaping a model for JSON has meant a transformer library or toArray() on the model, and the second couples the wire format to the database columns — so…

  • The REST API in core, and the plugin it replaces

    4.7 shipped the content endpoints. What moving off the feature plugin involves, why authentication is still the unsolved half, and the read API every site now exposes.

  • Extracting a service without a rewrite

    The reporting code had one caller and a six-hour test run. Finding the seam, dealing with the shared schema honestly, and routing traffic gradually rather than switching.