Installation#
To install the Firecrawl Python SDK, you can use pip:
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.
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.
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.
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.
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 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.
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.
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.
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.
Run an Agent#
Hand a research or extraction task to an agent with the agent method. It takes a prompt, an optional schema to shape the output, and max_credits to cap what the run can spend.
Agent runs are asynchronous. Use start_agent to get a job ID back immediately, then poll it with get_agent_status.
Every run also records an execution trace and output snapshots, which you can read with get_agent_trace and get_agent_snapshot. See Agent for the event schema and the full parameter list.
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().
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:
| Option | Type | Default | Description |
|---|---|---|---|
auto_paginate | bool | True | When True, automatically fetches all pages and aggregates results. Set to False to fetch one page at a time. |
max_pages | int | None | Stop after fetching this many pages (only applies when auto_paginate=True). |
max_results | int | None | Stop after collecting this many documents (only applies when auto_paginate=True). |
max_wait_time | int | None | Stop after this many seconds (only applies when auto_paginate=True). |
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 opaquenextURL from a previous response.get_batch_scrape_status_page(next_url)- Fetch the next page of batch scrape results using the opaquenextURL 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)
- See the default flow in Crawl a Website.
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:
Manual crawl with limits (auto-pagination + early stop)
Keep auto-pagination on but stop early with max_pages, max_results, or max_wait_time:
Batch Scrape#
Use the waiter method batch_scrape, 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
Start a job, then fetch one page at a time with auto_paginate=False. Use get_batch_scrape_status_page to fetch subsequent pages:
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:
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.
Browser#
Launch cloud browser sessions and execute code remotely.
Create a Session#
Execute Code#
Execute JavaScript instead of Python:
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(job_id, ...)runs code in the scrape-bound browser session.- The first
interactcall auto-initializes the session from the scrape context. - Additional
interactcalls on the same job ID reuse that live browser state. stop_interaction(job_id)stops the interactive session when you are done.
Are you an AI agent that needs a Firecrawl API key? See firecrawl.dev/agent-onboarding/SKILL.md for automated onboarding instructions.

