Firecrawl API Examples Every Developer Should Know

Fourteen Firecrawl API examples with code: scrape, JSON extraction, screenshots, actions, map, crawl, search, batch, change tracking, monitors and webhooks.

Summarize this post with AI

A 28-minute read, or the key points in about 30 seconds, in the assistant you already use.

Opens in a new tab with the prompt filled in. Nothing passes through this site.

Most Firecrawl API examples stop at a single scrape. That's the cheapest call Firecrawl has, at 1 credit a page. The costly mistakes happen elsewhere: a crawl with no limit defaults to 10,000 pages, and JSON mode costs five times a plain scrape.

Below are 14 examples, from one page to whole sites to scheduled monitors. Each one has a short snippet, what comes back, what it costs and when to reach for it.

One of them fails silently if you copy Firecrawl's docs with zod 4 installed. The fix is one line.

Every endpoint, parameter and credit cost below comes from Firecrawl's docs and pricing page, as of 7 October 2026. The SDK snippets were run against a local mock of the API (JavaScript SDK 4.44.0, Python SDK 4.49.1), and the JavaScript ones typecheck. None were run against the live API.

Some links here are affiliate links; they don't change your price.

Editorial cover showing a grid of eight icon cards: a page, a stack of pages, a magnifier, a sitemap tree, a camera, a clicking cursor, a highlighted amber bell and an arrow into a server
Fourteen Firecrawl API examples, from one page to whole sites to scheduled monitors.

Which Firecrawl endpoint should you use?

Firecrawl has one API, a handful of jobs and one currency: credits. Pick the job first, and the right method follows. Here's the cheat sheet, with credit costs from Firecrawl's billing docs on 7 October 2026.

You want toUseCredits
Get one page as markdown or HTMLscrape1 per page
Get typed fields from one pagescrape with JSON format5 per page
Capture what the page looks likescrape with screenshot format1 per page
Click or type before scrapingscrape with actions, or interact1 per page, plus 2 to 7 per browser minute for interact
List every URL on a sitemap1 per call
Scrape a whole site or sectioncrawl1 per page
Find pages you don't have URLs forsearch2 per 10 results, plus 1 per result scraped
Scrape a list of known URLsbatch scrape1 per page
Know when a page changesscrape with changeTracking, or a monitor1 per page per check
Get results pushed to youwebhook on crawl, batch or monitor0 to receive
Diagram of four cards grouping Firecrawl API jobs: One page with Scrape, JSON and Screenshot, Many pages with Crawl and Batch, Find pages with Map and Search, and Watch pages with Changes and Monitor
Start from the job: one page, many pages, finding pages, or watching pages for changes.

Not sure Firecrawl is the right tool at all? I compared it with Apify in Firecrawl vs Apify, and the plan prices are in my Firecrawl pricing breakdown.

How do you set up the SDK?

Every JavaScript example below uses this client. Install the package, then put your key in the FIRECRAWL_API_KEY environment variable.

bash
npm install firecrawl
ts
import { Firecrawl } from "firecrawl";

const firecrawl = new Firecrawl({ apiKey: process.env.FIRECRAWL_API_KEY });

The Python examples use the official Python SDK:

bash
pip install firecrawl-py
python
from firecrawl import Firecrawl

firecrawl = Firecrawl(api_key="fc-YOUR-API-KEY")

The older package name @mendable/firecrawl-js still works. On 7 October 2026 it was the same version as firecrawl (4.44.0) with identical code.

If APIs are new to you, my explainer on how an API works covers requests and keys first.

Firecrawl API examples for single pages

1. Scrape a page to clean markdown

This is the one you'll use most. You send a URL and get back the page as markdown, with the navigation and footer stripped out.

ts
const doc = await firecrawl.scrape("https://example.com", {
  formats: ["markdown"],
  onlyMainContent: true,
});
console.log(doc.metadata?.title, doc.metadata?.statusCode);
console.log(doc.markdown?.slice(0, 300));

The same call over plain HTTP:

bash
curl -X POST https://api.firecrawl.dev/v2/scrape \
  -H "Authorization: Bearer $FIRECRAWL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://example.com", "formats": ["markdown"]}'

What you get back (shape from Firecrawl's docs):

json
{
  "success": true,
  "data": {
    "markdown": "# Example Domain ...",
    "metadata": {
      "title": "Example Domain",
      "sourceURL": "https://example.com",
      "statusCode": 200,
      "scrapeId": "..."
    }
  }
}

The SDK hands you the inner data object, so you read doc.markdown directly.

Use it when you're feeding a page to an LLM, building a search index or archiving content. Check metadata.statusCode every time. Firecrawl charges 1 credit even when the target page answers 403 or 404.

If the LLM has to answer questions across many pages, this markdown is the ingest step of a RAG pipeline, and my guide to what RAG is and how retrieval-augmented generation works covers the chunking, embedding and retrieval that come next.

2. Extract JSON with a plain-English prompt

JSON mode runs an LLM over the page and returns structured data. The quickest version needs no schema, just a prompt.

ts
const doc = await firecrawl.scrape("https://example.com/pricing", {
  formats: [{ type: "json", prompt: "List every plan name and its monthly price." }],
});
console.log(doc.json);

What you get back: a json field on the document, shaped however the model decided. Use it for one-off exploration. For anything you store, use a schema, because the shape can change from page to page.

It costs 5 credits per page: 1 for the scrape and 4 for the extraction.

3. Extract typed JSON with a zod schema

Give Firecrawl a schema and it fills it in. Here's the version that works with zod 4:

ts
import { z } from "zod";

const Plans = z.object({
  plans: z.array(z.object({ name: z.string(), monthlyPrice: z.number().nullable() })),
});

const doc = await firecrawl.scrape("https://example.com/pricing", {
  formats: [{ type: "json", schema: z.toJSONSchema(Plans, { target: "draft-7" }) }],
});
const parsed = Plans.safeParse(doc.json);
if (parsed.success) console.log(parsed.data.plans);

Why the z.toJSONSchema call? Firecrawl's docs show passing the zod schema in directly, and the SDK converts it for you. But that converter is built for zod 3. Capturing what SDK 4.44.0 sends to a local mock when given a zod 4 schema shows an empty schema with no properties, and no error.

Converting it yourself sends the full schema. The safeParse call then catches any field the model got wrong. For schema design, retries and the same pattern with OpenAI, Claude or Gemini, see my guide to LLM structured data extraction.

Use it when the data goes into a database or a typed UI. The full setup, with error handling, is Step 4 of my Firecrawl API tutorial with Next.js.

4. Take a full-page screenshot

Ask for the screenshot format and you get an image URL back.

ts
const doc = await firecrawl.scrape("https://example.com/pricing", {
  formats: [{ type: "screenshot", fullPage: true }],
});
console.log(doc.screenshot);

What you get back: data.screenshot holds a URL to the image. The format also takes quality and viewport options.

Here's the catch: Firecrawl's docs say screenshot URLs expire after 24 hours. Download the file straight away if you need to keep it.

Use it for visual archives, QA checks or pricing-page captures. Billing docs list no extra charge for screenshots, so it's the base 1 credit.

5. Click and wait before scraping with actions

Some content only appears after a click. Actions run steps in the browser before the scrape happens.

ts
const doc = await firecrawl.scrape("https://example.com/pricing", {
  formats: ["markdown"],
  actions: [
    { type: "wait", milliseconds: 1000 },
    { type: "click", selector: "#annual-toggle" },
    { type: "wait", milliseconds: 1000 },
    { type: "screenshot", fullPage: true },
  ],
});
console.log(doc.markdown?.slice(0, 200), doc.actions);

What you get back: the markdown after the actions have run, plus an actions object. Screenshots taken by a screenshot action land in actions.screenshots.

The available actions include wait, click, write, press and screenshot. Firecrawl's docs say to put a wait before and after other actions so the page has time to load. Change #annual-toggle to a selector that exists on your page.

Use it for toggles, tabs, "load more" buttons and cookie banners. One heads-up: Firecrawl's docs now recommend Interact over actions for anything more involved.

6. Drive the page in plain English with Interact

Interact keeps a browser session open after a scrape, so you can give it instructions in plain English or as Playwright code.

ts
const doc = await firecrawl.scrape("https://example.com/pricing", { formats: ["markdown"] });
const scrapeId = doc.metadata?.scrapeId;
if (scrapeId) {
  const res = await firecrawl.interact(scrapeId, { prompt: "Switch to annual billing and tell me the cheapest paid plan" });
  console.log(res.output);
  await firecrawl.stopInteraction(scrapeId);
}

What you get back: an output string with the answer, plus live-view and CDP URLs for the browser session.

Firecrawl's docs skip the scrapeId check. Leave it out and TypeScript strict mode won't compile, because the SDK types scrapeId as optional.

The price is different here. Interact bills per browser minute with a one-minute minimum: 7 credits a minute with prompts, 2 with code only. Always call stopInteraction when you're done.

Firecrawl API examples for whole sites

7. Map every URL on a site

Map returns a list of a site's URLs without scraping them. It's the cheapest way to see what's there.

ts
const res = await firecrawl.map("https://docs.firecrawl.dev", { search: "webhooks", limit: 20 });
for (const link of res.links) console.log(link.url, link.title);
python
res = firecrawl.map("https://docs.firecrawl.dev", search="webhooks", limit=20)
for link in res.links:
    print(link.url, link.title)

What you get back:

json
{
  "success": true,
  "links": [
    { "url": "https://docs.firecrawl.dev/features/scrape", "title": "Scrape | Firecrawl", "description": "Turn any url into clean data" }
  ]
}

Map costs 1 credit per call, whatever the limit. The search option sorts the links by relevance to your term.

Use it before a crawl to choose paths, or to pick the exact URLs for a batch scrape. Firecrawl's docs note that map relies on sitemaps and its own index, so it can miss pages.

8. Crawl a section of a site and wait for it

Crawl follows links from a starting URL and scrapes every page it reaches. The waiter version blocks until the job finishes.

python
job = firecrawl.crawl(
    "https://docs.firecrawl.dev",
    limit=25,
    exclude_paths=["^/api-reference/.*"],
    scrape_options={"formats": ["markdown"], "only_main_content": True},
    poll_interval=2,
    timeout=120,
)
print(job.status, job.completed, job.total)
for page in job.data:
    print(page.metadata.source_url)

What you get back: a job with a status of scraping, completed, failed or cancelled, the total and completed counts, creditsUsed, and data holding one document per page.

Always set a limit. The default is 10,000 pages, and Firecrawl's crawl docs say it answers 402 before starting if your credits can't cover the limit.

Two scope rules catch people out. A crawl only follows child paths of your start URL unless you set crawlEntireDomain. And includePaths is checked against the start URL too, so a start URL outside your include pattern can return zero pages. That's why this example uses an exclude pattern.

9. Start a crawl in the background and check on it

For anything big, start the crawl and come back later. This is the pattern to use inside a serverless function.

ts
const { id } = await firecrawl.startCrawl("https://docs.firecrawl.dev", { limit: 100 });
const status = await firecrawl.getCrawlStatus(id);
console.log(status.status, `${status.completed}/${status.total}`);

What you get back: startCrawl returns the job ID straight away. getCrawlStatus returns the same shape as the waiter in example 8. Checking status doesn't cost credits.

Results stay available for 24 hours. Large responses are split into pages linked by a next URL, and the SDK follows them for you unless you turn autoPaginate off.

Diagram comparing a Wait lane, where a request stays processing behind an hourglass until done, with a Background lane, where the request is accepted, returns a Job ID and later rings a bell when done
The waiter blocks until the crawl finishes. The background version returns a job ID at once.

10. Search the web and scrape the results

Search runs a web query and can scrape each result in the same call.

ts
const results = await firecrawl.search("firecrawl next.js tutorial", {
  limit: 5,
  sources: ["web", "news"],
  scrapeOptions: { formats: ["markdown"] },
});
for (const item of results.web ?? []) {
  if ("url" in item) console.log(item.url, item.title);
  else console.log(item.metadata?.sourceURL, item.markdown?.length);
}

What you get back: results grouped by source in web, news and images. Each one is either a plain result (url, title, description) or a full document if you asked for scraping. That's why the loop checks which kind it has.

The cost has two parts: 2 credits per 10 results, rounded up, plus 1 credit for every result it scrapes. Five scraped results cost 2 plus 5, so 7 credits.

Use it for research agents and for finding pages when you don't know the URLs. You can also narrow results with includeDomains or categories such as pdf or developer.

11. Batch scrape a list of URLs

When you already have the URLs, from map or your own list, batch scrape runs them as one job.

ts
const job = await firecrawl.batchScrape(
  ["https://example.com/a", "https://example.com/b", "https://example.com/c"],
  { options: { formats: ["markdown"] }, pollInterval: 2, timeout: 120 }
);
console.log(job.status, job.completed, job.total);
python
job = firecrawl.batch_scrape(
    ["https://example.com/a", "https://example.com/b", "https://example.com/c"],
    formats=["markdown"],
    poll_interval=2,
    wait_timeout=120,
)
print(job.status, job.completed, job.total)

What you get back: the same job shape as a crawl, with one document per URL. There's also startBatchScrape if you'd rather poll, or a webhook.

Watch the option names. In JavaScript the formats go inside an options object, while Python takes them as direct arguments. The Python waiter's timeout is called wait_timeout.

It's the same 1 credit per page as a crawl. You just control the list.

Firecrawl API examples for watching pages

Diagram of Change tracking, an older page behind a newer page with a highlighted line and a minus-and-plus diff symbol, beside Monitor, a calendar and clock above three checked pages leading to a bell alert
Change tracking compares two scrapes when you run them. A monitor runs them on a schedule and tells you.

12. Track what changed on a page

Add the changeTracking format and Firecrawl compares the page with the last time you scraped it.

ts
type ChangeInfo = { changeStatus: "new" | "same" | "changed" | "removed"; diff?: { text?: string } };

const doc = await firecrawl.scrape("https://example.com/pricing", {
  formats: ["markdown", { type: "changeTracking", modes: ["git-diff"] }],
});
const change = doc.changeTracking as ChangeInfo | undefined;
if (change?.changeStatus === "changed") console.log(change.diff?.text);

What you get back: a changeTracking object with changeStatus set to new, same, changed or removed, plus previousScrapeAt and visibility. In git-diff mode, a changed page also includes the diff text.

The SDK types changeTracking as a loose object, which is why there's a small type in the snippet. The docs' JavaScript version reads the fields directly and won't compile under strict TypeScript.

Cost: basic change tracking and git-diff add nothing to the 1 credit scrape. JSON mode, which compares fields from your schema, costs 5 credits per page. The markdown format is required, because the comparison runs on markdown.

13. Schedule a monitor instead of a cron job

A monitor runs the checks for you on a schedule and tells you when something changes.

ts
const monitor = await firecrawl.createMonitor({
  name: "Competitor pricing",
  schedule: { text: "daily at 9am", timezone: "UTC" },
  goal: "Tell me when a plan, price or headline feature changes",
  targets: [{ type: "scrape", urls: ["https://example.com/pricing"] }],
  webhook: { url: "https://your-app.com/api/firecrawl-webhook" },
});
console.log(monitor.id, monitor.estimatedCreditsPerMonth);

What you get back: the monitor with its ID, the normalised cron schedule, the next run time and an estimatedCreditsPerMonth figure. Check that figure before you walk away.

Schedules accept phrases like hourly, every 30 minutes or daily at 9am. The minimum interval is 5 minutes, and one monitor takes 1 to 50 targets.

Each check costs the normal scrape credits. When the AI judge is switched on, add 1 credit for each changed page it reviews. Changes arrive by email, webhook, or both.

Monitors fit pricing pages, docs and competitor changelogs.

14. Get crawl results pushed to a webhook

Instead of polling, give a crawl a webhook and Firecrawl posts each page to your server as it finishes.

ts
const { id } = await firecrawl.startCrawl("https://docs.firecrawl.dev", {
  limit: 50,
  webhook: {
    url: "https://your-app.com/api/firecrawl-webhook",
    events: ["started", "page", "completed", "failed"],
    metadata: { project: "docs-index" },
  },
});
console.log("crawl started", id);

What your endpoint receives (shape from Firecrawl's docs):

json
{
  "success": true,
  "type": "crawl.page",
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "data": [{ "markdown": "# Page content...", "metadata": { "sourceURL": "https://example.com/page", "statusCode": 200 } }],
  "metadata": { "project": "docs-index" }
}

You subscribe with short names (started, page, completed, failed), but the payloads arrive typed as crawl.started, crawl.page and so on. Batch scrapes use batch_scrape.page, and monitors send monitor.page and monitor.check.completed.

Three rules from the webhook docs:

  • Verify the X-Firecrawl-Signature header, an HMAC-SHA256 of the raw body.
  • Answer with a 2xx within 10 seconds.
  • Expect repeats, because failed deliveries are retried after 1, 5 and 15 minutes.

The full Next.js handler is in Step 8 of the tutorial. If webhooks are new to you, start with my webhook explainer.

Which mistakes cost the most credits?

Most wasted credits come from four habits:

  • Crawling without a limit. The 10,000-page default either fails with a 402 or eats your plan.
  • Retrying blocked pages. A 403 still costs 1 credit, so stop after the first one and check metadata.statusCode.
  • Expecting Firecrawl's cache to save money. Cached results still cost 1 credit, so cache in your own app.
  • Leaving JSON mode on for every page of a crawl. It turns 1 credit a page into 5.

For scale: the Free plan's 1,000 monthly credits cover 1,000 plain scrapes or 200 JSON extractions. Hobby is $19 a month for 5,000 credits, or $16 a month billed yearly (as of 7 October 2026).

Rate limits matter too. On the Free plan you get 10 scrape, map or search requests a minute and 2 crawl requests a minute. A 429 means slow down. The JavaScript SDK doesn't retry it for you.

Frequently asked questions

What is the difference between Firecrawl scrape, crawl and map?▾
Scrape fetches one URL. Map lists a site's URLs without fetching their content, for 1 credit per call. Crawl follows links and scrapes every page it reaches, at 1 credit per page.
Is Firecrawl's extract endpoint still the way to get structured data?▾
Not for new code. Firecrawl's extractor comparison says to use agent instead, and the JavaScript SDK marks its extract methods as deprecated. Use JSON mode on scrape for a known page, or the agent endpoint when Firecrawl has to find the pages itself.
Can I use the Firecrawl API without an API key?▾
For some calls. Firecrawl's docs say scrape, search and interact work without a key at a low per-IP rate limit. Crawl, map, batch scrape and monitors need a key, and the Free plan key comes with 1,000 credits a month.
Does batch scrape share the scrape or the crawl rate limit?▾
Firecrawl's own pages disagree. The rate limits page says batch scrape shares the crawl limit, while the billing page says it shares the scrape limit. Plan for the stricter crawl limit until they align.
Do Firecrawl screenshots last forever?▾
No. Firecrawl's docs say screenshot URLs expire after 24 hours. Download the image as soon as the scrape returns if you want to keep it.

If you only try three of these, make it scrape, map and a background crawl with a webhook. Those cover most real projects. For a full app with the key kept server-side, caching and a Vercel deploy, follow the Next.js tutorial.

Share