Skip to main content

Prerequisites

Install the SDK

npm install @mendable/firecrawl-js

Environment variable

Instead of passing apiKey directly, set the FIRECRAWL_API_KEY environment variable:
export FIRECRAWL_API_KEY=fc-YOUR-API-KEY
const app = new Firecrawl();

Search the web

import Firecrawl from '@mendable/firecrawl-js';

const app = new Firecrawl({ apiKey: "fc-YOUR-API-KEY" });
const results = await app.search("firecrawl web scraping", { limit: 5 });

for (const result of results.web) {
  console.log(result.title, result.url);
}

Scrape a page

const result = await app.scrape("https://example.com");

console.log(result.markdown);
{
  "markdown": "# Example Domain\n\nThis domain is for use in illustrative examples...",
  "metadata": {
    "title": "Example Domain",
    "sourceURL": "https://example.com"
  }
}

Interact with a page

Use interact to control a live browser session — click buttons, fill forms, and extract dynamic content.
const result = await app.scrape('https://www.amazon.com', { formats: ['markdown'] });
const scrapeId = result.metadata?.scrapeId;

await app.interact(scrapeId, { prompt: 'Search for iPhone 16 Pro Max' });
const response = await app.interact(scrapeId, { prompt: 'Click on the first result and tell me the price' });
console.log(response.output);

await app.stopInteraction(scrapeId);

Next steps

Scrape docs

All scrape options including formats, actions, and proxies

Search docs

Search the web and get full page content

Interact docs

Click, fill forms, and extract dynamic content

Node SDK reference

Full SDK reference with crawl, map, batch scrape, and more