Installation
The official Rust SDK is maintained in the Firecrawl monorepo at apps/rust-sdk.
To install the Firecrawl Rust SDK, add the dependency from crates.io:
Or install via Cargo:
Requires Rust 1.70 or later.
Usage
- Get an API key from firecrawl.dev
- Set the API key as an environment variable named
FIRECRAWL_API_KEY, or pass it directly to Client::new(...)
Scrape a page and print its markdown:
The sections below cover crawling, mapping, searching, and the other SDK methods.
Scraping a URL
To scrape a single URL, use the scrape method.
Extract structured JSON using scrape_with_schema:
Or configure JSON extraction via ScrapeOptions directly:
Parsing uploaded files
Use parse to upload a local file (.html, .htm, .pdf, .docx, .doc, .odt, .rtf, .xlsx, .xls) as multipart form data to /v2/parse. The endpoint returns a Document with the requested formats.
ParseOptions intentionally omits scrape-only fields that /v2/parse rejects (such as actions, waitFor, location, mobile, screenshot, branding, and changeTracking).
Build a ParseFile from in-memory bytes or directly from a path:
Or read the file from disk and omit the options:
ParseFile
| Constructor | Description |
|---|
ParseFile::from_bytes(filename, bytes) | Build from a filename and in-memory bytes |
ParseFile::from_path(path) | Read bytes from disk and derive the filename |
.with_content_type(content_type) | Attach a MIME type hint (e.g. text/html, application/pdf) |
ParseOptions
Supported fields (all optional, camelCase on the wire):
formats: Vec<ParseFormat> — any of Markdown, Html, RawHtml, Links, Images, Summary, Json, Attributes
only_main_content: bool
include_tags: Vec<String> / exclude_tags: Vec<String>
headers: HashMap<String, String>
timeout: u32 (ms)
parsers: Vec<ParserConfig> (e.g. PDF parser config)
skip_tls_verification: bool
remove_base64_images: bool
fast_mode: bool
block_ads: bool
proxy: ParseProxyType (Basic or Auto)
json_options: JsonOptions
attribute_selectors: Vec<AttributeSelector>
zero_data_retention: bool
integration: String, origin: String, use_mock: String
Crawling a Website
To crawl a website and wait for completion, use crawl.
Start a Crawl
Start a job without waiting using start_crawl.
Checking Crawl Status
Check crawl progress with get_crawl_status.
Cancelling a Crawl
Cancel a running crawl with cancel_crawl.
Checking Crawl Errors
Retrieve errors from a crawl job with get_crawl_errors.
Mapping a Website
Discover links on a site using map.
For a simpler result with just URLs, use map_urls:
Searching the Web
Search with optional settings using search.
For a convenience method that returns scraped documents directly:
Batch Scraping
Scrape multiple URLs in parallel using batch_scrape.
Agent
Run an AI-powered agent with agent.
With a JSON schema for structured output:
Scrape-Bound Interactive Session
Use a scrape job ID to run follow-up browser code in the same context:
interact(...) runs code or prompts in the scrape-bound browser session.
stop_interaction(...) stops the interactive session when you are done.
Configuration
Client::new(...) and Client::new_selfhosted(...) create the client.
| Option | Description |
|---|
Client::new(api_key) | Create a client for the Firecrawl cloud service (https://api.firecrawl.dev) |
Client::new_selfhosted(api_url, api_key) | Create a client for a self-hosted Firecrawl instance |
Environment Variable
Set the FIRECRAWL_API_KEY environment variable instead of passing the key directly:
Poll Intervals
Synchronous methods (crawl, batch_scrape, agent) poll until completion. You can customize the poll interval via the options struct:
Error Handling
The SDK uses the FirecrawlError enum, which implements Error, Debug, and Display. All methods return Result<T, FirecrawlError>.
Are you an AI agent that needs a Firecrawl API key? See firecrawl.dev/agent-onboarding/SKILL.md for automated onboarding instructions.