PluginBench
Skill
Official
Review
Audit score 70

apify-sdk-integration

apify/agent-skills

Integrate Apify web scraping and automation into JavaScript, TypeScript, or Python apps via the apify-client package.

What is apify-sdk-integration?

Add Apify Actor execution to existing applications using the apify-client package (JS/TS/Python) or REST API. Use this when you need to call Apify Actors programmatically to perform web scraping, automation, or data extraction as part of your app's workflow.

  • Execute Apify Actors synchronously (blocking until completion) or asynchronously (start and poll later)
  • Retrieve structured data from Actor results via datasets and key-value stores
  • Handle Actor input schemas and pass configuration parameters programmatically
  • Manage run status, logs, and error handling for failed or incomplete executions
  • Support multiple languages via apify-client (JS/TS/Python) or direct REST API calls

How to install apify-sdk-integration

npx skills add https://github.com/apify/agent-skills --skill apify-sdk-integration
Prerequisites
  • An Apify account (free, no credit card required) and an APIFY_TOKEN from Console > Settings > Integrations
  • npm (for JavaScript/TypeScript) or pip (for Python) to install apify-client
  • Knowledge of the specific Actor's input schema before writing integration code (use search-actors or browse apify.com/store)
Claude Code
Cursor
Windsurf
Cline

How to use apify-sdk-integration

  1. 1.Create or obtain an APIFY_TOKEN from https://console.apify.com/settings/integrations and store it in an environment variable
  2. 2.Install the apify-client package: npm install apify-client (JS/TS) or pip install apify-client (Python)
  3. 3.Find the Actor you need using search-actors MCP tool or browse https://apify.com/store, then note its actor ID
  4. 4.Initialize an ApifyClient with your token and call the Actor using .call() for synchronous execution or .start() + .waitForFinish() for asynchronous execution
  5. 5.Retrieve results from the run's defaultDatasetId or defaultKeyValueStoreId using listItems() or getRecord()
  6. 6.Handle errors by checking run.status and retrieving logs if the Actor fails

Use cases

Good for
  • Add web scraping capabilities to a Node.js or Python backend without building custom crawlers
  • Integrate Apify Actors into a data pipeline to extract and transform web data automatically
  • Build a SaaS product that uses Apify Actors as a backend service for end-user automation
  • Call multiple Actors in sequence to perform complex multi-step data extraction workflows
  • Retrieve and process Actor results (screenshots, structured data, files) in application code
Who it's for
  • Backend developers integrating third-party automation into existing applications
  • Data engineers building ETL pipelines that rely on web scraping
  • SaaS builders offering web automation or data extraction features to customers
  • Full-stack developers adding scraping capabilities to Node.js or Python projects

apify-sdk-integration FAQ

What is the difference between apify-client and apify packages?

apify-client is for calling Actors from your application code (integration). apify is the SDK for building Actors. Always install apify-client for this skill.

Should I use .call() or .start() + .waitForFinish()?

Use .call() for short-running Actors (under a few minutes) as it blocks until completion. Use .start() + .waitForFinish() for long-running Actors or when you need the run ID immediately.

How do I find the correct input schema for an Actor?

Use the search-actors and fetch-actor-details MCP tools if available, or append .md to any Actor's Store URL (e.g., https://apify.com/apify/web-scraper.md) to view its documentation in markdown.

What should I do if the Actor fails or times out?

Check run.status and retrieve the run log using client.log(run.id).get() to see error details. Set timeoutSecs in the Actor input or waitSecs on .call() to control timeout behavior.

Can I use this with languages other than JavaScript and Python?

Yes, use the REST API directly for any language. Make HTTP requests to https://api.apify.com/v2 with your APIFY_TOKEN in the Authorization header.

Full instructions (SKILL.md)

Source of truth, from apify/agent-skills.


name: apify-sdk-integration description: 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.

Apify SDK Integration

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.

When to Use This Skill

  • Adding web scraping or automation to an existing app
  • Calling Apify Actors programmatically from application code
  • Building a product that uses Apify as a backend service
  • Integrating Actor results into a data pipeline

Critical: Package Naming

apify-client is the API client for calling Actors from your app. apify is the SDK for building Actors (wrong package for this use case).

Always install apify-client. Never install apify for integration work.

Prerequisites

The user needs an APIFY_TOKEN. Direct them to Console > Settings > Integrations at https://console.apify.com/settings/integrations to create one. If they don't have an account: https://console.apify.com/sign-up (free, no credit card).

Store the token securely — environment variable or secrets manager, never hardcoded.

Finding the Right Actor

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 keyword
  • fetch-actor-details — get the Actor's input schema, output format, and pricing

Alternatively, browse https://apify.com/store. Append .md to any Actor's Store URL to get its docs in markdown.

JavaScript / TypeScript

Install

npm install apify-client

Synchronous Execution (wait for results)

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' }],
    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).

Asynchronous Execution (start and poll/retrieve later)

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.

Retrieving Results

// 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');

Error Handling

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;
}

Python

Install

pip install apify-client

Synchronous Execution

from 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().items

Asynchronous Execution

run = 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().items

Async Client (asyncio)

from 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()).items

REST API (Any Language)

For languages without an official client, use the REST API directly.

Start a Run

POST https://api.apify.com/v2/acts/{actorId}/runs
Authorization: Bearer <APIFY_TOKEN>
Content-Type: application/json

{ "startUrls": [{ "url": "https://example.com" }] }

Get Run Status

GET https://api.apify.com/v2/acts/{actorId}/runs/{runId}
Authorization: Bearer <APIFY_TOKEN>

Get Dataset Items

GET https://api.apify.com/v2/datasets/{datasetId}/items?format=json
Authorization: Bearer <APIFY_TOKEN>

Full API reference: https://docs.apify.com/api/v2

Best Practices

  • Set timeouts: Pass timeoutSecs in the Actor input or use waitSecs on .call() to avoid indefinite waits.
  • Paginate large datasets: Use limit and offset when retrieving dataset items. Default limit is 250K items.
  • Reuse clients: Create one ApifyClient instance and reuse it across calls.
  • Handle Actor-specific input: Every Actor has its own input schema. Use fetch-actor-details MCP tool or append .md to the Actor's Store URL to get the schema before constructing input.

Documentation

If the Apify MCP server is available, use search-apify-docs and fetch-apify-docs tools for contextual documentation lookups during development.