An API is how software talks to other software. Every time you log into a website with Google, check the weather on your phone, or pay with Stripe, an API is doing the work behind the scenes. Understanding APIs is one of the most useful concepts in modern programming — and it's simpler than the jargon makes it sound.
What changed in 2026
- AI APIs are everywhere. Calling a language model API (OpenAI, Anthropic, Google Gemini) is now a standard task for developers of all levels — same mechanics as any REST API.
- API-first development is the norm. Most products are built as a backend API consumed by multiple frontends (web, mobile, partner integrations).
- OpenAPI/Swagger documentation is expected. Well-designed APIs ship with auto-generated interactive docs at
/docs or similar.
- Webhooks complement REST — APIs now often push events to your server rather than waiting to be polled.
The core concept
An API (Application Programming Interface) is a contract: "if you send me a request in this format, I will send back a response in that format."
A restaurant analogy: the menu is the API documentation (what you can order), your order is the request, and the food that arrives is the response. The kitchen (the server) handles the actual work — you never see how it's done.
How a REST API works
Most web APIs you'll encounter are REST APIs. They use standard HTTP:
| HTTP method |
What it means |
Example |
| GET |
Retrieve data |
Get a list of users |
| POST |
Create new data |
Create a new user |
| PUT / PATCH |
Update existing data |
Update a user's email |
| DELETE |
Remove data |
Delete a user |
The API returns data as JSON — a simple key-value text format every language can parse.
Calling your first API
You don't need code to call an API. Use curl in your terminal:
# Get a random joke from a public API (no key required)
curl https://official-joke-api.appspot.com/random_joke
Response:
{
"id": 17,
"type": "general",
"setup": "Why can't you give Elsa a balloon?",
"punchline": "Because she'll let it go."
}
In JavaScript (browser console or Node.js):
// fetch() is built into modern browsers and Node 18+
const res = await fetch('https://official-joke-api.appspot.com/random_joke');
const joke = await res.json();
console.log(joke.setup);
console.log(joke.punchline);
Using an API that requires a key
Most real APIs require authentication via an API key — a long secret string that identifies your account.
import httpx # pip install httpx
API_KEY = "your_key_here" # never hardcode real keys; use env vars
response = httpx.get(
"https://api.openweathermap.org/data/2.5/weather",
params={"q": "London", "appid": API_KEY, "units": "metric"}
)
data = response.json()
print(f"Temperature: {data['main']['temp']}°C")
Store API keys in environment variables, never in your code:
export WEATHER_API_KEY="abc123..."
import os
API_KEY = os.environ["WEATHER_API_KEY"]
REST vs GraphQL vs gRPC
| Style |
When to use it |
Complexity |
| REST |
Default choice; broad ecosystem |
Low |
| GraphQL |
Flexible queries; client picks fields |
Medium |
| gRPC |
High-performance, internal services |
Higher |
| WebSockets |
Real-time two-way (chat, live data) |
Medium |
For 99% of beginner projects, REST is the right choice. You'll encounter GraphQL on larger platforms (GitHub, Shopify APIs).
How to explore an API
- Read the documentation — every good API has docs with examples.
- Try requests in Postman or Insomnia — GUI tools for sending API calls without writing code.
- Check for OpenAPI specs — most modern APIs ship a
/openapi.json or Swagger UI at /docs.
- Look for client libraries — official SDKs (Python, JavaScript) wrap the API so you don't manually build every request.
Common mistakes
Putting API keys in frontend JavaScript. Anyone who visits your site can read them. Keys belong on the server or in environment variables.
Ignoring HTTP status codes. 200 means OK, 400 means your request was wrong, 401 means unauthorized, 404 means not found, 500 means server error. Always check the status before using the response data.
Not handling rate limits. Most free API tiers limit requests per minute. Build in retry logic with backoff for production code.
Ignoring pagination. APIs rarely return all records at once. Look for next_page, cursor, or offset in responses.
What to skip
- Building your own auth protocol — use API keys, OAuth, or JWTs as the provider specifies; don't invent your own scheme.
- Polling every second for updates — use webhooks (the API pushes to you) when available; polling hammers rate limits.
- Parsing JSON manually — every language has a built-in JSON parser; use it.
FAQ
What's the difference between an API and a website?
A website returns HTML meant for humans to read in a browser. An API returns structured data (usually JSON) meant for other software to consume.
Do I need to be a programmer to use an API?
For basic usage: tools like Zapier and Make let non-developers connect APIs visually. For custom integrations: yes, basic programming is required.
What is an API endpoint?
A specific URL that accepts a request. https://api.example.com/users is an endpoint. https://api.example.com/users/42 is a different endpoint that returns user with ID 42.
How do I find free APIs to practice with?
The public-apis repository on GitHub lists hundreds of free, open APIs organized by category. No sign-up required for many of them.
Where to go next
See REST API best practices in 2026, SQL for beginners in 2026, and How to build a website in 2026.