Apify for AI agents
Connect your AI agent or application to Apify - the platform for web scraping, data extraction, and browser automation. The typical agent workflow: find an Actor, run it, get structured data back.
Core concepts
- Actors - Serverless cloud programs that perform scraping, crawling, or automation tasks. Thousands of ready-made Actors are available in Apify Store.
- Datasets - Append-only storage for structured results. Every Actor run creates a default dataset. Export as JSON, CSV, Excel, XML, or RSS.
- API - RESTful API at
https://api.apify.com/v2for all platform operations. Also accessible via MCP, CLI, and client libraries.
Prerequisites
Sign up to Apify Console. The free plan includes monthly platform usage credits with no credit card required. Get your API token from Console > Settings > Integrations.
The MCP server's search-actors, fetch-actor-details, and docs tools work without authentication. You can browse Actors and documentation without an account.
Run your first Actor
Every Apify Actor follows the same pattern: send input as JSON, get structured data back. The shortest path through each of the main integration methods, using the agent-optimized RAG Web Browser Actor:
- MCP
- JavaScript
- Python
- CLI
After connecting the MCP server to your AI assistant, ask:
Use Apify's RAG Web Browser to find the top 3 pages about Apify documentation, then summarize.
Your agent calls search-actors, call-actor, and reads the resulting dataset items - all through MCP, no code required.
import { ApifyClient } from 'apify-client';
const client = new ApifyClient({ token: process.env.APIFY_TOKEN });
const run = await client.actor('apify/rag-web-browser').call({
query: 'Apify documentation',
maxResults: 3,
});
const { items } = await client.dataset(run.defaultDatasetId).listItems();
import os
from apify_client import ApifyClient
client = ApifyClient(token=os.environ['APIFY_TOKEN'])
run = client.actor('apify/rag-web-browser').call(
run_input={'query': 'Apify documentation', 'maxResults': 3},
)
items = client.dataset(run['defaultDatasetId']).list_items().items
apify login # one-time
apify call apify/rag-web-browser \
-i '{"query": "Apify documentation", "maxResults": 3}' \
--output-dataset
The pattern is the same across every integration method: pick an Actor, send input, receive structured data. Choose the connection method below that fits your stack.
When an agent calls Actors automatically, set run limits to prevent surprise bills. Pass these as query parameters on the run Actor endpoint:
memory(MB) - power of 2, minimum 128. Lower memory means lower cost per second.timeout(seconds) - cap how long a single run can last.maxTotalChargeUsd- cap total run cost for pay-per-event Actors.
See Usage and resources and Billing for details.
Choose your integration method
| Method | Best for | Auth |
|---|---|---|
| MCP server | AI agents and coding assistants | OAuth or API token |
| API client | Backend apps (JavaScript/Python) | API token |
| CLI | Building and deploying custom Actors | API token |
| REST API | Any language, HTTP integrations, no-code tools | API token |
MCP server
The Apify MCP server connects your agent to the full Apify platform via the Model Context Protocol. No local installation needed for remote-capable clients.
Remote (recommended)
Works with Claude Code, Cursor, VS Code, GitHub Copilot, and other remote-capable clients.
-
Add the following to your MCP client's configuration:
{
"mcpServers": {
"apify": {
"url": "https://mcp.apify.com"
}
}
} -
Restart your client and sign in when prompted. OAuth handles authentication automatically.
Local/stdio
For clients that only support local MCP servers, for example Claude Desktop.
-
Add the following to your MCP client's configuration:
{
"mcpServers": {
"apify": {
"command": "npx",
"args": ["-y", "@apify/actors-mcp-server"],
"env": { "APIFY_TOKEN": "YOUR_TOKEN" }
}
}
} -
Replace
YOUR_TOKENwith your API token and restart the client.
For client-specific setup instructions, use the MCP Configurator which generates ready-to-paste configs. For details, see the MCP server documentation.
API client
For integrating Apify into your application code.
apify-client is the API client for calling Actors. The apify package is the SDK for building Actors. For backend integration, install apify-client.
- JavaScript / TypeScript
- Python
npm install apify-client
import { ApifyClient } from 'apify-client';
const client = new ApifyClient({ token: process.env.APIFY_TOKEN });
const run = await client.actor('apify/web-scraper').call({
startUrls: [{ url: 'https://example.com' }],
});
const { items } = await client.dataset(run.defaultDatasetId).listItems();
Full reference: JavaScript API client docs
pip install apify-client
import os
from apify_client import ApifyClient
client = ApifyClient(token=os.environ['APIFY_TOKEN'])
run = client.actor('apify/web-scraper').call(
run_input={'startUrls': [{'url': 'https://example.com'}]}
)
items = client.dataset(run['defaultDatasetId']).list_items().items
Full reference: Python API client docs
CLI
For running Actors and building custom ones from the command line.
Install on macOS or Linux (Windows and Homebrew alternatives in the CLI install docs):
curl -fsSL https://apify.com/install-cli.sh | bash
apify login # authenticate with your API token
Discover and inspect Actors:
apify actors search scraping # search Apify Store
apify actors info apify/web-scraper --readme # get Actor README
apify actors info apify/web-scraper --input # get input schema
Run an Actor and get its output:
apify actors call apify/web-scraper \
-i '{"startUrls": [{"url": "https://example.com"}]}' \
--output-dataset
Build and deploy custom Actors:
apify create my-actor # scaffold (JS/TS/Python)
apify run # test locally
apify push # deploy to Apify cloud
Full reference: Apify CLI documentation.
REST API
For HTTP-native integrations or languages without a dedicated client. Base URL: https://api.apify.com/v2. Authenticate with the Authorization: Bearer YOUR_TOKEN header.
Quick reference
| Action | Method | Endpoint |
|---|---|---|
| Search Actors in Store | GET | /v2/store |
| Get Actor details | GET | /v2/acts/{actorId} |
| Run an Actor | POST | /v2/acts/{actorId}/runs |
| Run Actor (sync, get results) | POST | /v2/acts/{actorId}/run-sync-get-dataset-items |
| Get run status | GET | /v2/actor-runs/{runId} |
| Get dataset items | GET | /v2/datasets/{datasetId}/items |
The sync endpoint (run-sync-get-dataset-items) runs an Actor and returns results in a single request (waits up to 5 minutes). Use async endpoints for longer runs.
For runs that take longer than the sync timeout, prefer webhooks over polling - Apify will POST a notification to your URL when the run finishes, avoiding wasted requests.
Full reference: Apify API v2.
Agent Skills
Once you connect an agent via MCP or a coding assistant, Apify Agent Skills add pre-built workflows on top - guiding the agent through multi-step scraping pipelines and Actor development tasks. Skills are not a separate integration method; they layer over your existing connection.
Install into Claude Code, Cursor, Gemini CLI, or OpenAI Codex:
npx skills add apify/agent-skills
| Skill | What it does |
|---|---|
apify-ultimate-scraper | Routes web scraping requests to the right Actor for multi-step data pipelines |
apify-actor-development | Guided workflow for building and deploying custom Actors |
apify-actorization | Converts an existing project into an Apify Actor |
apify-generate-output-schema | Auto-generates output schemas from Actor source code |
For the full list and details, see the skills registry.
Documentation access for agents
Apify documentation is available in formats optimized for programmatic consumption.
| Resource | How to access |
|---|---|
| Specific doc page | Append .md to any docs URL (for example, docs.apify.com/platform/actors.md) |
| Specific doc page (alt) | Request with Accept: text/markdown header |
| Docs index | docs.apify.com/llms.txt |
| Full docs (large) | docs.apify.com/llms-full.txt |
| Actor Store pages | Append .md to any Apify Store URL |
| MCP docs tools | search-apify-docs, fetch-apify-docs |
For targeted lookups, prefer .md URLs for specific pages or the MCP docs tools over the full llms-full.txt file. Agents with limited context windows may not load llms-full.txt fully.
Useful resources
- MCP server integration - Tool customization, dynamic Actor discovery, and advanced configuration
- CLI documentation - Complete command reference
- API reference - All REST API endpoints
- API client for JavaScript | for Python - Client libraries
- Storage documentation - Datasets, key-value stores, and request queues
- Build with AI - Build and deploy your first Actor
- Framework integrations - CrewAI, LangChain, LlamaIndex, and more