Skip to main content

Node

Scrape, crawl, and extract structured data from websites using the Firecrawl Node SDK.
4 min read

Scrape single pages, crawl entire sites, and map URLs from your Node.js application. The SDK handles pagination, retries, and async job polling so you can focus on working with the returned data.

Installation#

Install the SDK with npm:

Node

Usage#

  1. Get an API key from firecrawl.dev
  2. Set the API key as an environment variable named FIRECRAWL_API_KEY or pass it as a parameter to the Firecrawl class.
Note

No API key? You can construct Firecrawl without a key and use scrape, search, and interact on the keyless free tier (rate-limited per IP — see Rate Limits). All other methods require a key.

Here's an example of how to use the SDK with error handling:

Node

Scraping a URL#

Scrape a single URL and get back structured page data with the scrape method.

Node

Parsing uploaded files#

Use parse when you want to upload a local file (html, pdf, docx, xlsx, etc.) instead of scraping by URL. parse does not support changeTracking or browser-only options like screenshot, branding, actions, waitFor, location, and mobile.

Node

Crawling a Website#

Crawl an entire website starting from a single URL with the crawl method. You can set a page limit, restrict to specific domains, and choose output formats. See Pagination for auto and manual pagination.

Node

Sitemap-Only Crawl#

Use sitemap: "only" to crawl sitemap URLs only (the start URL is always included, and HTML link discovery is skipped).

Node

Start a Crawl#

Start a crawl without waiting for it to finish using startCrawl. The method returns a job ID you can poll later. Use crawl instead when you want to block until completion. See Pagination for paging behavior and limits.

Node

Checking Crawl Status#

Check whether a crawl is still running, completed, or failed with the checkCrawlStatus method. Pass the job ID returned by startCrawl.

Node

Cancelling a Crawl#

Cancel a running crawl with the cancelCrawl method. Pass the job ID returned by startCrawl.

Node

Mapping a Website#

Discover all URLs on a website with the map method. Pass a starting URL and get back a list of discovered pages.

Node

Running an Agent#

Hand a research or extraction task to an agent with the agent method. Pass a prompt, an optional schema to shape the output, and maxCredits to cap what the run can spend.

Node

Agent runs are asynchronous. Use startAgent to get a job ID back immediately, then poll it with getAgentStatus.

Node

Every run also records an execution trace and output snapshots, which you can read with getAgentTrace and getAgentSnapshot. See Agent for the event schema and the full parameter list.

Crawling a Website with WebSockets#

Stream crawl results in real time with watcher(jobId, options). You receive each page as it is crawled instead of waiting for the entire job to finish.

Node

Pagination#

Firecrawl endpoints for crawl and batch return a next URL when more data is available. The Node SDK auto-paginates by default and aggregates all documents; in that case next will be null. You can disable auto-pagination or set limits.

Crawl#

Use the waiter method crawl for the simplest experience, or start a job and page manually.

Simple crawl (auto-pagination, default)
Manual crawl with pagination control (single page)
  • Start a job, then fetch one page at a time with autoPaginate: false.
Node
Manual crawl with limits (auto-pagination + early stop)
  • Keep auto-pagination on but stop early with maxPages, maxResults, or maxWaitTime.
Node

Batch Scrape#

Use the waiter method batchScrape, or start a job and page manually.

Simple batch scrape (auto-pagination, default)
Manual batch scrape with pagination control (single page)
  • Start a job, then fetch one page at a time with autoPaginate: false.
Node
Manual batch scrape with limits (auto-pagination + early stop)
  • Keep auto-pagination on but stop early with maxPages, maxResults, or maxWaitTime.
Node

Browser#

Launch cloud browser sessions and execute code remotely.

Create a Session#

Node

Execute Code#

Node

Execute JavaScript instead of Python:

Node

Execute bash with agent-browser:

Node

Profiles#

Save and reuse browser state (cookies, localStorage, etc.) across sessions:

Node

Connect via CDP#

For full Playwright control, connect directly using the CDP URL:

Node

List & Close Sessions#

Node

Scrape-Bound Interactive Session#

Use a scrape job ID to keep interacting with the replayed page context from that scrape:

  • interact(jobId, {...}) runs code in the scrape-bound browser session.
  • First interact call auto-initializes the session from the scrape context.
  • Additional interact calls on the same job ID reuse that live browser state.
  • stopInteraction(jobId) stops the interactive session when you are done.
Node

Error Handling#

The SDK throws descriptive exceptions for any errors returned by the Firecrawl API. Wrap calls in try/catch blocks as shown in the examples above.

Are you an AI agent that needs a Firecrawl API key? See firecrawl.dev/agent-onboarding/SKILL.md for automated onboarding instructions.