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:
Usage#
- Get an API key from firecrawl.dev
- Set the API key as an environment variable named
FIRECRAWL_API_KEYor pass it as a parameter to theFirecrawlclass.
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:
Scraping a URL#
Scrape a single URL and get back structured page data with the scrape method.
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.
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.
Sitemap-Only Crawl#
Use sitemap: "only" to crawl sitemap URLs only (the start URL is always included, and HTML link discovery is skipped).
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.
Checking Crawl Status#
Check whether a crawl is still running, completed, or failed with the checkCrawlStatus method. Pass the job ID returned by startCrawl.
Cancelling a Crawl#
Cancel a running crawl with the cancelCrawl method. Pass the job ID returned by startCrawl.
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.
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.
Agent runs are asynchronous. Use startAgent to get a job ID back immediately, then poll it with getAgentStatus.
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.
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)
- See the default flow in Crawling a Website.
Manual crawl with pagination control (single page)
- Start a job, then fetch one page at a time with
autoPaginate: false.
Manual crawl with limits (auto-pagination + early stop)
- Keep auto-pagination on but stop early with
maxPages,maxResults, ormaxWaitTime.
Batch Scrape#
Use the waiter method batchScrape, or start a job and page manually.
Simple batch scrape (auto-pagination, default)
- See the default flow in Batch Scrape.
Manual batch scrape with pagination control (single page)
- Start a job, then fetch one page at a time with
autoPaginate: false.
Manual batch scrape with limits (auto-pagination + early stop)
- Keep auto-pagination on but stop early with
maxPages,maxResults, ormaxWaitTime.
Browser#
Launch cloud browser sessions and execute code remotely.
Create a Session#
Execute Code#
Execute JavaScript instead of Python:
Execute bash with agent-browser:
Profiles#
Save and reuse browser state (cookies, localStorage, etc.) across sessions:
Connect via CDP#
For full Playwright control, connect directly using the CDP URL:
List & Close Sessions#
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
interactcall auto-initializes the session from the scrape context. - Additional
interactcalls on the same job ID reuse that live browser state. stopInteraction(jobId)stops the interactive session when you are done.
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.

