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.
They can run either locally or on the Apify platform, where you can scale their execution, monitor runs, schedule tasks, integrate them with other services, or even publish and monetize them. If you're new to Apify, learn more about the platform in the Apify documentation.
For more context, read the Actor whitepaper.
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
If you need to interact with the Apify API programmatically without creating Actors, use the Apify API client for JavaScript instead.