> ## Documentation Index
> Fetch the complete documentation index at: https://firecrawl-claude-eager-dijkstra-1rj1nh.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` hex package) and the OpenAPI spec. Use this file to get an agent calling Firecrawl correctly in one pass.

The Elixir SDK is auto-generated from the OpenAPI spec. Function names follow the OpenAPI operation names rather than short aliases.

## Install

Add to your `mix.exs` dependencies:

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

Then run `mix deps.get`.

## Authenticate

**Application config** (recommended):

```elixir theme={null}
# config/config.exs
config :firecrawl, api_key: "fc-YOUR_API_KEY"
```

**Per-call option** (overrides config):

```elixir theme={null}
Firecrawl.scrape_and_extract_from_url([url: "https://example.com"], api_key: "fc-...")
```

Additional per-call options:

* `:base_url` — override the default `https://api.firecrawl.dev/v2` (for self-hosted).
* Any other keys are passed through to the underlying `Req` request.

No API key is required for scrape, search, and interact — they fall back to a keyless free tier (rate-limited per IP).

## When To Use What

* **`search_and_scrape`**: Start with a text query and need to discover relevant URLs and content across the web.
* **`scrape_and_extract_from_url`**: Already have a URL and want page content (markdown, HTML, structured JSON, screenshots, etc.).
* **`interact_with_scrape_browser_session`**: The page needs clicks, form fills, or post-scrape browser actions — run code against the live browser session.

## Search

### Why use it

Search the web and optionally scrape each result. Returns categorized results (web, news, images) with optional content scraping.

### Preferred SDK method

```elixir theme={null}
Firecrawl.search_and_scrape(params, opts)
Firecrawl.search_and_scrape!(params, opts)  # raises on error
```

### Example

```elixir theme={null}
{:ok, response} = Firecrawl.search_and_scrape(
  query: "firecrawl web scraping API",
  limit: 5,
  scrape_options: [formats: ["markdown"]]
)

for item <- response.body["data"]["web"] do
  IO.puts("#{item["url"]} #{item["title"]}")
end
```

### Parameters

All parameters are passed as a keyword list. Only `query` is required.

| Parameter             | Type           | Description                                                            |
| --------------------- | -------------- | ---------------------------------------------------------------------- |
| `query`               | `:string`      | **Required.** The search query.                                        |
| `limit`               | `:integer`     | Max number of results.                                                 |
| `sources`             | `list(any)`    | Sources: `"web"`, `"news"`, `"images"`.                                |
| `categories`          | `list(any)`    | Category filters: `"github"`, `"research"`, `"pdf"`, `"developer"`.    |
| `include_domains`     | `list(string)` | Only include these domains. Mutually exclusive with `exclude_domains`. |
| `exclude_domains`     | `list(string)` | Exclude these domains.                                                 |
| `tbs`                 | `:string`      | Time-based filter (e.g. `"qdr:d"` for past day).                       |
| `location`            | `:string`      | Location for geo-targeting.                                            |
| `country`             | `:string`      | ISO country code.                                                      |
| `ignore_invalid_urls` | `:boolean`     | Exclude invalid URLs.                                                  |
| `timeout`             | `:integer`     | Timeout in milliseconds.                                               |
| `highlights`          | `:boolean`     | Generate highlights. Defaults to `true`.                               |
| `scrape_options`      | `keyword`      | Scrape options applied to each result.                                 |
| `enterprise`          | `list(string)` | Enterprise options (e.g. `["zdr"]`).                                   |

**Return type**: `{:ok, %Req.Response{}}` where `response.body` contains `"data"` with `"web"`, `"news"`, `"images"` arrays.

## Scrape

### Why use it

Fetch a single URL and extract content in various formats: markdown, HTML, structured JSON, screenshots, audio, video, and more. Handles JavaScript rendering, ad blocking, proxies, and caching.

### Preferred SDK method

```elixir theme={null}
Firecrawl.scrape_and_extract_from_url(params, opts)
Firecrawl.scrape_and_extract_from_url!(params, opts)  # raises on error
```

### Example

```elixir theme={null}
{:ok, response} = Firecrawl.scrape_and_extract_from_url(
  url: "https://example.com",
  formats: ["markdown", "links"],
  only_main_content: true
)

IO.puts(response.body["data"]["markdown"])
```

### Parameters

All parameters are passed as a keyword list. Only `url` is required.

| Parameter               | Type                           | Description                                                                                                                                                                                                                        |
| ----------------------- | ------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `url`                   | `:string`                      | **Required.** The URL to scrape.                                                                                                                                                                                                   |
| `formats`               | `list(any)`                    | Output formats: `"markdown"`, `"html"`, `"rawHtml"`, `"links"`, `"images"`, `"screenshot"`, `"summary"`, `"json"`, `"audio"`, `"video"`, `"branding"`, `"product"`, `"menu"`, `"changeTracking"`. Also accepts format config maps. |
| `headers`               | `any`                          | Custom HTTP headers.                                                                                                                                                                                                               |
| `include_tags`          | `list(string)`                 | HTML tags to include.                                                                                                                                                                                                              |
| `exclude_tags`          | `list(string)`                 | HTML tags to exclude.                                                                                                                                                                                                              |
| `only_main_content`     | `:boolean`                     | Strip boilerplate.                                                                                                                                                                                                                 |
| `timeout`               | `:integer`                     | Timeout in ms. Min 1000, max 300000. Default 60000.                                                                                                                                                                                |
| `wait_for`              | `:integer`                     | Wait before scraping in ms.                                                                                                                                                                                                        |
| `mobile`                | `:boolean`                     | Emulate mobile viewport.                                                                                                                                                                                                           |
| `parsers`               | `list(any)`                    | Parser config (e.g. PDF mode).                                                                                                                                                                                                     |
| `actions`               | `list(any)`                    | Browser actions before scraping.                                                                                                                                                                                                   |
| `location`              | `keyword`                      | Geo-targeting: `country`, `languages`.                                                                                                                                                                                             |
| `skip_tls_verification` | `:boolean`                     | Skip TLS checks.                                                                                                                                                                                                                   |
| `remove_base64_images`  | `:boolean`                     | Strip base64 images.                                                                                                                                                                                                               |
| `block_ads`             | `:boolean`                     | Block ads and popups.                                                                                                                                                                                                              |
| `proxy`                 | `:basic \| :enhanced \| :auto` | Proxy tier.                                                                                                                                                                                                                        |
| `max_age`               | `:integer`                     | Cache max-age in ms.                                                                                                                                                                                                               |
| `store_in_cache`        | `:boolean`                     | Store in Firecrawl cache.                                                                                                                                                                                                          |
| `lockdown`              | `:boolean`                     | Only serve cached results.                                                                                                                                                                                                         |
| `redact_pii`            | `:boolean`                     | Redact PII.                                                                                                                                                                                                                        |
| `audit_metadata`        | `keyword`                      | SIEM attribution. Keys: `username` (required).                                                                                                                                                                                     |
| `profile`               | `keyword`                      | Browser profile: `name`, `save_changes`.                                                                                                                                                                                           |
| `zero_data_retention`   | `:boolean`                     | Zero data retention mode.                                                                                                                                                                                                          |

## Interact

### Why use it

Execute code against the live browser session from a previous scrape. Use it to click buttons, fill forms, navigate, or extract dynamic content that only appears after user interaction.

### Preferred SDK method

```elixir theme={null}
Firecrawl.interact_with_scrape_browser_session(job_id, params, opts)
Firecrawl.interact_with_scrape_browser_session!(job_id, params, opts)  # raises on error
```

### Example

```elixir theme={null}
{:ok, scrape_response} = Firecrawl.scrape_and_extract_from_url(
  url: "https://example.com",
  formats: ["markdown"]
)

job_id = scrape_response.body["data"]["metadata"]["jobId"]

{:ok, result} = Firecrawl.interact_with_scrape_browser_session(job_id,
  code: "document.querySelector('button.load-more').click();",
  language: :node,
  timeout: 30
)

IO.puts(result.body["stdout"])

# When done, stop the session:
Firecrawl.stop_interactive_scrape_browser_session(job_id)
```

### Parameters

The first argument is `job_id` (string). Remaining parameters are a keyword list.

| Parameter  | Type                        | Description                                           |
| ---------- | --------------------------- | ----------------------------------------------------- |
| `job_id`   | `String.t()`                | **Required.** Path parameter. The scrape job ID.      |
| `code`     | `:string`                   | **Required.** Code to execute in the browser sandbox. |
| `language` | `:python \| :node \| :bash` | Language of the code. Defaults to `:node`.            |
| `timeout`  | `:integer`                  | Execution timeout in seconds.                         |
| `origin`   | `:string`                   | Origin label for telemetry.                           |

**Stop the session** when done:

```elixir theme={null}
Firecrawl.stop_interactive_scrape_browser_session(job_id)
```

## Notes

* **Function names are OpenAPI-derived**: `scrape_and_extract_from_url`, `search_and_scrape`, `interact_with_scrape_browser_session`. These are the canonical names; there are no short aliases.
* All parameter names use **snake\_case** (e.g. `only_main_content`, `skip_tls_verification`).
* Every function has a bang (`!`) variant that raises `Firecrawl.Error` on HTTP errors instead of returning `{:error, ...}`.
* Return values are `{:ok, %Req.Response{}}` or `{:error, exception}`. Access response data via `response.body`.
* **No deprecated aliases exist** in the Elixir SDK.
* The Elixir SDK is auto-generated from the OpenAPI spec. Its parameter names match the API wire format (in snake\_case).

## Source Of Truth

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