> ## Documentation Index
> Fetch the complete documentation index at: https://firecrawl-claude-eager-dijkstra-iecucq.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. Generated from SDK source (`firecrawl` crate) and the v2 OpenAPI spec. Method names and parameters match the SDK public API.

## Install

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

Crate: `firecrawl` on crates.io.

## 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"))?;
```

`Client::new(api_key)` connects to `https://api.firecrawl.dev`. `Client::new_selfhosted(api_url, api_key)` connects to a self-hosted instance. An empty key falls back to the keyless free tier.

## 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. Requires a `scrapeId` from a prior scrape.

## Search

### Why use it

Discover relevant pages from a query, then pick URLs to scrape or interact with. Constrain results to a site with `site:` in the query.

### 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?;

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

Results are in `results.data.web`, `results.data.news`, `results.data.images`.

### Parameters

| Parameter                     | Type                  | Description                                                |
| ----------------------------- | --------------------- | ---------------------------------------------------------- |
| `query`                       | `impl AsRef<str>`     | Search query. Use `site:example.com` to scope to a domain. |
| `options.sources`             | `Vec<SearchSource>`   | Sources: `Web`, `News`, `Images`.                          |
| `options.categories`          | `Vec<SearchCategory>` | Filter: `Github`, `Research`, `Pdf`.                       |
| `options.include_domains`     | `Vec<String>`         | Restrict results to these domains.                         |
| `options.exclude_domains`     | `Vec<String>`         | Exclude results from these domains.                        |
| `options.limit`               | `u32`                 | Max results. Default: `5`, max: `20`.                      |
| `options.tbs`                 | `String`              | Time-based filter (e.g. `"qdr:d"`, `"qdr:w"`).             |
| `options.location`            | `String`              | Localized search results.                                  |
| `options.ignore_invalid_urls` | `bool`                | Drop invalid URLs.                                         |
| `options.timeout`             | `u32`                 | Request timeout in milliseconds.                           |
| `options.highlights`          | `bool`                | Generate query-relevant highlights. Default: `true`.       |
| `options.scrape_options`      | `ScrapeOptions`       | Scrape each search result (see Scrape parameters).         |
| `options.integration`         | `String`              | Integration identifier.                                    |

## Scrape

### Why use it

Get structured content from a URL 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?;

println!("{:?}", doc.markdown);
```

### Parameters

| Parameter                         | Type                      | Description                                                                                                                                                                                                                                          |
| --------------------------------- | ------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `url`                             | `impl AsRef<str>`         | URL to scrape.                                                                                                                                                                                                                                       |
| `options.formats`                 | `Vec<Format>`             | Output formats: `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 HTTP headers.                                                                                                                                                                                                                                 |
| `options.include_tags`            | `Vec<String>`             | HTML tags to include.                                                                                                                                                                                                                                |
| `options.exclude_tags`            | `Vec<String>`             | HTML tags to exclude.                                                                                                                                                                                                                                |
| `options.only_main_content`       | `bool`                    | Strip nav, footer, and boilerplate.                                                                                                                                                                                                                  |
| `options.timeout`                 | `u32`                     | Timeout in milliseconds.                                                                                                                                                                                                                             |
| `options.wait_for`                | `u32`                     | Wait for page render (milliseconds).                                                                                                                                                                                                                 |
| `options.mobile`                  | `bool`                    | Mobile viewport.                                                                                                                                                                                                                                     |
| `options.parsers`                 | `Vec<ParserConfig>`       | File parsers. PDF: `ParserConfig::Pdf { parser_type, max_pages, pages, blocks, page_markers }`.                                                                                                                                                      |
| `options.actions`                 | `Vec<Action>`             | Pre-scrape actions: `Wait`, `Click`, `Write`, `Press`, `Scroll`, `Scrape`, `Screenshot`, `ExecuteJavascript`, `Pdf`.                                                                                                                                 |
| `options.location`                | `LocationConfig`          | Geo config: `country`, `languages`.                                                                                                                                                                                                                  |
| `options.skip_tls_verification`   | `bool`                    | Skip TLS verification.                                                                                                                                                                                                                               |
| `options.remove_base64_images`    | `bool`                    | Drop base64 images from markdown.                                                                                                                                                                                                                    |
| `options.fast_mode`               | `bool`                    | Faster scrapes, reduced fidelity.                                                                                                                                                                                                                    |
| `options.block_ads`               | `bool`                    | Block ads and cookie popups.                                                                                                                                                                                                                         |
| `options.proxy`                   | `ProxyType`               | Proxy: `Basic`, `Stealth`, `Enhanced`, `Auto`.                                                                                                                                                                                                       |
| `options.max_age`                 | `u32`                     | Max age of cached content (milliseconds).                                                                                                                                                                                                            |
| `options.min_age`                 | `u32`                     | Min age of cached content (milliseconds).                                                                                                                                                                                                            |
| `options.store_in_cache`          | `bool`                    | Cache the result.                                                                                                                                                                                                                                    |
| `options.profile`                 | `ProfileConfig`           | Persistent browser profile: `name`, `save_changes`.                                                                                                                                                                                                  |
| `options.json_options`            | `JsonOptions`             | JSON extraction: `schema`, `system_prompt`, `prompt`.                                                                                                                                                                                                |
| `options.screenshot_options`      | `ScreenshotOptions`       | Screenshot: `full_page`, `quality`, `viewport`.                                                                                                                                                                                                      |
| `options.change_tracking_options` | `ChangeTrackingOptions`   | Change tracking: `modes` (`GitDiff`, `Json`), `schema`, `prompt`, `tag`.                                                                                                                                                                             |
| `options.attribute_selectors`     | `Vec<AttributeSelector>`  | Attribute extraction: `selector`, `attribute`.                                                                                                                                                                                                       |

## Interact

### Why use it

Control the browser session tied to a prior scrape. Use for clicks, form fills, code execution, or natural-language instructions.

### Preferred SDK method

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

At least one of `code` or `prompt` must be non-empty; otherwise returns `FirecrawlError::Misuse`.

### Example

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

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

let job_id = doc.metadata
    .as_ref()
    .and_then(|m| m.scrape_id.as_ref())
    .expect("Missing scrapeId");

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

// When done:
client.stop_interaction(job_id).await?;
```

### Parameters

| Parameter          | Type                    | Description                                                                |
| ------------------ | ----------------------- | -------------------------------------------------------------------------- |
| `job_id`           | `impl AsRef<str>`       | Scrape job ID from `document.metadata.scrape_id`.                          |
| `options.code`     | `Option<String>`        | Code to execute. At least one of `code` or `prompt` required.              |
| `options.prompt`   | `Option<String>`        | Natural-language instruction. At least one of `code` or `prompt` required. |
| `options.language` | `ScrapeExecuteLanguage` | Runtime: `Python`, `Node`, `Bash`. Default: `Node`.                        |
| `options.timeout`  | `u32`                   | Execution timeout in seconds.                                              |

Stop the session with `client.stop_interaction(job_id)`.

## Notes

* Deprecated aliases: `scrape_execute` → `interact`, `stop_interactive_browser` / `delete_scrape_browser` → `stop_interaction`.
* All types are exported at crate root: `use firecrawl::Client`.
* `ScrapeOptions` has dedicated sub-option structs: `json_options`, `screenshot_options`, `change_tracking_options`.
* `search_and_scrape(query, limit)` is a convenience that calls `search` with default scrape options and returns `Vec<Document>`.

## Source Of Truth

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