BolEnglishLearn · Play · Win
Login

📜 API & Integration · APIs & Integration

📜

API Contract

API ConceptCoreModule 5

Define exactly how systems communicate.

Consumers need stable request, response, and error structures.

💡 In practice

POST /orders accepts customerId and items and returns orderId and status.

🖼️ CONCEPT PICTURE
A picture to help remember API Contract
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.

💡 Learn🛠️ Apply🎯 Check

💡 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

1
Write it down
Document each endpoint's inputs, outputs and errors so consumers do not have to guess.
2
Be explicit about shapes
Name every field, its type, and whether it is required, for both requests and responses.
3
Describe failures too
Define the error structure so consumers can handle problems, not just the happy path.
4
Change it carefully
Treat the contract as a promise; breaking changes need versioning and warning, not a silent edit.

⚠️ 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.
⚠️ Common mistake: Changing request or response shapes without telling consumers. Treat the contract as a promise and version or announce any breaking change.

🎯 Quick check

Score: 0/3

Three questions to test the idea.

  1. 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. 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. 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.

🔑 Key terms

Endpoint
A single callable address of the API.
Payload
The data sent in a request or returned in a response.
Schema
The defined shape and types of the data.
Breaking change
A change that makes existing callers stop working.

✅ Review checklist

📊 Your progress

0%
Mark this topic learned to track it.
Saved in this browser.

🔗 Related topics

🚀 Got it?
Mark it learned and move to the next topic.
Next topic →