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

# Elixir Agent Quickstart

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

# Firecrawl Elixir Agent Quickstart

Canonical quickstart for external agents. Generated from SDK source (`:firecrawl` v1.9.2) and the v2 OpenAPI spec. Function names and parameter keys match the auto-generated client module.

## Install

Add to `mix.exs`:

```elixir theme={null}
{:firecrawl, "~> 1.9"}
```

## Authenticate

```elixir theme={null}
# config/runtime.exs or config.exs
config :firecrawl, api_key: System.get_env("FIRECRAWL_API_KEY")

# Or pass api_key per call:
{:ok, res} = Firecrawl.search_and_scrape([query: "firecrawl webhooks"], api_key: "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. Constrain results to a site with `site:`, for example `site:docs.firecrawl.dev crawl webhooks`.

### Preferred SDK method

`Firecrawl.search_and_scrape(params \\ [], opts \\ [])`

### Example

```elixir theme={null}
{:ok, res} = Firecrawl.search_and_scrape(
  query: "site:docs.firecrawl.dev webhook retries",
  sources: [:web],
  limit: 5,
  scrape_options: [
    formats: ["markdown"],
    only_main_content: true
  ]
)
```

### Parameters

| Parameter             | Type           | Description                                                                       |
| --------------------- | -------------- | --------------------------------------------------------------------------------- |
| `query`               | `string`       | Search query. Use `site:example.com` to limit to a domain. **Required.**          |
| `sources`             | `list`         | Sources to query: `:web`, `:news`, `:images` (atoms or strings).                  |
| `categories`          | `list`         | Filter by category: `:github`, `:research`, `:pdf` (atoms, strings, or maps).     |
| `include_domains`     | `list[string]` | Restrict to these domains.                                                        |
| `exclude_domains`     | `list[string]` | Exclude these domains.                                                            |
| `limit`               | `integer`      | Max results.                                                                      |
| `tbs`                 | `string`       | Time-based filter (e.g. `qdr:d`, `qdr:w`).                                        |
| `location`            | `string`       | Location for localized results.                                                   |
| `country`             | `string`       | ISO 3166-1 alpha-2 country code (e.g. `"US"`).                                    |
| `ignore_invalid_urls` | `boolean`      | Drop URLs that cannot be scraped.                                                 |
| `timeout`             | `integer`      | Request timeout in milliseconds.                                                  |
| `highlights`          | `boolean`      | Generate query-relevant highlights. Defaults to `true`.                           |
| `enterprise`          | `list[string]` | Enterprise options: `["zdr"]` for zero data retention, `["anon"]` for anonymized. |
| `scrape_options`      | `keyword list` | Options applied to scrape each result (see Scrape parameters).                    |

## Scrape

### Why use it

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

### Preferred SDK method

`Firecrawl.scrape_and_extract_from_url(params \\ [], opts \\ [])`

### Example

```elixir theme={null}
{:ok, res} = Firecrawl.scrape_and_extract_from_url(
  url: "https://example.com/pricing",
  formats: [
    "markdown",
    "links",
    %{type: "json", prompt: "Extract plan names and prices."}
  ],
  only_main_content: true,
  wait_for: 1000
)
```

### Parameters

| Parameter               | Type             | Description                                                                                                                                                                                                                                                                                                       |
| ----------------------- | ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `url`                   | `string`         | URL to scrape. **Required.**                                                                                                                                                                                                                                                                                      |
| `formats`               | `list`           | Output formats. Strings: `"markdown"`, `"html"`, `"rawHtml"`, `"links"`, `"images"`, `"screenshot"`, `"summary"`, `"changeTracking"`, `"json"`, `"branding"`, `"audio"`, `"video"`. Maps: `%{type: "json", prompt: ..., schema: ...}`, `%{type: "question", question: ...}`, `%{type: "highlights", query: ...}`. |
| `headers`               | `map`            | Custom HTTP headers.                                                                                                                                                                                                                                                                                              |
| `include_tags`          | `list[string]`   | Include only these HTML tags.                                                                                                                                                                                                                                                                                     |
| `exclude_tags`          | `list[string]`   | Exclude these HTML tags.                                                                                                                                                                                                                                                                                          |
| `only_main_content`     | `boolean`        | Strip nav, footer, and boilerplate.                                                                                                                                                                                                                                                                               |
| `timeout`               | `integer`        | Timeout in milliseconds. Min 1000, max 300000.                                                                                                                                                                                                                                                                    |
| `wait_for`              | `integer`        | Wait for page render (milliseconds).                                                                                                                                                                                                                                                                              |
| `mobile`                | `boolean`        | Use mobile viewport.                                                                                                                                                                                                                                                                                              |
| `parsers`               | `list`           | File parsing controls. `%{type: "pdf", mode: "fast" \| "auto" \| "ocr", maxPages: integer}`.                                                                                                                                                                                                                      |
| `actions`               | `list[map]`      | Pre-scrape browser actions: `wait`, `screenshot`, `click`, `write`, `press`, `scroll`, `scrape`, `executeJavascript`, `pdf`.                                                                                                                                                                                      |
| `location`              | `keyword list`   | `[country: "US", languages: ["en-US"]]` for geo/language-aware scraping.                                                                                                                                                                                                                                          |
| `skip_tls_verification` | `boolean`        | Skip TLS verification.                                                                                                                                                                                                                                                                                            |
| `remove_base64_images`  | `boolean`        | Drop base64 images from output.                                                                                                                                                                                                                                                                                   |
| `block_ads`             | `boolean`        | Block ads and cookie popups.                                                                                                                                                                                                                                                                                      |
| `proxy`                 | `atom \| string` | Proxy tier: `:basic`, `:enhanced`, `:auto`.                                                                                                                                                                                                                                                                       |
| `max_age`               | `integer`        | Max cache age in milliseconds.                                                                                                                                                                                                                                                                                    |
| `min_age`               | `integer`        | Min cache age in milliseconds.                                                                                                                                                                                                                                                                                    |
| `store_in_cache`        | `boolean`        | Cache the result.                                                                                                                                                                                                                                                                                                 |
| `lockdown`              | `boolean`        | Serve only cached results.                                                                                                                                                                                                                                                                                        |
| `redact_pii`            | `boolean`        | Redact personally identifiable information.                                                                                                                                                                                                                                                                       |
| `audit_metadata`        | `keyword list`   | SIEM audit: `[username: "user"]`.                                                                                                                                                                                                                                                                                 |
| `profile`               | `keyword list`   | Persistent browser profile: `[name: "session", save_changes: true]`.                                                                                                                                                                                                                                              |
| `zero_data_retention`   | `boolean`        | Enable zero data retention.                                                                                                                                                                                                                                                                                       |

## Interact

### Why use it

Use interact when a page requires browser actions or code execution after a scrape starts. The Elixir SDK exposes code-based interactions only (no `prompt` parameter).

### Preferred SDK method

`Firecrawl.interact_with_scrape_browser_session(job_id, params \\ [], opts \\ [])`

### Example

```elixir theme={null}
{:ok, res} = Firecrawl.interact_with_scrape_browser_session(
  "<scrapeJobId>",
  code: "console.log(await page.title());",
  language: :node,
  timeout: 60
)
```

### Parameters

| Parameter  | Type             | Description                                           |
| ---------- | ---------------- | ----------------------------------------------------- |
| `job_id`   | `string`         | Scrape job ID. **Required** (positional).             |
| `code`     | `string`         | Code to execute in the browser session. **Required.** |
| `language` | `atom \| string` | Runtime: `:python`, `:node`, `:bash`.                 |
| `timeout`  | `integer`        | Execution timeout in seconds.                         |
| `origin`   | `string`         | Optional origin label for telemetry.                  |

### Stop session

`Firecrawl.stop_interactive_scrape_browser_session(job_id)` ends the browser session. A bang variant `stop_interactive_scrape_browser_session!/2` is also available.

## Notes

* The Elixir client is auto-generated from the OpenAPI spec. Function names are spec-derived, not hand-aliased.
* No deprecated function aliases exist in this SDK.
* Each function has a bang (`!`) variant that raises on error instead of returning `{:error, _}`.
* All Elixir-side parameter keys are snake\_case; they are automatically converted to camelCase for the API.
* Parameters are validated at runtime using `NimbleOptions` before any HTTP request.
* The SDK uses `Req` as its HTTP client.

## Source Of Truth

* `firecrawl/apps/elixir-sdk/mix.exs`
* `firecrawl/apps/elixir-sdk/lib/firecrawl.ex`
* `firecrawl-docs/api-reference/v2-openapi.json`
