How to Connect Claude AI to Apify
Connecting Claude AI to Apify means wiring two separate APIs together so that Claude can trigger a scraper or automation (an Apify "actor"), read back the results, and reason over that data. There's no built-in integration between the two — you write the glue code yourself, either as a simple pipeline (run actor, feed output to Claude) or as a Claude tool call that runs the actor on demand.
This guide walks through both patterns, with working code, so you can pick the one that fits your use case.
What "connecting" Claude to Apify actually involves
Apify runs headless scrapers and automations called actors — think "scrape this Amazon listing," "crawl this site for emails," "monitor this URL for changes." Claude has no native way to reach the internet or run actors on its own; it only processes the text (or structured content) you send it.
So the connection is always application-level:
- Your code calls the Apify API to start an actor run and waits for (or polls for) the result.
- Your code sends that result — usually JSON — to Claude as part of the prompt or as a tool result.
- Claude summarizes, extracts, classifies, or acts on the data and returns text.
There are two common architectures:
- Pipeline (batch): run the actor first, then send the finished dataset to Claude in a single request. Simple, good for reports and one-off analysis.
- Tool use (agentic): give Claude a
run_apify_actortool definition. Claude decides when to call it, your backend executes the actor, and you feed the result back into the conversation. Good for chat assistants that need to fetch fresh data mid-conversation.
Step 1: Get your Apify API token
In the Apify console, go to Settings → Integrations and copy your API token. You'll use it to trigger actor runs via REST:
curl -X POST "https://api.apify.com/v2/acts/apify~web-scraper/run-sync-get-dataset-items?token=$APIFY_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"startUrls": [{ "url": "https://example.com" }],
"maxPagesPerCrawl": 5
}'
run-sync-get-dataset-items is the simplest endpoint for scripting: it runs the actor and returns the resulting dataset items directly, no polling required. For long-running crawls, use the async run endpoint and poll GET /v2/actor-runs/{runId} until the status is SUCCEEDED.
Step 2: Get access to Claude's API
You need a way to call Claude programmatically. If you're using Claude via a subscription (claude.ai) rather than Anthropic's developer console, you don't have a direct API key by default — subscriptions and API access are separate products.
SubToAPI solves that gap: it turns your existing Claude access into a standard HTTPS API with keys formatted sub_live_..., so you can call Claude from a script the same way you'd call any other API, with streaming, tool use, and usage metadata included. Sign up at /signup and generate a key from the dashboard.
Step 3: Pipeline approach — scrape, then ask Claude
This is the fastest way to get something working. Run the actor, capture the JSON, and pass it straight into a Claude request.
const APIFY_TOKEN = process.env.APIFY_TOKEN;
const SUBTOAPI_KEY = process.env.SUBTOAPI_KEY;
async function scrapeWithApify(url) {
const res = await fetch(
`https://api.apify.com/v2/acts/apify~web-scraper/run-sync-get-dataset-items?token=${APIFY_TOKEN}`,
{
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ startUrls: [{ url }], maxPagesPerCrawl: 1 }),
}
);
return res.json();
}
async function analyzeWithClaude(scrapedData) {
const res = await fetch("https://api.subtoapi.app/v1/messages", {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${SUBTOAPI_KEY}`,
},
body: JSON.stringify({
model: "claude-sonnet-4-5",
max_tokens: 1024,
messages: [
{
role: "user",
content: `Summarize the key points from this scraped page data:\n\n${JSON.stringify(scrapedData).slice(0, 8000)}`,
},
],
}),
});
return res.json();
}
const data = await scrapeWithApify("https://example.com/blog");
const summary = await analyzeWithClaude(data);
console.log(summary.content[0].text);
This works for reports, digests, and any workflow where scraping happens first and analysis happens after. See /docs/messages for the full request format.
Step 4: Tool-use approach — let Claude trigger Apify itself
If you want Claude to decide when to scrape — for example, inside a chat assistant that answers questions about live web data — define an Apify run as a tool Claude can call:
{
"name": "run_apify_actor",
"description": "Runs an Apify actor by ID with the given input and returns the dataset items.",
"input_schema": {
"type": "object",
"properties": {
"actorId": { "type": "string" },
"input": { "type": "object" }
},
"required": ["actorId", "input"]
}
}
Pass this tool definition in your request to /v1/messages. When Claude responds with a tool_use block, your backend calls the Apify API with the arguments Claude supplied, then sends the result back as a tool_result message so Claude can continue the conversation with fresh data in hand. This is the same tool-calling loop used for any external API — Apify is just the tool being executed. Full details on the request/response shape are in /docs/tools.
For actors that take longer than a few seconds, stream Claude's response while the actor runs in the background, or set expectations with a short "checking that now" message — see /docs/streaming for streaming setup.
Choosing the right approach
- Use the pipeline pattern for scheduled jobs, digests, and reports where you control the trigger.
- Use the tool-use pattern for interactive assistants where the user's question determines what needs scraping.
- Cache Apify results when possible — actor runs cost compute credits on Apify's side and add latency, so don't re-run a scrape for every Claude request if the underlying page hasn't changed.
Both patterns need a working Claude endpoint to send data to. If you're building on a Claude subscription rather than an Anthropic developer account, check /pricing for SubToAPI plans, or start with /docs/quickstart to get your first request running in a few minutes.
questions
Do I need an Apify account and a Claude API key to connect them? Yes — they're separate services with separate authentication. You need an Apify API token to trigger actor runs and a way to call Claude programmatically (either Anthropic's developer API or a service like SubToAPI if you're on a Claude subscription).
Can Claude scrape websites directly without Apify? No. Claude has no built-in internet access unless the interface you're using has browsing enabled. Apify (or any scraper) fetches the data, and you pass the results to Claude as text for it to process.
What's the difference between the pipeline and tool-use approaches? Pipeline means you run the Apify actor first and send finished data to Claude in one request — simpler and predictable. Tool use means Claude decides mid-conversation to call the actor, which suits interactive assistants that need on-demand, fresh data.