Skills
Chapter 4 of 5
Integrate Apify into an existing JavaScript/TypeScript or Python application using the apify-client package.
2 minutes · 427 words · 21 sections
Add Apify Actor execution to an existing application. This skill covers the apify-client package for JS/TS and Python, plus the REST API for other languages.
apify-clientis the API client for calling Actors from your app.apifyis the SDK for building Actors (wrong package for this use case).Always install
apify-client. Never installapifyfor integration work.
The user needs an APIFY_TOKEN. Direct them to Console > Settings > Integrations at https://console.apify.com/settings/integrations (opens in a new tab) to create one. If they don’t have an account: https://console.apify.com/sign-up (opens in a new tab) (free, no credit card).
Store the token securely — environment variable or secrets manager, never hardcoded.
Before writing integration code, find the Actor that fits the user’s needs. Use the MCP tools if available:
search-actors — search the Apify Store by keywordfetch-actor-details — get the Actor’s input schema, output format, and pricingAlternatively, browse https://apify.com/store (opens in a new tab). Append .md to any Actor’s Store URL to get its docs in markdown.
npm install apify-clientimport { 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' }],
maxPagesPerCrawl: 10,
});
const { items } = await client.dataset(run.defaultDatasetId).listItems();.call() blocks until the Actor finishes. Use for short-running Actors (under a few minutes).
const run = await client.actor('apify/web-scraper').start({
startUrls: [{ url: 'https://example.com' }],
});
// Poll for completion
const finishedRun = await client.run(run.id).waitForFinish();
// Retrieve results
const { items } = await client.dataset(finishedRun.defaultDatasetId).listItems();Use .start() + .waitForFinish() for long-running Actors or when you need the run ID immediately.
// Dataset items (structured data from pushData)
const { items } = await client.dataset(run.defaultDatasetId).listItems({
limit: 100,
offset: 0,
});
// Key-value store (files, screenshots, etc.)
const record = await client.keyValueStore(run.defaultKeyValueStoreId).getRecord('OUTPUT');try {
const run = await client.actor('apify/web-scraper').call(input);
if (run.status !== 'SUCCEEDED') {
const log = await client.log(run.id).get();
throw new Error(`Actor failed with status ${run.status}: ${log}`);
}
const { items } = await client.dataset(run.defaultDatasetId).listItems();
} catch (error) {
if (error.message?.includes('not found')) {
// Actor ID is wrong or Actor was deleted
} else if (error.statusCode === 401) {
// Invalid or missing APIFY_TOKEN
}
throw error;
}pip install apify-clientfrom apify_client import ApifyClient
import os
client = ApifyClient(token=os.environ['APIFY_TOKEN'])
run = client.actor('apify/web-scraper').call(run_input={
'startUrls': [{'url': 'https://example.com'}],
'maxPagesPerCrawl': 10,
})
items = client.dataset(run['defaultDatasetId']).list_items().itemsrun = client.actor('apify/web-scraper').start(run_input={
'startUrls': [{'url': 'https://example.com'}],
})
# Poll for completion
finished_run = client.run(run['id']).wait_for_finish()
items = client.dataset(finished_run['defaultDatasetId']).list_items().itemsfrom apify_client import ApifyClientAsync
client = ApifyClientAsync(token=os.environ['APIFY_TOKEN'])
run = await client.actor('apify/web-scraper').call(run_input={
'startUrls': [{'url': 'https://example.com'}],
})
items = (await client.dataset(run['defaultDatasetId']).list_items()).itemsFor languages without an official client, use the REST API directly.
POST https://api.apify.com/v2/actors/{actorId}/runs
Authorization: Bearer <APIFY_TOKEN>
Content-Type: application/json
{ "startUrls": [{ "url": "https://example.com" }] }GET https://api.apify.com/v2/actor-runs/{runId}
Authorization: Bearer <APIFY_TOKEN>GET https://api.apify.com/v2/datasets/{datasetId}/items?format=json
Authorization: Bearer <APIFY_TOKEN>Full API reference: https://docs.apify.com/api/v2 (opens in a new tab)
timeoutSecs in the Actor input or use waitSecs on .call() to avoid indefinite waits.limit and offset when retrieving dataset items. Default limit is 250K items.ApifyClient instance and reuse it across calls.fetch-actor-details MCP tool or append .md to the Actor’s Store URL to get the schema before constructing input.If the Apify MCP server is available, use search-apify-docs and fetch-apify-docs tools for contextual documentation lookups during development.
Install this repository
npx skills add apify/agent-skills/plugin marketplace add apify/agent-skillsSkills install per repository, not per chapter — the CLI has no documented per-skill form, so we do not print one.
Integrate Apify into an existing JavaScript/TypeScript or Python application using the apify-client package. Use when adding web scraping, automation, or data extraction capabilities to an existing app via the Apify API.
The verbatim description from this skill’s front matter — the string an agent matches on to decide whether to load it.
main, last pushed 4 August 2026.SKILL.md, not by matching a directory convention. One layout observed: skills/*/SKILL.md.h1 and no skipped levels:.claude-plugin/marketplace.json by Apify, declaring 6 plugins. It is read for editorial metadata only — never as the skill index, which is always the repository tree./apify/agent-skills.md, and each chapter at its own .md URL.