Connect to APIs Using Claude Code
Pull data from web services and APIs using Claude Code as your translator.
Working with APIs (Without Being a Developer)
You've mastered files. But some data doesn't live in files — it lives in web services. Your CRM, your analytics, your project management tool. These services have APIs: ways for programs to request data directly.
The good news: you don't need to write code to use them. Claude Code can make API calls for you if you tell it what you want.
What's an API?
An API (Application Programming Interface) is like a door into a web service. Instead of clicking around a website, you can ask the API directly: "Give me all my customers" or "What's the current weather in Chicago?"
The API responds with structured data — usually JSON, which looks like this:
{
"customer_name": "Acme Corp",
"revenue": 50000,
"status": "active"
}Claude Code can read this data, process it, and combine it with your files.
Getting API access
Most services that have APIs require an "API key" — a password that identifies you. Here's how to get one:
- Log into the service (your CRM, analytics tool, etc.)
- Look for "Settings" → "API" or "Developer" or "Integrations"
- Generate an API key
- Copy it somewhere safe
For example, to get a weather API key:
- Go to openweathermap.org
- Create a free account
- Find your API key in your account dashboard
Security note: API keys are like passwords. Don't share them publicly or commit them to public code repositories.
Your first API call
Let's try something simple — getting weather data:
Use the OpenWeatherMap API to get the current weather in Chicago.
The API key is: [your-api-key]
The endpoint is: https://api.openweathermap.org/data/2.5/weather
Tell me:
- Current temperature (in Fahrenheit)
- Weather conditions (sunny, cloudy, etc.)
- HumidityClaude makes the request, parses the response, and gives you a readable answer.
Combining API data with files
The real power is combining API data with your existing files:
1. Read customers.csv — this has customer names and their city
2. For each unique city, get the current weather from OpenWeatherMap
3. Add a "current_weather" column to the customer data
4. Save as customers_with_weather.csvNow you have enriched data — your customer list enhanced with live information.
Common business API use cases
CRM data:
Pull all deals from our HubSpot API that closed this month.
The API key is: [key]
The endpoint is: https://api.hubspot.com/crm/v3/objects/deals
Create a summary with:
- Total deal value
- Average deal size
- List of deal names and amountsProject management:
Get all tasks from Asana that are due this week.
The API key is: [key]
Create a markdown checklist sorted by due date.Spreadsheet integration:
Pull data from this Google Sheet using the Sheets API:
Sheet ID: [id]
API key: [key]
Process it the same way as a CSV.Keeping API keys secure
Don't put API keys directly in your instructions. Better approach:
- Create a file:
~/.api-keys/openweathermap.txtcontaining just the key - In your instruction: "Read the API key from ~/.api-keys/openweathermap.txt"
Or use environment variables if you're comfortable with the terminal:
export WEATHER_API_KEY="your-key-here"Then in your instruction:
Use the API key from the WEATHER_API_KEY environment variable.API documentation
Every API has documentation describing:
- What endpoints are available (what you can request)
- What parameters to send
- What the response looks like
You don't need to memorize this. Just tell Claude:
The API documentation is at: https://service.com/api/docs
I want to get [whatever you want].Claude reads the docs and figures out the right call to make.
Rate limits and quotas
Most APIs limit how many requests you can make. A free tier might allow 100 requests per day. If your workflow processes 500 customers, you'll hit the limit.
For high-volume needs:
- Check if there's a "bulk" endpoint that returns many records at once
- Spread requests over multiple days
- Upgrade to a paid tier if the API is valuable enough
Claude will tell you if it hits a rate limit. You can then adjust your approach.
When APIs aren't available
Not every service has an API. If there's no API, you'll need to:
- Export data manually (CSV, Excel) and process the files
- Use a service like Zapier that connects to the app (more on this later)
- Check if there's an unofficial API or integration
Building an API-powered workflow
Here's a real example — daily sales briefing:
Every morning:
1. Pull yesterday's closed deals from HubSpot API
2. Pull website traffic from Google Analytics API
3. Read the sales_targets.csv file
Create a morning briefing that includes:
- Deals closed yesterday (names, amounts)
- Traffic vs. same day last week
- Progress toward monthly sales target
- Any deals in pipeline expected to close today
Save as briefing_[today's date].mdThree data sources — two APIs, one file — combined into one useful output.
Next up
API calls are powerful for one-time tasks, but what about recurring work? In the next lesson, you'll learn to schedule automations — run your workflows daily, weekly, or monthly without manual intervention.