Skip to main content

Apify API

Apify API provides programmatic access to the Apify Platform

API reference

The Apify API allows developers to interact programmatically apps using HTTP requests. The Apify API is built around REST.

The API has predictable resource-oriented URLs, returns JSON-encoded responses, and uses standard HTTP response codes, authentication, and verbs.

cURL
# Prepare Actor input
cat > input.json <<'EOF'
{
// Define the input in JSON here
}
EOF

# Run the Actor
curl "https://api.apify.com/v2/acts/username~actorname/runs?token=<YOUR_API_TOKEN>" \
-X POST \
-d @input.json \
-H 'Content-Type: application/json'

# Use the defaultDatasetId from response and pass it instead of <DATASET_ID>
curl "https://api.apify.com/v2/datasets/<DATASET_ID>/items?token=<YOUR_API_TOKEN>"

API client

The official library to interact with Apify API.
JavaScript Client
Python Client

JavaScript API client

The official library to interact with Apify API from a web browser, Node.js, JavaScript, or Typescript applications.Star
npm install apify-client
// Easily run Actors, await them to finish using the convenient .call() method, and retrieve results from the resulting dataset.
const { ApifyClient } = require('apify-client');

const client = new ApifyClient({
token: 'MY-APIFY-TOKEN',
});

// Starts an actor and waits for it to finish.
const { defaultDatasetId } = await client.actor('john-doe/my-cool-actor').call();

// Fetches results from the actor's dataset.
const { items } = await client.dataset(defaultDatasetId).listItems();

Related articles