Skip to main content

.NET

Firecrawl .NET SDK is a wrapper around the Firecrawl API to help you easily turn websites into markdown.
3 min read

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:

Note
Requires .NET 8.0 or later.

Usage#

  1. Get an API key from firecrawl.dev
  2. Set the API key as an environment variable named FIRECRAWL_API_KEY, or pass it to the FirecrawlClient constructor

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:

OptionTypeDefaultDescription
apiKeystring?FIRECRAWL_API_KEY env varYour Firecrawl API key
apiUrlstring?https://api.firecrawl.dev (or FIRECRAWL_API_URL)API base URL
timeoutTimeSpan?5 minutesHTTP request timeout
maxRetriesint3Automatic retries for transient failures
backoffFactordouble0.5Exponential backoff factor in seconds
httpClientHttpClient?Built from timeoutPre-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:

ExceptionHTTP CodeWhen
AuthenticationException401Invalid or missing API key
RateLimitException429Too many requests
JobTimeoutExceptionAsync job (crawl/batch scrape) did not complete in time
FirecrawlExceptionvariesBase 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.