Installation#
The official Java SDK is maintained in the Firecrawl monorepo at apps/java-sdk.
To install the Firecrawl Java SDK, add the dependency from Maven Central:
Usage#
- Get an API key from firecrawl.dev
- Set the API key as an environment variable named
FIRECRAWL_API_KEY, or pass it withFirecrawlClient.builder().apiKey(...)
Here is a quick example using the current SDK API surface:
Scraping a URL#
To scrape a single URL, use the scrape method.
Parsing uploaded files#
The latest Java SDK package (com.firecrawl:firecrawl-java) supports direct file uploads to /v2/parse.
parse does not support changeTracking or browser-only options like screenshot, branding, actions, waitFor, location, and mobile.
JSON Extraction#
Extract structured JSON with JsonFormat 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:
Async Support#
Async variants are built in and return CompletableFuture.
Browser#
The Java 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).stopInteraction(...)explicitly stops the interactive session when you are done.
List & Close Sessions#
Configuration#
FirecrawlClient.builder() supports the following options:
| Option | Type | Default | Description |
|---|---|---|---|
apiKey | String | FIRECRAWL_API_KEY env var or firecrawl.apiKey system property | Your Firecrawl API key |
apiUrl | String | https://api.firecrawl.dev (or FIRECRAWL_API_URL) | API base URL |
timeoutMs | long | 300000 | HTTP request timeout in ms |
maxRetries | int | 3 | Automatic retries for transient failures |
backoffFactor | double | 0.5 | Exponential backoff factor in seconds |
asyncExecutor | Executor | ForkJoinPool.commonPool() | Custom executor for async methods |
httpClient | OkHttpClient | Built from timeoutMs | Pre-configured OkHttpClient instance |
Custom HTTP Client#
You can pass a pre-configured OkHttpClient to control connection pooling, interceptors, SSL configuration, proxy settings, and any other OkHttp feature. When provided, the timeoutMs setting is ignored in favor of the client's own configuration.
Error Handling#
The SDK throws runtime exceptions under com.firecrawl.errors.
Are you an AI agent that needs a Firecrawl API key? See firecrawl.dev/agent-onboarding/SKILL.md for automated onboarding instructions.

