A comprehensive guide to contracts that let different software systems exchange data reliably.
HTTP Exposed over the internet (REST, GraphQL).
Interfaces provided by SDKs or packages.
System calls (files, network, UI).
Interfaces to physical devices (IoT).
APIs hide internal complexity and present a stable contract to consumers via a Request-Response flow.
// Request
GET /v1/weather?city=Hyderabad HTTP/1.1
Host: api.example.com
Accept: application/json
// Response
HTTP/1.1 200 OK
Content-Type: application/json
{
"city": "Hyderabad",
"temp_c": 28.4,
"condition": "Partly Cloudy"
}
| Aspect | REST | GraphQL |
|---|---|---|
| Contract | Multiple endpoints, fixed resources | Single endpoint, typed schema |
| Data Fetching | Over/under-fetch possible | Client specifies exact shape |
| Caching | Simple (URL/Method based) | Complex (Needs field-level strategies) |
| Versioning | Path or Header (v1, v2) | Evolve schema (deprecate fields) |
// REST
GET /v1/users/42
GET /v1/users/42/posts
// GraphQL
query {
user(id: 42) {
name
posts { title }
}
}
Authorization: ApiKey <key>
Authorization: Bearer <token>
Click the button below to perform a live GET request to a public placeholder API using JavaScript fetch.
// Response will appear here...