API
An API (Application Programming Interface) is a set of rules that lets one program request data or actions from another. It defines which requests you can send, in what format, and what response comes back. Claude Code itself sends requests to Anthropic's API to get the model's answers, and the apps you build with it often call the APIs of other services, such as payments or maps.
The way two programs talk to each other. It’s like a restaurant’s menu: it shows what you can ask for and what you get back.
How it shows up in Claude Code
APIs show up in two ways when you work with Claude Code.
First, Claude Code talks to an API itself. Every time you send a message, the program sends a request to the Claude model and gets the answer back. You can connect through a Claude subscription, an API key from the Claude Console, or a cloud provider such as Amazon Bedrock. You can see which route your requests take with /status.
Second, your projects use APIs. A site that shows the weather asks a weather service's API; an online payment goes through a payment provider's API. Claude can write the code that makes those requests and read the service's documentation to know what to ask for.
Example
You want your page to show the euro exchange rate. You tell Claude:
Add the euro exchange rate to the home page, taken from a public API. Tell me which API you pick, whether it needs a key and where we keep the key. Don't put the key in the code.
Claude finds a suitable service, writes the request and shows you the response it gets.
Common mistakes
- Putting an API's key straight into the code. It ends up in git, where anyone with access to the project can see it.
- Assuming an API is free and unlimited. Many have request limits or usage-based costs.
- Not checking what happens when the API doesn't answer. Ask Claude to handle the case where the service is down.
Related terms and where you learn it
Access to an API often needs an API key, kept as a secret in an environment variable. The exact address you send a request to is an endpoint, and the response usually comes back as JSON.
In the course: the lesson “How do you sign in to your account?” in module 00, Installation and first steps.
How it appears in the course
The one that runs a single test, not all of them. In the Acme API example it was pnpm test path/to/file.
Practice · Module 02, CLAUDE.md: your project’s memory
→ Where does the API key go?
For the curious · Module 03, Permissions: what Claude may do
For example, /compact keep the decisions about the API makes the summary and keeps the decisions about the API.
How do you look after the conversation memory? · Module 04, The working method, step by step
Learn Claude Code from zero, in plain English
12 modules with 1–2 minute lessons, which you can also do on your phone. The first two modules are free.