API
Definition
An API (application programming interface) is a defined set of requests and responses that lets one piece of software use the data or functions of another without knowing how it works inside.
Diagram
Request
POST /v1/shipments Authorization: Bearer sk_test_… Content-Type: application/json { "to": "Ikeja, Lagos", "weight_kg": 2.4 }
- Method: what to do (GET reads, POST creates, PATCH updates, DELETE removes)
- URL: which resource
- Headers: who is asking, and in what format
- Body: the data sent
Response
201 Created Content-Type: application/json { "id": "shp_8421", "price": 3500, "label_url": "https://…" }
- 2xx: it worked
- 4xx: the request was wrong (401 not signed in, 404 not found, 429 too many)
- 5xx: the server failed