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

Canonical Firecrawl Elixir quickstart for agents. Generated from `:firecrawl` **v1.11.0** SDK source and the v2 OpenAPI spec. The Elixir client is auto-generated from the OpenAPI spec; function names and parameter keys match the generated surface.

## Install

Add to `mix.exs`:

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

Requires Elixir >= 1.15.

## 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.scrape_and_extract_from_url(
  [url: "https://example.com"],
  api_key: "fc-your-api-key"
)
```

A nil API key enables keyless free-tier access (rate-limited per IP). Every function accepts `api_key:` and `base_url:` overrides in the trailing `opts` keyword list.

## 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. Elixir SDK exposes code-based interactions only (no `prompt` parameter).

## 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:`, 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 scope to a domain.          |
| `sources`             | `list`         | Atoms, strings, or maps: `:web`, `:news`, `:images`.                |
| `categories`          | `list`         | Atoms, strings, or maps: `:developer`, `:research`, `:pdf`.         |
| `include_domains`     | `list(string)` | Allowlist domains.                                                  |
| `exclude_domains`     | `list(string)` | Blocklist domains.                                                  |
| `limit`               | `integer`      | Cap the number of results.                                          |
| `tbs`                 | `string`       | Time-based filter (e.g. `qdr:d` for past day).                      |
| `location`            | `string`       | Localized results.                                                  |
| `country`             | `string`       | ISO 3166-1 alpha-2 targeting (e.g. `"US"`).                         |
| `ignore_invalid_urls` | `boolean`      | Drop URLs that cannot be scraped.                                   |
| `highlights`          | `boolean`      | Generate query-relevant highlights. Defaults to `true` server-side. |
| `timeout`             | `integer`      | Request timeout in milliseconds.                                    |
| `scrape_options`      | `keyword list` | Scrape each search result. See Scrape parameters.                   |
| `enterprise`          | `list(string)` | Zero-data-retention modes: `"zdr"`, `"anon"`.                       |

## Scrape

### Why use it

Get structured content from a URL 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`       | The URL to scrape.                                                                                                                                                                                                                                                                                            |
| `formats`               | `list`         | Output formats. Strings: `"markdown"`, `"html"`, `"rawHtml"`, `"links"`, `"images"`, `"screenshot"`, `"summary"`, `"changeTracking"`, `"json"`, `"branding"`, `"audio"`, `"video"`. Maps: `%{type: "json", prompt: ...}`, `%{type: "screenshot", fullPage: true}`, `%{type: "changeTracking", modes: [...]}`. |
| `headers`               | `map`          | Custom request headers.                                                                                                                                                                                                                                                                                       |
| `include_tags`          | `list(string)` | Only include content from these HTML tags.                                                                                                                                                                                                                                                                    |
| `exclude_tags`          | `list(string)` | Exclude content from these HTML tags.                                                                                                                                                                                                                                                                         |
| `only_main_content`     | `boolean`      | Strip nav, footer, and other boilerplate.                                                                                                                                                                                                                                                                     |
| `timeout`               | `integer`      | Timeout in milliseconds. Min: 1000, default: 60000, max: 300000.                                                                                                                                                                                                                                              |
| `wait_for`              | `integer`      | Wait for the page to render (ms).                                                                                                                                                                                                                                                                             |
| `mobile`                | `boolean`      | Emulate a mobile viewport.                                                                                                                                                                                                                                                                                    |
| `parsers`               | `list`         | File parsing controls: `"pdf"` or `%{type: "pdf", mode: "auto", maxPages: 5}`.                                                                                                                                                                                                                                |
| `actions`               | `list(map)`    | Pre-scrape actions: `wait`, `click`, `write`, `press`, `scroll`, `scrape`, `executeJavascript`, `screenshot`, `pdf`.                                                                                                                                                                                          |
| `location`              | `keyword list` | Geo or language-aware scraping: `[country: "US", languages: ["en-US"]]`.                                                                                                                                                                                                                                      |
| `skip_tls_verification` | `boolean`      | Skip TLS verification.                                                                                                                                                                                                                                                                                        |
| `remove_base64_images`  | `boolean`      | Drop base64 images from markdown.                                                                                                                                                                                                                                                                             |
| `block_ads`             | `boolean`      | Block ads and cookie popups.                                                                                                                                                                                                                                                                                  |
| `proxy`                 | `atom`         | Proxy control: `:basic`, `:enhanced`, `:auto`.                                                                                                                                                                                                                                                                |
| `max_age`               | `integer`      | Use cached data up to this age (ms). Default: 2 days.                                                                                                                                                                                                                                                         |
| `min_age`               | `integer`      | Use cached data only if at least this old (ms).                                                                                                                                                                                                                                                               |
| `store_in_cache`        | `boolean`      | Cache the result on Firecrawl's side.                                                                                                                                                                                                                                                                         |
| `lockdown`              | `boolean`      | Serve only cached results; no outbound request.                                                                                                                                                                                                                                                               |
| `redact_pii`            | `boolean`      | Redact personally identifiable information.                                                                                                                                                                                                                                                                   |
| `profile`               | `keyword list` | Persistent browser profile: `[name: "...", save_changes: true]`.                                                                                                                                                                                                                                              |
| `audit_metadata`        | `keyword list` | SIEM logging attribution: `[username: "..."]`.                                                                                                                                                                                                                                                                |
| `zero_data_retention`   | `boolean`      | Enable zero data retention for this scrape.                                                                                                                                                                                                                                                                   |

## Interact

### Why use it

Execute code in the browser session tied to a scrape job. 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, scrape_res} = Firecrawl.scrape_and_extract_from_url(
  url: "https://example.com",
  formats: ["markdown"]
)
job_id = get_in(scrape_res.body, ["data", "metadata", "scrapeId"])

{:ok, res} = Firecrawl.interact_with_scrape_browser_session(
  job_id,
  code: "console.log(await page.title());",
  language: :node,
  timeout: 60
)

# Stop the session when done
{:ok, _} = Firecrawl.stop_interactive_scrape_browser_session(job_id)
```

### Parameters

| Parameter  | Type      | Description                                      |
| ---------- | --------- | ------------------------------------------------ |
| `job_id`   | `string`  | Scrape job ID from the scrape response metadata. |
| `code`     | `string`  | Code to run in the browser session. Required.    |
| `language` | `atom`    | 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.

## Notes

* The Elixir client is auto-generated from the OpenAPI spec; function names reflect the generated surface.
* All params use snake\_case atom keys; they are automatically camelCased for the HTTP body.
* Every function has a bang (`!`) variant that raises on error: `scrape_and_extract_from_url!`, `search_and_scrape!`, etc.
* An `"origin"` field (`"elixir-sdk@1.11.0"`) is automatically injected into every request body.
* `interact_with_scrape_browser_session` only accepts `code`, not `prompt`.

## Source Of Truth

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