api-design

  • Rate limiting moved to the service provider

    The throttle middleware took its limits as route parameters, so a limit that depended on the user or the plan had to be a custom middleware. The by…

  • Assertions about shape, not about values

    A collection asserting that the total is 4900 fails whenever the seed data changes, which is every sprint — and gets deleted rather than fixed. Asserting on presence…

  • A problem details response, and the RFC nobody reads

    Every API invents its own error shape, so a client talking to four services has four parsers — and RFC 7807 is a shape somebody has already thought…

  • BigInt exists, and JSON does not know about it

    An identifier larger than 2^53 loses precision as a JavaScript number, and BigInt fixes the arithmetic and not the transport. This is the reason well-designed APIs return large…

  • Generating a client from the document, and when not to

    A generated client removes the hand-written HTTP layer and produces a large amount of code nobody has read, in a style nobody chose. For six endpoints a hand-written…

  • Request validation against the schema, in the framework

    A document describing what the API accepts and a validator enforcing it are two implementations of one rule, and they diverge in the direction of the code. Validating…

  • An environment file with no secrets in it

    A Postman environment holds a base URL and a token, and the token is the reason these files leak. An empty value with the secret type is the…

  • An idempotency key, and where the response is stored

    A client that times out and retries has sent the same request twice, and the server cannot tell whether the first one succeeded. Storing the response rather than…

  • An HTTP client that is part of the framework

    Four services, four hand-rolled clients, four retry policies. 7.0 wraps Guzzle, and the wrapper is the point rather than the transport.

  • Contract tests that live in the repository

    The collection lived in one person’s account, which is not version control. An endpoint changed and the client team found out from an error.