Installation#
The official .NET SDK is maintained in the Firecrawl monorepo at apps/dot-net-sdk.
To install the Firecrawl .NET SDK, add the NuGet package:
Usage#
- Get an API key from firecrawl.dev
- Set the API key as an environment variable named
FIRECRAWL_API_KEY, or pass it to theFirecrawlClientconstructor
Here is a quick example using the current SDK API surface:
Scraping a URL#
To scrape a single URL, use the ScrapeAsync method.
JSON Extraction#
Extract structured JSON with JsonFormat via the scrape endpoint:
Crawling a Website#
To crawl a website and wait for completion, use CrawlAsync. This method handles polling and pagination automatically.
Start a Crawl#
Start a job without waiting using StartCrawlAsync.
Checking Crawl Status#
Check crawl progress with GetCrawlStatusAsync.
Cancelling a Crawl#
Cancel a running crawl with CancelCrawlAsync.
Mapping a Website#
Discover links on a site using MapAsync.
Searching the Web#
Search with optional search settings using SearchAsync.
Batch Scraping#
Scrape multiple URLs in parallel using BatchScrapeAsync. This method handles polling and pagination automatically.
Batch Scrape with Idempotency Key#
To ensure duplicate requests are not processed, pass an IdempotencyKey:
Usage & Metrics#
Check concurrency and remaining credits:
Async Support#
All methods in the .NET SDK are async by default and return Task<T>. They support CancellationToken for cooperative cancellation.
Configuration#
The FirecrawlClient constructor supports the following options:
| Option | Type | Default | Description |
|---|---|---|---|
apiKey | string? | FIRECRAWL_API_KEY env var | Your Firecrawl API key |
apiUrl | string? | https://api.firecrawl.dev (or FIRECRAWL_API_URL) | API base URL |
timeout | TimeSpan? | 5 minutes | HTTP request timeout |
maxRetries | int | 3 | Automatic retries for transient failures |
backoffFactor | double | 0.5 | Exponential backoff factor in seconds |
httpClient | HttpClient? | Built from timeout | Pre-configured HttpClient instance |
Custom HTTP Client#
You can pass a pre-configured HttpClient to control connection pooling, proxies, message handlers, and any other HttpClient feature. When provided, the timeout setting is ignored in favor of the client's own configuration.
Environment Variable Configuration#
The SDK resolves configuration from environment variables when constructor parameters are omitted:
Error Handling#
The SDK throws specific exceptions under Firecrawl.Exceptions.
The exception hierarchy:
| Exception | HTTP Code | When |
|---|---|---|
AuthenticationException | 401 | Invalid or missing API key |
RateLimitException | 429 | Too many requests |
JobTimeoutException | — | Async job (crawl/batch scrape) did not complete in time |
FirecrawlException | varies | Base exception for all other API errors |
Transient failures (408, 409, 502, and other 5xx errors) are retried automatically with exponential backoff before an exception is thrown.
Are you an AI agent that needs a Firecrawl API key? See firecrawl.dev/agent-onboarding/SKILL.md for automated onboarding instructions.

