API (API)
An API is a contract between two pieces of software that defines how they talk to each other. When you check the weather on your phone, the app sends a request to a weather API (“Give me the forecast for Austin, TX”), and the API sends back structured data that the app displays. You never see the API directly; you see the result. APIs let applications share data and capabilities without exposing their internal workings.
An Application Programming Interface (API) is a defined interface that specifies how software components interact. In web development, “API” most commonly refers to HTTP-based web APIs that exchange data between clients and servers.
API styles:
- REST (Representational State Transfer): resource-oriented, uses HTTP methods (GET, POST, PUT, DELETE), stateless, most common web API style
- GraphQL: query language allowing clients to request exactly the fields they need, single endpoint
- gRPC: binary protocol using Protocol Buffers, high performance, used for microservice communication
- WebSocket: persistent bidirectional connection for real-time data (chat, live updates)
- JSON-RPC: remote procedure call encoded in JSON, used by MCP (Model Context Protocol)
HTTP API conventions:
| Method | Purpose | Idempotent |
|---|---|---|
| GET | Read a resource | Yes |
| POST | Create a resource | No |
| PUT | Replace a resource | Yes |
| PATCH | Partial update | No |
| DELETE | Remove a resource | Yes |
API design concepts:
- Endpoints: URL paths representing resources (
/api/v1/users/123) - Authentication: API keys, OAuth 2.0, JWT tokens
- Rate limiting: cap requests per time window to prevent abuse
- Versioning: URL path (
/v1/), header, or query parameter - Pagination: limit response size for large collections (cursor-based or offset-based)
- Status codes: 200 (OK), 201 (Created), 400 (Bad Request), 401 (Unauthorized), 404 (Not Found), 429 (Rate Limited), 500 (Server Error)
API interaction with curl
# GET request: fetch a resource
$ curl -s https://api.example.com/v1/users/123 \
-H "Authorization: Bearer sk-abc123" | jq
{
"id": 123,
"name": "Mokey",
"email": "mokey@bytesnation.com",
"role": "admin"
}
# POST request: create a resource
$ curl -s -X POST https://api.example.com/v1/users \
-H "Authorization: Bearer sk-abc123" \
-H "Content-Type: application/json" \
-d '{"name": "New User", "email": "new@example.com"}' | jq
{
"id": 456,
"name": "New User",
"created_at": "2026-04-15T12:00:00Z"
}
# Check rate limit headers
$ curl -sI https://api.example.com/v1/users
X-RateLimit-Limit: 1000
X-RateLimit-Remaining: 847
X-RateLimit-Reset: 1713200000 APIs are the connective tissue of modern software. Every mobile app, every SaaS integration, every cloud service, and every AI tool communicates through APIs. When you connect Slack to GitHub, or when Claude Code calls tools, APIs make it happen. In IT infrastructure, APIs control cloud resources (AWS API, Azure REST API), manage network devices (Meraki Dashboard API, UniFi API), and feed monitoring systems (Prometheus, Datadog). The shift toward “API-first” design means building the API before the UI, enabling automation and integration from day one. MCP (Model Context Protocol) is an API standard specifically designed for AI tools to interact with external services, using JSON-RPC 2.0 over STDIO or HTTP.