Skip to main content

Installation

To install the Firecrawl Python SDK, you can use pip:
Python

Usage

Get an API key from firecrawl.dev, then either set it as the FIRECRAWL_API_KEY environment variable or pass it directly to the Firecrawl class.
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.
Python

Scraping a URL

Scrape a single URL with the scrape method. It returns the page content as structured data, including markdown, metadata, and any other formats you request.
Python
The Python SDK converts all response field names from camelCase to snake_case. For example, metadata fields like ogImage, ogTitle, and sourceURL from the API become og_image, og_title, and source_url in the SDK response.

Parsing uploaded files

Use parse to upload local files (html, pdf, docx, xlsx, etc.) directly to /v2/parse. parse does not support changeTracking or browser-only options like actions, wait_for, location, mobile, screenshot, and branding.
Python

Crawl a Website

To crawl a website, use the crawl method. It takes the starting URL and optional options as arguments. The options allow you to specify additional settings for the crawl job, such as the maximum number of pages to crawl, allowed domains, and the output format. See Pagination for auto/manual pagination and limiting.
Python

Sitemap-Only Crawl

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

Start a Crawl

Prefer non-blocking? Check out the Async Class section below.
Start a job without waiting using start_crawl. It returns a job ID you can use to check status. Use crawl when you want a waiter that blocks until completion. See Pagination for paging behavior and limits.
Python

Checking Crawl Status

Check the status of a crawl job with get_crawl_status. Pass the job ID and receive the current status along with any results collected so far.
Python

Cancelling a Crawl

Cancel a crawl job with the cancel_crawl method. Pass the job ID returned by start_crawl to receive the cancellation status.
Python

Map a Website

Use map to generate a list of URLs from a website. The options let you customize the mapping process, including excluding subdomains or utilizing the sitemap.
Python

Crawling a Website with WebSockets

To crawl a website with WebSockets, start the job with start_crawl and subscribe using the watcher helper. Create a watcher with the job ID and attach handlers (e.g., for page, completed, failed) before calling start().
Python

Pagination

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

PaginationConfig

Use PaginationConfig to control pagination behavior when calling get_crawl_status or get_batch_scrape_status:
Python

Manual Pagination Helpers

When auto_paginate=False, the response includes a next URL if more data is available. Use these helper methods to fetch subsequent pages:
  • get_crawl_status_page(next_url) - Fetch the next page of crawl results using the opaque next URL from a previous response.
  • get_batch_scrape_status_page(next_url) - Fetch the next page of batch scrape results using the opaque next URL from a previous response.
These methods return the same response type as the original status call, including a new next URL if more pages remain.

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
Start a job, then fetch one page at a time with auto_paginate=False. Use get_crawl_status_page to fetch subsequent pages:
Python
Manual crawl with limits (auto-pagination + early stop)
Keep auto-pagination on but stop early with max_pages, max_results, or max_wait_time:
Python

Batch Scrape

Use the waiter method batch_scrape, or start a job and page manually.
Simple batch scrape (auto-pagination, default)
Manual batch scrape with pagination control
Start a job, then fetch one page at a time with auto_paginate=False. Use get_batch_scrape_status_page to fetch subsequent pages:
Python
Manual batch scrape with limits (auto-pagination + early stop)
Keep auto-pagination on but stop early with max_pages, max_results, or max_wait_time:
Python

Error Handling

When a request fails, the SDK raises an exception with a descriptive message explaining what went wrong. Wrap calls in try/except to catch these exceptions and handle failures in your application.

Async Class

For async operations, use the AsyncFirecrawl class. Its methods mirror Firecrawl, but they don’t block the main thread.
Python
Python

Browser

Launch cloud browser sessions and execute code remotely.

Create a Session

Python

Execute Code

Python
Execute JavaScript instead of Python:
Python

Profiles

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

Connect via CDP

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

List & Close Sessions

Python

Scrape-Bound Interactive Session

Use a scrape job ID to keep interacting with the replayed page context from that scrape:
  • interact(job_id, ...) runs code in the scrape-bound browser session.
  • The first interact call auto-initializes the session from the scrape context.
  • Additional interact calls on the same job ID reuse that live browser state.
  • stop_interaction(job_id) stops the interactive session when you are done.
Python
Are you an AI agent that needs a Firecrawl API key? See firecrawl.dev/agent-onboarding/SKILL.md for automated onboarding instructions.