> ## Documentation Index
> Fetch the complete documentation index at: https://firecrawl-claude-eager-dijkstra-8bz2qg.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Rust Agent Quickstart

> Canonical Firecrawl Rust quickstart for external agents using search, scrape, and interact.

# Firecrawl Rust Agent Quickstart

Canonical quickstart for external agents integrating Firecrawl with Rust. Generated from SDK source and OpenAPI spec.

## Install

```bash theme={null}
cargo add firecrawl
```

## Authenticate

```rust theme={null}
use firecrawl::Client;

let client = Client::new("fc-YOUR-API-KEY")?;
```

For self-hosted instances:

```rust theme={null}
let client = Client::new_selfhosted("https://your-instance.example.com", Some("fc-YOUR-API-KEY"))?;
```

Set `FIRECRAWL_API_KEY` environment variable for keyless initialization (handled at the application level — the SDK accepts an empty or `None` key for keyless free tier).

## When To Use What

* **search**: Start with a query, discover relevant URLs, and get their content in one call.
* **scrape**: You already have a URL and want its page content as markdown, HTML, JSON, or other formats.
* **interact**: The page needs clicks, form fills, or post-scrape browser actions on a live session.

## Search

### Why use it

Search the web for a query and get scraped content from the top results. Combines discovery and content extraction in one call.

### Preferred SDK method

`client.search(query, options)`

### Example

```rust theme={null}
use firecrawl::{Client, SearchOptions};

let client = Client::new("fc-YOUR-API-KEY")?;
let response = client.search("firecrawl web scraping", SearchOptions {
    limit: Some(5),
    ..Default::default()
}).await?;

if let Some(web_results) = response.data.web {
    for result in web_results {
        println!("{:?}", result);
    }
}
```

### Parameters

All fields on `SearchOptions` are `Option<T>` and default to `None`.

| Parameter             | Type                          | Description                                                       |
| --------------------- | ----------------------------- | ----------------------------------------------------------------- |
| `query`               | `impl AsRef<str>`             | **Required.** First positional argument. Search query.            |
| `limit`               | `Option<u32>`                 | Max results. Default: 5, Max: 20.                                 |
| `sources`             | `Option<Vec<SearchSource>>`   | Sources: `Web`, `News`, `Images`.                                 |
| `categories`          | `Option<Vec<SearchCategory>>` | Categories: `Github`, `Research`, `Pdf`.                          |
| `include_domains`     | `Option<Vec<String>>`         | Restrict to these domains. Cannot combine with `exclude_domains`. |
| `exclude_domains`     | `Option<Vec<String>>`         | Exclude these domains. Cannot combine with `include_domains`.     |
| `tbs`                 | `Option<String>`              | Time-based filter (e.g. `"qdr:d"` past day).                      |
| `location`            | `Option<String>`              | Geo-targeting location string.                                    |
| `ignore_invalid_urls` | `Option<bool>`                | Exclude invalid URLs.                                             |
| `timeout`             | `Option<u32>`                 | Timeout in ms.                                                    |
| `highlights`          | `Option<bool>`                | Generate query-relevant highlights. Default: `true`.              |
| `scrape_options`      | `Option<ScrapeOptions>`       | Scrape options applied to each result page.                       |
| `integration`         | `Option<String>`              | Integration identifier.                                           |
| `origin`              | `Option<String>`              | Auto-set to SDK version if `None`.                                |

There is also a convenience method `client.search_and_scrape(query, limit)` that returns `Vec<Document>` directly.

## Scrape

### Why use it

Get the content of a single URL as markdown, HTML, JSON, screenshots, or other formats.

### Preferred SDK method

`client.scrape(url, options)`

### Example

```rust theme={null}
use firecrawl::{Client, ScrapeOptions, Format};

let client = Client::new("fc-YOUR-API-KEY")?;
let document = client.scrape("https://example.com", ScrapeOptions {
    formats: Some(vec![Format::Markdown, Format::Links]),
    only_main_content: Some(true),
    ..Default::default()
}).await?;

if let Some(md) = document.markdown {
    println!("{}", md);
}
```

### Parameters

All fields on `ScrapeOptions` are `Option<T>` and default to `None`.

| Parameter                 | Type                              | Description                                                                                                                                                                                                                                                            |
| ------------------------- | --------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `url`                     | `impl AsRef<str>`                 | **Required.** First positional argument. URL to scrape.                                                                                                                                                                                                                |
| `formats`                 | `Option<Vec<Format>>`             | Output formats: `Markdown`, `Html`, `RawHtml`, `Links`, `Images`, `Screenshot`, `Summary`, `ChangeTracking`, `Json`, `Attributes`, `Branding`, `Product`, `Menu`, `Audio`, `Video`, `Question(QuestionFormat)`, `Highlights(HighlightsFormat)`. Default: `[Markdown]`. |
| `headers`                 | `Option<HashMap<String, String>>` | Custom HTTP headers.                                                                                                                                                                                                                                                   |
| `include_tags`            | `Option<Vec<String>>`             | HTML tags to include.                                                                                                                                                                                                                                                  |
| `exclude_tags`            | `Option<Vec<String>>`             | HTML tags to exclude.                                                                                                                                                                                                                                                  |
| `only_main_content`       | `Option<bool>`                    | Strip navbars, footers, boilerplate. Default: `true`.                                                                                                                                                                                                                  |
| `timeout`                 | `Option<u32>`                     | Timeout in ms. Default: `60000`.                                                                                                                                                                                                                                       |
| `wait_for`                | `Option<u32>`                     | Extra delay in ms before fetching content.                                                                                                                                                                                                                             |
| `mobile`                  | `Option<bool>`                    | Emulate a mobile device.                                                                                                                                                                                                                                               |
| `parsers`                 | `Option<Vec<ParserConfig>>`       | File processing controls (e.g. PDF with mode and max\_pages).                                                                                                                                                                                                          |
| `actions`                 | `Option<Vec<Action>>`             | Browser actions before content capture.                                                                                                                                                                                                                                |
| `location`                | `Option<LocationConfig>`          | Geo settings with `country` and `languages`.                                                                                                                                                                                                                           |
| `skip_tls_verification`   | `Option<bool>`                    | Skip TLS certificate verification.                                                                                                                                                                                                                                     |
| `remove_base64_images`    | `Option<bool>`                    | Remove base64 images from markdown. Default: `true`.                                                                                                                                                                                                                   |
| `fast_mode`               | `Option<bool>`                    | Enable fast mode.                                                                                                                                                                                                                                                      |
| `block_ads`               | `Option<bool>`                    | Block ads and cookie popups. Default: `true`.                                                                                                                                                                                                                          |
| `proxy`                   | `Option<ProxyType>`               | Proxy type: `Basic`, `Stealth`, `Enhanced`, `Auto`. Default: `Auto`.                                                                                                                                                                                                   |
| `max_age`                 | `Option<u32>`                     | Cache threshold in seconds.                                                                                                                                                                                                                                            |
| `min_age`                 | `Option<u32>`                     | Cache-only mode minimum age in seconds.                                                                                                                                                                                                                                |
| `store_in_cache`          | `Option<bool>`                    | Store result in cache. Default: `true`.                                                                                                                                                                                                                                |
| `lockdown`                | `Option<bool>`                    | Cache-only, no outbound requests.                                                                                                                                                                                                                                      |
| `redact_pii`              | `Option<bool>`                    | Redact PII.                                                                                                                                                                                                                                                            |
| `audit_metadata`          | `Option<AuditMetadata>`           | SIEM logging with `username` field.                                                                                                                                                                                                                                    |
| `profile`                 | `Option<ProfileConfig>`           | Persistent browser profile with `name` and optional `save_changes`.                                                                                                                                                                                                    |
| `integration`             | `Option<String>`                  | Integration identifier.                                                                                                                                                                                                                                                |
| `json_options`            | `Option<JsonOptions>`             | JSON extraction with `schema`, `system_prompt`, `prompt`.                                                                                                                                                                                                              |
| `screenshot_options`      | `Option<ScreenshotOptions>`       | Screenshot config with `full_page`, `quality`, `viewport`.                                                                                                                                                                                                             |
| `change_tracking_options` | `Option<ChangeTrackingOptions>`   | Change tracking with `modes`, `schema`, `prompt`, `tag`.                                                                                                                                                                                                               |
| `attribute_selectors`     | `Option<Vec<AttributeSelector>>`  | Attribute extraction with `selector` and `attribute`.                                                                                                                                                                                                                  |
| `origin`                  | `Option<String>`                  | Auto-set to SDK version if `None`.                                                                                                                                                                                                                                     |

There is also a convenience method `client.scrape_with_schema(url, schema, prompt)` for JSON extraction.

## Interact

### Why use it

Control a live browser session tied to a scrape job. Click buttons, fill forms, navigate, and extract dynamic content using code or natural-language prompts.

### Preferred SDK method

`client.interact(job_id, options)`

### Example

```rust theme={null}
use firecrawl::{Client, ScrapeOptions, ScrapeExecuteOptions, Format};

let client = Client::new("fc-YOUR-API-KEY")?;
let document = client.scrape("https://www.amazon.com", ScrapeOptions {
    formats: Some(vec![Format::Markdown]),
    ..Default::default()
}).await?;

let scrape_id = document.metadata
    .and_then(|m| m.get("scrapeId").and_then(|v| v.as_str().map(String::from)))
    .expect("scrapeId not found");

let response = client.interact(&scrape_id, ScrapeExecuteOptions {
    prompt: Some("Search for iPhone 16 Pro Max".into()),
    ..Default::default()
}).await?;

let response = client.interact(&scrape_id, ScrapeExecuteOptions {
    prompt: Some("Click on the first result and tell me the price".into()),
    ..Default::default()
}).await?;
println!("{:?}", response.output);

client.stop_interaction(&scrape_id).await?;
```

### Parameters

All fields on `ScrapeExecuteOptions` are `Option<T>` and default to `None`.

| Parameter  | Type                            | Description                                                                    |
| ---------- | ------------------------------- | ------------------------------------------------------------------------------ |
| `job_id`   | `impl AsRef<str>`               | **Required.** First positional argument. Scrape job ID from document metadata. |
| `code`     | `Option<String>`                | Code to execute in the browser sandbox. One of `code` or `prompt` required.    |
| `prompt`   | `Option<String>`                | Natural-language instruction. One of `code` or `prompt` required.              |
| `language` | `Option<ScrapeExecuteLanguage>` | Runtime: `Python`, `Node`, `Bash`. Default: `Node`.                            |
| `timeout`  | `Option<u32>`                   | Execution timeout in seconds. Min: 1, Max: 300.                                |
| `origin`   | `Option<String>`                | Auto-set to SDK version if `None`.                                             |

Stop the session when done:

```rust theme={null}
client.stop_interaction(&scrape_id).await?;
```

## Notes

* All option structs use **snake\_case** fields and derive `Default` — use struct literal syntax with `..Default::default()`.
* The `options` parameter on `scrape` and `search` accepts `impl Into<Option<T>>`, so you can pass `None` directly to skip options.
* The `origin` field is automatically set to the SDK version string if not provided.
* Deprecated aliases (do not use in new code):
  * `scrape_execute()` → use `interact()`
  * `stop_interactive_browser()` / `delete_scrape_browser()` → use `stop_interaction()`

## Source Of Truth

* `firecrawl/apps/rust-sdk/src/client.rs`
* `firecrawl/apps/rust-sdk/src/scrape.rs`
* `firecrawl/apps/rust-sdk/src/search.rs`
* `firecrawl/apps/rust-sdk/Cargo.toml`
* `firecrawl-docs/api-reference/v2-openapi.json`
