Skip to main content

Go

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

Installation#

The official Go SDK is maintained in the Firecrawl monorepo at apps/go-sdk.

To install the Firecrawl Go SDK, run:

Note
Requires Go 1.23 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 with option.WithAPIKey(...)

Here is a quick example using the current SDK API surface:

Scraping a URL#

To scrape a single URL, use the Scrape method.

JSON Extraction#

Extract structured JSON using JsonOptions via the Scrape endpoint:

Crawling a Website#

To crawl a website and wait for completion, use Crawl.

Start a Crawl#

Start a job without waiting using StartCrawl.

Checking Crawl Status#

Check crawl progress with GetCrawlStatus.

Cancelling a Crawl#

Cancel a running crawl with CancelCrawl.

Mapping a Website#

Discover links on a site using Map.

Searching the Web#

Search with optional search settings using Search.

Batch Scraping#

Scrape multiple URLs in parallel using BatchScrape.

Agent#

Run an AI-powered agent with Agent.

With a JSON schema for structured output:

Usage & Metrics#

Check concurrency and remaining credits:

Browser#

The Go SDK includes Browser Sandbox helpers.

Create a Session#

Execute Code#

Scrape-Bound Interactive Session#

Use a scrape job ID to run follow-up browser code in the same replayed context:

  • Interact(...) runs code in the scrape-bound browser session (and initializes it on first use).
  • StopInteractiveBrowser(...) explicitly stops the interactive session when you are done.

List & Close Sessions#

Configuration#

firecrawl.NewClient() accepts functional options:

OptionTypeDefaultDescription
option.WithAPIKeystringFIRECRAWL_API_KEY env varYour Firecrawl API key
option.WithAPIURLstringhttps://api.firecrawl.dev (or FIRECRAWL_API_URL)API base URL
option.WithTimeouttime.Duration5 * time.MinuteHTTP client timeout
option.WithMaxRetriesint3Automatic retries for transient failures
option.WithBackoffFactorfloat640.5Exponential backoff factor in seconds
option.WithHTTPClient*http.ClientBuilt from timeoutPre-configured HTTP client instance
option.WithHeaderstring, stringAdd an extra header to all requests

Custom HTTP Client#

You can pass a pre-configured *http.Client to control transport settings, proxy configuration, TLS settings, and more. When provided, the WithTimeout setting is ignored in favor of the client's own configuration.

Context Support#

All methods accept a context.Context as the first argument for cancellation and deadline control:

Error Handling#

The SDK uses typed errors under the firecrawl package.

Retry Logic#

The SDK automatically retries transient failures:

  • Retried: 408, 409, 5xx errors, and connection failures
  • Not retried: 401, 429, and other 4xx errors
  • Backoff: Exponential backoff with configurable factor

Pointer Helpers#

The SDK provides convenience functions for optional pointer fields:

Are you an AI agent that needs a Firecrawl API key? See firecrawl.dev/agent-onboarding/SKILL.md for automated onboarding instructions.