📜 API & Integration · APIs & Integration
API Contract
Define exactly how systems communicate.
Consumers need stable request, response, and error structures.
POST /orders accepts customerId and items and returns orderId and status.
💡 Like a restaurant menu: it tells you exactly what to order and what you will get, so there are no surprises when the plate arrives.
💡 Why it matters
An API contract is a promise other systems build on. When it is clear and stable, teams can work independently and integrations keep working. When it drifts without warning, every consumer breaks at once, often in production. The contract is the shared language of integration.
🛠️ How to achieve it
⚠️ Signs of trouble
- •Consumers discover fields by trial and error.
- •A small backend change breaks callers without warning.
- •Errors come back in unpredictable shapes.
- •Nobody can say for sure what an endpoint returns.
🎯 Quick check
Score: 0/3Three questions to test the idea.
1. What is an API contract?
Answer: The agreed, stable definition of requests, responses and errors
The contract is the promise about how systems talk: the shapes of requests, responses and errors that consumers rely on.
2. What should an API contract describe besides successful responses?
Answer: The error structure for failures
Consumers need to handle failures too, so the contract must define how errors look, not just the happy path.
3. What is the risk of silently changing a response shape?
Answer: Existing consumers break without warning
The contract is a promise others build on; an unannounced breaking change can break every caller at once.
