APIs power every app you use—from weather widgets and maps to payments and AI. This guide explains APIs in plain language with diagrams, requests, and real examples you can try. We start from first principles and build up to REST, authentication, rate limits, and versioning.
API, endpoint, and resource
- API: a contract that defines how software can talk to another system.
- Endpoint: the specific URL that serves one action (e.g.,
/api/v1/weather?city=rome
). - Resource: the data the endpoint exposes (e.g., a weather report object).
HTTP request/response
GET /api/v1/joke HTTP/1.1 Host: apinest.com Accept: application/json
HTTP/1.1 200 OK Content-Type: application/json { "joke": "Why do programmers prefer dark mode? Because light attracts bugs." }
A visual model

The client sends a request, the server runs business logic, then returns a structured response. CDNs/gateways can cache, throttle, and authenticate traffic.
Methods
Method | Purpose | Idempotent? |
---|---|---|
GET | Read | Yes |
POST | Create/Action | No (usually) |
PUT | Replace | Yes |
PATCH | Partial update | No (depends) |
DELETE | Delete | Yes |
Authentication
Most APIs require a key or token. On ApiNest, send x-api-key
:
curl -H "x-api-key: YOUR_KEY" https://apinest.com/api/v1/fact
Versioning
Version in the path (e.g., /v1
) so you can evolve without breaking clients.
Pagination, rate limits, caching
Paginate long lists and respect rate limits. Cache immutable GETs.
GET /api/v1/items?limit=20&sort=created_desc 200 OK { "items": [...], "nextCursor": "eyJpZCI6IjEyMyJ9" }
async function call(url, opts){ for (let i=0;i<3;i++){ const res = await fetch(url, opts) if (res.status === 429){ const ra = +res.headers.get('Retry-After') || 2**i await new Promise(r=>setTimeout(r, ra*1000)); continue } if (!res.ok) throw new Error((await res.json()).message) return res.json() } }
Error handling
{ "error": "RATE_LIMIT_MINUTE", "message": "Rate limit exceeded. Try again in a minute.", "retryAfter": 60 }
Try it now
# Joke curl -H "x-api-key: YOUR_KEY" https://apinest.com/api/v1/joke # Pokemon curl -H "x-api-key: YOUR_KEY" "https://apinest.com/api/v1/pokemon?name=pikachu"
FAQ
Is REST the only option?
No. There’s also gRPC, GraphQL, and WebSockets. REST remains the most interoperable for public APIs.
Why do I see 401 or 429?
401 means missing/invalid auth; 429 means rate limit. Include the key and add retries with backoff.