APIs operate on a request-response model where a client sends structured requests to a server, which processes them and returns structured responses. This is the fundamental communication pattern.
The API workflow is like a restaurant: You (client) place an order (request) with specific details. The kitchen (server) receives the order, processes it according to your specifications, and delivers the meal (response). The API acts as the intermediary that formats your order, validates it, processes it through business logic, and returns results in a standard format. The beauty of APIs is that the client doesn't need to know how the server processes requests internally - it only needs to know the contract (input format and output format). This separation of concerns allows different systems to communicate seamlessly even if they're built with different technologies.
GET
/api/users/123
Authorization: Bearer token, Content-Type: application/json
None (for GET requests)
200 OK
Content-Type: application/json
{ id: 123, name: 'John', email: 'john@example.com' }
Scenario: You're testing a user registration API. During testing, you send a POST request to /api/users. The API returns 200 OK but you notice the response takes 3 seconds. Walk through what could be happening in each step of the request-response flow, and explain how you'd diagnose the slowness.