Skip to main content
Version: 3.4

Apify SDK for JavaScript

The Apify SDK for JavaScript is the official library for creating Apify Actors using JavaScript or TypeScript. It provides useful features like Actor lifecycle management, local storage emulation, and Actor event handling.

import { Actor } from 'apify';

await Actor.init();

const input = await Actor.getInput();
console.log(input);

await Actor.exit();

What are Actors

Actors are serverless programs that can do almost anything. From simple scripts and web scrapers to complex automation workflows, AI agents, or even always-on services that expose HTTP endpoints.

Actors can be executed locally or on the Apify platform. The Apify platform lets you run Actors at scale and provides features for monitoring, scheduling, publishing, and monetizing them.

What you can build

Almost any Node.js project can become an Actor, including projects for:

  • Web scraping and crawling - The SDK works seamlessly with Crawlee, which makes Apify a natural place to deploy and scale your crawlers. Start from a ready-made Cheerio template.
  • Browser automation - Drive a real browser with Playwright, Puppeteer, or Selenium to automate tasks, fill in forms, or test web apps.
  • AI agents - Host agents built with your framework of choice. Ready-made Actor templates cover LangChain, LangGraph, BeeAI, and Mastra.
  • MCP servers - Deploy an MCP server as an Actor and make its tools available to any MCP client. See the MCP server and MCP proxy templates.
  • Web servers and APIs - Run a web server inside an Actor to serve HTTP requests, for example to expose your scraper as a live API. See the Standby mode templates (JavaScript, TypeScript).

Whatever you build, the Apify SDK doesn't lock you into a particular framework. Bring the libraries you already use, and let Apify run your project in the cloud.

Quick start

To create and run Actors using Apify Console, check out Apify Console documentation. For creating and running JavaScript Actors locally, refer to the Actor lifecycle guide.

Explore the Guides section in the sidebar for a deeper understanding of the SDK's features and best practices.

Installation

The Apify SDK for JavaScript is typically installed when you create a new Actor project using the Apify CLI. To install it manually in an existing project, use:

npm install apify
API client alternative

If you need to interact with the Apify API programmatically without creating Actors, use the Apify API client for JavaScript instead.