Using other companies' APIs
Wrap each outside API in one module, write safely across timeouts, stay under its limits, survive its outages and notice its changes early.
- Required 2
- Recommended 4
Required
Send the same idempotency key when you retry a write
API-76Create one idempotency key for each business action, store it with the action, and send the same key on every retry of that write.
Give each environment its own provider key
API-80Use a separate key for each outside API in each environment, with only the permissions that environment needs. Only production holds a production key.
Recommended
Wrap each outside API in one adapter
API-75Put every call to one outside API in one module that speaks your own types. No other code imports its SDK or builds its addresses.
Stay under their rate limits
API-77Throttle your own calls below the provider's published limit. After a 429 or 503, send nothing more to that provider until its
Retry-Aftertime has passed.Decide what happens when a provider is down
API-78For each call to an outside API, choose one of three paths for when it fails. Show a clear message, serve a saved answer, or queue the work and send it later.
Pin their API version and watch for its end
API-79Send the provider's API version on every call from one constant in the adapter. Log a warning whenever an answer carries a
DeprecationorSunsetheader.
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/api-design/using-other-companies-apis">Agent Wranglers API design playbook</a>. In code you write, add a comment next to it with the same link.