Skip to main content
Version: Next

Overview

The Apify API client is the official library to access the Apify REST API from your JavaScript/TypeScript applications. It runs both in Node.js and browser and provides useful features like automatic retries and convenience functions that improve the experience of using the Apify API.

The client simplifies interaction with the Apify platform by providing:

All requests and responses (including errors) are encoded in JSON format with UTF-8 encoding.

Prerequisites

apify-client requires Node.js version 22 or higher. Node.js is available for download on the official website. Check for your current Node.js version by running:

node -v

Installation

You can install the client via NPM or any other package manager of your choice.

npm i apify-client

The client sends its requests through a built-in axios transport and compresses request bodies with brotli, so no optional packages are needed. For details, see HTTP clients and HTTP compression.

Quick example

The following example shows how to run an Actor and retrieve its results:

import { ApifyClient } from 'apify-client';

// You can find your API token at https://console.apify.com/account/integrations.
const client = new ApifyClient({ token: 'MY-APIFY-TOKEN' });

// Start an Actor and wait for it to finish.
const run = await client.actor('apify/web-scraper').call({
startUrls: [{ url: 'https://example.com' }],
maxCrawlPages: 10,
});

// Fetch results from the Actor run's default dataset.
const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log(items);

You can find your API token in the Integrations section of Apify Console. See the Quick start guide for more details on authentication.