A web API is a boundary through which a provider exposes capabilities to consumers over a network. A consumer sends an HTTP request describing an action and its needed data; the provider returns a response indicating the result. Consumers need to understand that exchange, not the provider’s database, code, or internal services. section 1.1 section 1.1.2 section 1.1.3
Sharing a message
A social-network mobile app can call POST /statuses to share a message, sending the message and an optional photo. The backend can store it and identify friends without requiring the mobile app to know whether that work involves other services or a particular database. The visible operation and data—not those internal choices—are what the consumer builds against. section 1.1.1 section 1.1.3 section 1.6.2
A useful API contract makes several choices clear to consumers:
- Capabilities: which operations exist and what data they need and return. Missing operations or data can make a desired feature difficult or impossible to build. section 1.2.2 section 1.6.2
- Behavior: use HTTP responses and errors consistently enough that consumers can understand failures and help end users recover. section 1.1.2 section 1.2.2
- Access and volume: define who may see sensitive data, and avoid forcing consumers to retrieve an unbounded amount in one call. section 1.2.3 section 1.7.3
- Change: assess existing consumers before renaming a response field or changing its meaning; either change can break them. section 1.2.4 section 1.3.2
A contract serves others even when an API is private: another team, a new colleague, or a future maintainer may consume it. Designing it around domain capabilities rather than one screen can also let a website, mobile app, and later clients use the same interface. Specific consumer needs still matter, so review the design with consumers, subject-matter experts, IT experts, and security experts. section 1.1.4 section 1.7.1 section 1.4.1 section 1.4.2
Before implementation, identify the capabilities consumers need, turn them into HTTP operations, and model their inputs and outputs. Describe the resulting interface in a standard API specification so stakeholders can check it against those needs. Revisit the design when development or early use reveals a gap—and treat later modifications as design decisions too. section 1.6 section 1.6.2 section 1.6.3 section 1.3.3












































