What is an API?
The menu of things a server can do
⏱ Est. ~4 min
01 · Read
An API (Application Programming Interface) is a set of rules that defines which requests a server will accept and what responses it'll send back.
When an engineer builds a server, they don't let just anyone throw any request at it. They define an API — a clear list of endpoints (URLs) you can call, what data to send, and what you'll get back.
Every app you use relies on APIs. When a weather app shows you the forecast, it's calling a weather API. When you log into a website, it's calling an auth API. When you scroll a social feed, it's calling an API to pull the next batch of posts.
💡 Picture thisAn API is like a restaurant menu. The menu tells you what you can order, what's in each dish, and how much it costs. You can't walk into the kitchen and make something yourself — you pick from the menu. APIs work the same way: they tell your app what it can ask the server for.
Key points
- API = Application Programming Interface
- It defines the "menu" of requests a server accepts
- Each menu item is called an endpoint (a specific URL + method)
- APIs let different software systems talk to each other without needing to know each other's internals
02 · Code example
Here's what a typical blog API looks like. Each endpoint is an HTTP method + a URL path.
Blog API Endpoints
GET /api/posts → Get all blog posts
GET /api/posts/15 → Get post #15
POST /api/posts → Create a new post
PUT /api/posts/15 → Update post #15
DELETE /api/posts/15 → Delete post #15
User API Endpoints
GET /api/users → Get all users
GET /api/users/42 → Get user #42's profile
POST /api/users → Create a new user (sign up)
PUT /api/users/42 → Update user #42's profile
DELETE /api/users/42 → Delete user #42's account
Notice the pattern: the URL tells you what you're operating on (/posts or /users), the number tells you which one, and the HTTP method tells you what you want to do. This consistent pattern makes APIs easy to guess and easy to use.
03 · Quiz
A mobile weather app shows today's forecast. How does it get that data?
- The forecast data is hard-coded into the app
- The app reads data from the phone's sensors
- The app calls a weather API to fetch the latest data
- The app scrapes a weather website
04 · Fill in the blank
An API defines which _____ a server will accept.
Other lessons in this chapter
⚠ The full interactive experience needs JavaScript. Please enable it and reload.
※ This is an independent Traditional Chinese teaching project — not an official Anthropic product. Claude™ is a trademark of Anthropic, PBC.