> ## Documentation Index
> Fetch the complete documentation index at: https://firecrawl-claude-eager-dijkstra-8bb4v8.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.

Canonical Firecrawl Rust quickstart for external agents. Aligned with `firecrawl` crate **v2.12.1** (`firecrawl/apps/rust-sdk`) and the v2 OpenAPI spec.

## Install

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

## Authenticate

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

let client = Client::new("fc-your-api-key")?;
// Self-hosted:
// let client = Client::new_selfhosted("http://localhost:3002", Some("fc-your-api-key"))?;
```

## When To Use What

* `search`: use when you start with a query and need discovery.
* `scrape`: use when you already have a URL and want page content.
* `interact`: use when the page needs clicks, forms, or post-scrape browser actions.

## Search

### Why use it

Use search to discover relevant pages from a query, then pick URLs to scrape or interact with. You can constrain results to a site with `site:`, for example `site:docs.firecrawl.dev crawl webhooks`.

### Preferred SDK method

`client.search(query, options)` → `Result<SearchResponse, FirecrawlError>`

### Example

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

let results = client
    .search("site:docs.firecrawl.dev webhook retries", None)
    .await?;
```

### Parameters

| Parameter                     | Type                  | Description                                                            |
| ----------------------------- | --------------------- | ---------------------------------------------------------------------- |
| `query`                       | `impl AsRef<str>`     | The search query. Use `site:example.com` to limit results to a domain. |
| `options.sources`             | `Vec<SearchSource>`   | Sources to search. Values: `Web`, `News`, `Images`.                    |
| `options.categories`          | `Vec<SearchCategory>` | Filter by category. Values: `Github`, `Research`, `Pdf`.               |
| `options.include_domains`     | `Vec<String>`         | Restrict results to these domains.                                     |
| `options.exclude_domains`     | `Vec<String>`         | Exclude these domains.                                                 |
| `options.limit`               | `u32`                 | Cap results.                                                           |
| `options.tbs`                 | `String`              | Time-based filter (e.g. `qdr:d`, `qdr:w`).                             |
| `options.location`            | `String`              | Location string for localized results.                                 |
| `options.ignore_invalid_urls` | `bool`                | Drop URLs that cannot be scraped.                                      |
| `options.timeout`             | `u32`                 | Request timeout in milliseconds.                                       |
| `options.highlights`          | `bool`                | Generate query-relevant highlights. Defaults to true server-side.      |
| `options.scrape_options`      | `ScrapeOptions`       | Scrape each search result (see Scrape parameters).                     |

**Return value:** `SearchResponse` containing `success: bool`, `data: SearchData`, `warning: Option<String>`. `SearchData` has `web: Option<Vec<SearchResultOrDocument>>`, `news: Option<Vec<SearchResultNews>>`, `images: Option<Vec<SearchResultImage>>`.

## Scrape

### Why use it

Use scrape when you already have a URL and want structured content in one or more formats.

### Preferred SDK method

`client.scrape(url, options)` → `Result<Document, FirecrawlError>`

### Example

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

let doc = client
    .scrape("https://docs.firecrawl.dev", ScrapeOptions {
        formats: Some(vec![Format::Markdown]),
        ..Default::default()
    })
    .await?;
```

### Parameters

| Parameter                         | Type                      | Description                                                                                                                                                                                                                                                   |
| --------------------------------- | ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `url`                             | `impl AsRef<str>`         | The URL to scrape.                                                                                                                                                                                                                                            |
| `options.formats`                 | `Vec<Format>`             | Output formats. Values: `Markdown`, `Html`, `RawHtml`, `Links`, `Images`, `Screenshot`, `Summary`, `ChangeTracking`, `Json`, `Attributes`, `Branding`, `Product`, `Menu`, `Audio`, `Video`. Also: `Question(QuestionFormat)`, `Highlights(HighlightsFormat)`. |
| `options.headers`                 | `HashMap<String, String>` | Custom request headers.                                                                                                                                                                                                                                       |
| `options.include_tags`            | `Vec<String>`             | Include only specific HTML tags.                                                                                                                                                                                                                              |
| `options.exclude_tags`            | `Vec<String>`             | Exclude specific HTML tags.                                                                                                                                                                                                                                   |
| `options.only_main_content`       | `bool`                    | Strip nav, footer, and other boilerplate.                                                                                                                                                                                                                     |
| `options.timeout`                 | `u32`                     | Timeout in milliseconds.                                                                                                                                                                                                                                      |
| `options.wait_for`                | `u32`                     | Wait for the page to render (milliseconds).                                                                                                                                                                                                                   |
| `options.mobile`                  | `bool`                    | Use a mobile viewport.                                                                                                                                                                                                                                        |
| `options.parsers`                 | `Vec<ParserConfig>`       | File parsing controls. Values: `ParserConfig::Simple("pdf")`, `ParserConfig::Pdf { parser_type, mode?, max_pages? }`.                                                                                                                                         |
| `options.actions`                 | `Vec<Action>`             | Pre-scrape browser actions. Types: `Wait`, `Screenshot`, `Click`, `Write`, `Press`, `Scroll`, `Scrape`, `ExecuteJavascript`, `Pdf`.                                                                                                                           |
| `options.location`                | `LocationConfig`          | Geo or language-aware scraping. Fields: `country`, `languages`.                                                                                                                                                                                               |
| `options.skip_tls_verification`   | `bool`                    | Skip TLS verification.                                                                                                                                                                                                                                        |
| `options.remove_base64_images`    | `bool`                    | Drop base64 images from markdown output.                                                                                                                                                                                                                      |
| `options.fast_mode`               | `bool`                    | Faster scrapes with reduced fidelity.                                                                                                                                                                                                                         |
| `options.block_ads`               | `bool`                    | Block ads and cookie popups.                                                                                                                                                                                                                                  |
| `options.proxy`                   | `ProxyType`               | Proxy mode. Values: `Basic`, `Stealth`, `Enhanced`, `Auto`.                                                                                                                                                                                                   |
| `options.max_age`                 | `u32`                     | Use cached data up to this age (seconds).                                                                                                                                                                                                                     |
| `options.min_age`                 | `u32`                     | Use cached data only if at least this old (seconds).                                                                                                                                                                                                          |
| `options.store_in_cache`          | `bool`                    | Cache the result.                                                                                                                                                                                                                                             |
| `options.lockdown`                | `bool`                    | Only serve cached results, never make an outbound request.                                                                                                                                                                                                    |
| `options.redact_pii`              | `bool`                    | Redact personally identifiable information.                                                                                                                                                                                                                   |
| `options.profile`                 | `ProfileConfig`           | Persistent browser profile. Fields: `name`, `save_changes`.                                                                                                                                                                                                   |
| `options.audit_metadata`          | `AuditMetadata`           | User attribution for SIEM logging. Field: `username`.                                                                                                                                                                                                         |
| `options.json_options`            | `JsonOptions`             | JSON extraction config. Fields: `schema`, `system_prompt`, `prompt`.                                                                                                                                                                                          |
| `options.screenshot_options`      | `ScreenshotOptions`       | Screenshot config. Fields: `full_page`, `quality`, `viewport`.                                                                                                                                                                                                |
| `options.change_tracking_options` | `ChangeTrackingOptions`   | Change tracking config. Fields: `modes` (`GitDiff`, `Json`), `schema`, `prompt`, `tag`.                                                                                                                                                                       |
| `options.attribute_selectors`     | `Vec<AttributeSelector>`  | Attribute extraction. Fields: `selector`, `attribute`.                                                                                                                                                                                                        |

## Interact

### Why use it

Use interact when a page requires browser actions or code execution after a scrape starts.

### Preferred SDK method

`client.interact(job_id, options)` → `Result<ScrapeExecuteResponse, FirecrawlError>`

### Example

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

let result = client
    .interact(
        "<scrapeJobId>",
        ScrapeExecuteOptions {
            prompt: Some("Click the pricing tab and summarize the plans.".to_string()),
            ..Default::default()
        },
    )
    .await?;
```

### Parameters

| Parameter          | Type                    | Description                                                                                                            |
| ------------------ | ----------------------- | ---------------------------------------------------------------------------------------------------------------------- |
| `job_id`           | `impl AsRef<str>`       | Scrape job ID.                                                                                                         |
| `options.code`     | `Option<String>`        | Code to run in the browser session. Provide `code` or `prompt` (at least one required, else `FirecrawlError::Misuse`). |
| `options.prompt`   | `Option<String>`        | Natural-language instruction for the browser agent. Provide `code` or `prompt` (at least one required).                |
| `options.language` | `ScrapeExecuteLanguage` | Runtime. Values: `Python`, `Node`, `Bash`. Default: `Node`.                                                            |
| `options.timeout`  | `u32`                   | Execution timeout in seconds.                                                                                          |

### Stop session

`client.stop_interaction(job_id)` → `Result<ScrapeBrowserDeleteResponse, FirecrawlError>`

Ends the scrape-bound browser session. Response includes `success`, `session_duration_ms`, `credits_billed`.

## Notes

* Deprecated aliases: `scrape_execute` → `interact`; `stop_interactive_browser` and `delete_scrape_browser` → `stop_interaction`.
* `ScrapeOptions` uses dedicated `json_options`, `screenshot_options`, `change_tracking_options` for advanced format configuration (unlike JS/Python which use inline format objects).
* `search_and_scrape(query, limit)` is a convenience helper that searches then returns `Vec<Document>`.
* All types are exported at the crate root: `use firecrawl::Client`.
* All option structs derive `Default`; use `..Default::default()` to fill unset fields.

## Source Of Truth

* `firecrawl/apps/rust-sdk/Cargo.toml`
* `firecrawl/apps/rust-sdk/src/lib.rs`
* `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/src/types.rs`
* `firecrawl-docs/api-reference/v2-openapi.json`
