# Crawl

> Recursively crawl a website and get content from every page

import InstallationPython from '/snippets/v2/installation/python.mdx';
import InstallationNode from '/snippets/v2/installation/js.mdx';
import InstallationCLI from '/snippets/v2/installation/cli.mdx';
import CrawlPython from '/snippets/v2/crawl/base/python.mdx';
import CrawlNode from '/snippets/v2/crawl/base/js.mdx';
import CrawlCURL from '/snippets/v2/crawl/base/curl.mdx';
import CrawlCLI from '/snippets/v2/crawl/base/cli.mdx';
import CheckCrawlJobPython from '/snippets/v2/crawl-status/short/python.mdx';
import CheckCrawlJobNode from '/snippets/v2/crawl-status/short/js.mdx';
import CheckCrawlJobCURL from '/snippets/v2/crawl-status/short/curl.mdx';
import CheckCrawlJobCLI from '/snippets/v2/crawl-status/short/cli.mdx';
import CheckCrawlJobOutputScraping from '/snippets/v2/crawl-status/base/output-scraping.mdx';
import CheckCrawlJobOutputCompleted from '/snippets/v2/crawl-status/base/output-completed.mdx';
import CrawlWebSocketPython from '/snippets/v2/crawl-websocket/base/python.mdx';
import CrawlWebSocketNode from '/snippets/v2/crawl-websocket/base/js.mdx';
import CrawlWebhookCURL from '/snippets/v2/crawl-webhook/base/curl.mdx';
import PythonCrawlExample from '/snippets/v2/crawl/sdk-example/python.mdx';
import NodeCrawlExample from '/snippets/v2/crawl/sdk-example/js.mdx';
import PythonCrawlExampleResponse from '/snippets/v2/crawl/sdk-example/python-response.mdx';
import NodeCrawlExampleResponse from '/snippets/v2/crawl/sdk-example/js-response.mdx';
import StartCrawlPython from '/snippets/v2/start-crawl/base/python.mdx';
import StartCrawlNode from '/snippets/v2/start-crawl/base/js.mdx';
import StartCrawlCURL from '/snippets/v2/start-crawl/base/curl.mdx';
import StartCrawlCLI from '/snippets/v2/start-crawl/base/cli.mdx';
import StartCrawlOutput from '/snippets/v2/start-crawl/base/output.mdx';
import PlaygroundCTA from "/snippets/shared/playground-cta-crawl.mdx";

Crawl submits a URL to Firecrawl and recursively discovers and scrapes every reachable subpage. It handles sitemaps, JavaScript rendering, and rate limits automatically, returning clean markdown or structured data for each page.

- Discovers pages via sitemap and recursive link traversal
- Supports path filtering, depth limits, and subdomain/external link control
- Returns results via polling, WebSocket, or webhook

<PlaygroundCTA />

## Installation

<CodeGroup>

<InstallationPython />
<InstallationNode />
<InstallationCLI />

</CodeGroup>

## Basic usage

Submit a crawl job by calling `POST /v2/crawl` with a starting URL. The endpoint returns a job ID that you use to poll for results.

<CodeGroup>

<CrawlPython />
<CrawlNode />
<CrawlCURL />
<CrawlCLI />

</CodeGroup>

<Info>
  Each page crawled consumes 1 credit. The default crawl `limit` is 10,000 pages. Before starting, the crawl endpoint checks that your remaining credits can cover the `limit` — if not, it returns a **402 (Payment Required)** error. Set a lower `limit` to match your intended crawl size (e.g. `limit: 100`) to avoid this. Additional credits apply for certain options: JSON mode costs 4 additional credits per page, and PDF parsing costs 1 credit per PDF page.
</Info>

### Scrape options

All options from the [Scrape endpoint](/api-reference/endpoint/scrape) are available in crawl via `scrapeOptions` (JS) / `scrape_options` (Python). These apply to every page the crawler scrapes, including formats, proxy, caching, actions, location, and tags.

<CodeGroup>

```python Python
from firecrawl import Firecrawl

firecrawl = Firecrawl(api_key='fc-YOUR_API_KEY')

# Crawl with scrape options
response = firecrawl.crawl('https://example.com',
    limit=100,
    scrape_options={
        'formats': [
            'markdown',
            { 'type': 'json', 'schema': { 'type': 'object', 'properties': { 'title': { 'type': 'string' } } } }
        ],
        'proxy': 'auto',
        'max_age': 600000,
        'only_main_content': True
    }
)
```

```js Node
import { Firecrawl } from 'firecrawl';

const firecrawl = new Firecrawl({ apiKey: 'fc-YOUR_API_KEY' });

// Crawl with scrape options
const crawlResponse = await firecrawl.crawl('https://example.com', {
  limit: 100,
  scrapeOptions: {
    formats: [
      'markdown',
      {
        type: 'json',
        schema: { type: 'object', properties: { title: { type: 'string' } } },
      },
    ],
    proxy: 'auto',
    maxAge: 600000,
    onlyMainContent: true,
  },
});
```

</CodeGroup>

## Checking crawl status

Use the job ID to poll for the crawl status and retrieve results.

<CodeGroup>

<CheckCrawlJobPython />
<CheckCrawlJobNode />
<CheckCrawlJobCURL />
<CheckCrawlJobCLI />

</CodeGroup>

<Note>
  Job results are available via the API for 24 hours after completion. After this period, you can still view your crawl history and results in the [activity logs](https://www.firecrawl.dev/app/logs).
</Note>

<Note>
  Pages in the crawl results `data` array are pages that Firecrawl successfully scraped, even if the target site returned an HTTP error like 404. The `metadata.statusCode` field shows the HTTP status code from the target site. To retrieve pages that Firecrawl itself failed to scrape (e.g. network errors, timeouts, or robots.txt blocks), use the dedicated [Get Crawl Errors](/api-reference/endpoint/crawl-get-errors) endpoint (`GET /crawl/{id}/errors`).
</Note>

### Response handling

The response varies based on the crawl's status. For incomplete or large responses exceeding 10MB, a `next` URL parameter is provided. You must request this URL to retrieve the next 10MB of data. If the `next` parameter is absent, it indicates the end of the crawl data.

<Info>
  The `skip` and `next` parameters are only relevant when hitting the API directly.
  If you're using the SDK, pagination is handled automatically and all
  results are returned at once.
</Info>

<CodeGroup>
  <CheckCrawlJobOutputScraping />
  <CheckCrawlJobOutputCompleted />
</CodeGroup>

## SDK methods

There are two ways to use crawl with the SDK.

### Crawl and wait

The `crawl` method waits for the crawl to complete and returns the full response. It handles pagination automatically. This is recommended for most use cases.

<CodeGroup>
  <PythonCrawlExample />
  <NodeCrawlExample />
</CodeGroup>

The response includes the crawl status and all scraped data:

<CodeGroup>
  <PythonCrawlExampleResponse />
  <NodeCrawlExampleResponse />
</CodeGroup>

### Start and check later

The `startCrawl` / `start_crawl` method returns immediately with a crawl ID. You then poll for status manually. This is useful for long-running crawls or custom polling logic.

<CodeGroup>
  <StartCrawlPython />
  <StartCrawlNode />
  <StartCrawlCURL />
  <StartCrawlCLI />
</CodeGroup>

The initial response returns the job ID:

<StartCrawlOutput />

## Real-time results with WebSocket

The watcher method provides real-time updates as pages are crawled. Start a crawl, then subscribe to events for immediate data processing.

<CodeGroup>
  <CrawlWebSocketPython />
  <CrawlWebSocketNode />
</CodeGroup>

## Webhooks

You can configure webhooks to receive real-time notifications as your crawl progresses. This allows you to process pages as they are scraped instead of waiting for the entire crawl to complete.

<CrawlWebhookCURL />

### Event types

| Event | Description |
|-------|-------------|
| `crawl.started` | Fires when the crawl begins |
| `crawl.page` | Fires for each page successfully scraped |
| `crawl.completed` | Fires when the crawl finishes |
| `crawl.failed` | Fires if the crawl encounters an error |

### Payload

```json
{
  "success": true,
  "type": "crawl.page",
  "id": "crawl-job-id",
  "data": [...], // Page data for 'page' events
  "metadata": {}, // Your custom metadata
  "error": null
}
```

### Verifying webhook signatures

Every webhook request from Firecrawl includes an `X-Firecrawl-Signature` header containing an HMAC-SHA256 signature. Always verify this signature to ensure the webhook is authentic and has not been tampered with.

1. Get your webhook secret from the [Advanced tab](https://www.firecrawl.dev/app/settings?tab=advanced) of your account settings
2. Extract the signature from the `X-Firecrawl-Signature` header
3. Compute HMAC-SHA256 of the raw request body using your secret
4. Compare with the signature header using a timing-safe function

<Warning>
  Never process a webhook without verifying its signature first. The `X-Firecrawl-Signature` header contains the signature in the format: `sha256=abc123def456...`
</Warning>

For complete implementation examples in JavaScript and Python, see the [Webhook Security documentation](/webhooks/security). For comprehensive webhook documentation including detailed event payloads, payload structure, advanced configuration, and troubleshooting, see the [Webhooks documentation](/webhooks/overview).

## Configuration reference

The full set of parameters available when submitting a crawl job:

| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `url` | `string` | (required) | The starting URL to crawl from |
| `limit` | `integer` | `10000` | Maximum number of pages to crawl |
| `maxDiscoveryDepth` | `integer` | (none) | Maximum depth from the root URL based on link-discovery hops, not the number of `/` segments in the URL. Each time a new URL is found on a page, it is assigned a depth one higher than the page it was discovered on. The root site and sitemapped pages have a discovery depth of 0. Pages at the max depth are still scraped, but links on them are not followed. |
| `includePaths` | `string[]` | (none) | URL pathname regex patterns to include. Only matching paths are crawled. |
| `excludePaths` | `string[]` | (none) | URL pathname regex patterns to exclude from the crawl |
| `regexOnFullURL` | `boolean` | `false` | Match `includePaths`/`excludePaths` against the full URL (including query parameters) instead of just the pathname |
| `crawlEntireDomain` | `boolean` | `false` | Follow internal links to sibling or parent URLs, not just child paths |
| `allowSubdomains` | `boolean` | `false` | Follow links to subdomains of the main domain |
| `allowExternalLinks` | `boolean` | `false` | Follow links to external websites. External links are followed one hop (their own links are not crawled), and links pointing to an external site's homepage are skipped — see [External links](#external-links). |
| `sitemap` | `string` | `"include"` | Sitemap handling: `"include"` (default), `"skip"`, or `"only"` |
| `ignoreQueryParameters` | `boolean` | `false` | Avoid re-scraping the same path with different query parameters |
| `ignoreRobotsTxt` | `boolean` | `false` | Ignore the website's robots.txt rules. **Enterprise only** — contact support@firecrawl.com to enable. |
| `robotsUserAgent` | `string` | (none) | Custom User-Agent string for robots.txt evaluation. When set, robots.txt is fetched with this User-Agent and rules are matched against it instead of the default. **Enterprise only** — contact support@firecrawl.com to enable. |
| `delay` | `number` | (none) | Delay in seconds between scrapes to respect rate limits. Setting this forces concurrency to 1. |
| `maxConcurrency` | `integer` | (none) | Maximum concurrent scrapes. Defaults to your team's concurrency limit. |
| `scrapeOptions` | `object` | (none) | Options applied to every scraped page (formats, proxy, caching, actions, etc.) |
| `webhook` | `object` | (none) | Webhook configuration for real-time notifications |
| `prompt` | `string` | (none) | Natural language prompt to generate crawl options. Explicitly set parameters override generated equivalents. |

## Important details

<Warning>
  By default, crawl ignores sublinks that are not children of the URL you provide. For example, `website.com/other-parent/blog-1` would not be returned if you crawled `website.com/blogs/`. Use the `crawlEntireDomain` parameter to include sibling and parent paths. To crawl subdomains like `blog.website.com` when crawling `website.com`, use the `allowSubdomains` parameter.
</Warning>

- **Sitemap discovery**: By default, the crawler includes the website's sitemap to discover URLs (`sitemap: "include"`). If you set `sitemap: "skip"`, only pages reachable through HTML links from the root URL are found. Assets like PDFs or deeply nested pages listed in the sitemap but not directly linked from HTML will be missed. For maximum coverage, keep the default setting.
- **Credit usage**: Each page crawled costs 1 credit. JSON mode adds 4 credits per page, and PDF parsing costs 1 credit per PDF page.
- **Result expiration**: Job results are available via the API for 24 hours after completion. After that, view results in the [activity logs](https://www.firecrawl.dev/app/logs).
- **Crawl errors**: The `data` array contains pages Firecrawl successfully scraped. Use the [Get Crawl Errors](/api-reference/endpoint/crawl-get-errors) endpoint to retrieve pages that failed due to network errors, timeouts, or robots.txt blocks.
- <a id="external-links"></a>**External links**: With `allowExternalLinks: true`, the crawler follows links pointing off your domain and scrapes each linked page once — it does not then crawl the links found on those external pages. Links to an external site's **homepage** (a root URL with no path, e.g. `https://example.com/`) are intentionally skipped to avoid pulling in an entire unrelated site; these appear in [Get Crawl Errors](/api-reference/endpoint/crawl-get-errors) with the code `EXTERNAL_LINK`. Redirects are followed to their destination — including a link that resolves to its canonical URL (for example `http → https` or the `www` variant) — so only redirects that land on an external homepage are skipped.
- **Non-deterministic results**: Crawl results may vary between runs of the same configuration. Pages are scraped concurrently, so the order in which links are discovered depends on network timing and which pages finish loading first. This means different branches of a site may be explored to different extents near the depth boundary, especially at higher `maxDiscoveryDepth` values. To get more deterministic results, set `maxConcurrency` to `1` or use `sitemap: "only"` if the site has a comprehensive sitemap.

> Are you an AI agent that needs a Firecrawl API key? See [firecrawl.dev/agent-onboarding/SKILL.md](https://www.firecrawl.dev/agent-onboarding/SKILL.md) for automated onboarding instructions.
