Skip to main content

Firecrawl Java Agent Quickstart

This file is the canonical quickstart for external agents integrating Firecrawl via the Java SDK. It is generated from SDK source and OpenAPI spec.

Install

Gradle:
Maven:
Requires Java 11+.

Authenticate

Or from environment variable (FIRECRAWL_API_KEY):
Builder options: apiKey (String), apiUrl (String, default "https://api.firecrawl.dev"), timeoutMs (long, default 300000), maxRetries (int, default 3), backoffFactor (double, default 0.5), asyncExecutor (Executor), httpClient (OkHttpClient).

When To Use What

  • search: Use when you start with a query and need to discover relevant URLs and their content. Returns results from web, news, and image sources.
  • scrape: Use when you already have a specific URL and want its page content in markdown, HTML, JSON, or other formats.
  • interact: Use when the page needs post-scrape browser actions like clicking, typing, scrolling, or executing code in a live browser session.

Why use it

Search the web for a query and optionally scrape the results. Returns categorized results from web, news, and image sources with optional content extraction.

Preferred SDK method

Example

Parameters

All SearchOptions fields are null by default (omitted from the request body). Use the builder pattern.

Return type

SearchData with: getWeb(), getNews(), getImages(). Each returns List<Map<String, Object>>.

Scrape

Why use it

Scrape a single URL and get its content in one or more formats. Supports browser automation, LLM extraction, screenshots, and more.

Preferred SDK method

Example

Parameters

All ScrapeOptions fields are null by default (omitted from the request body). Use the builder pattern.

Format objects

Interact

Why use it

Execute code in a live browser session tied to a scrape job. Use for post-scrape interactions like clicking buttons, filling forms, or running scripts.

Preferred SDK method

Example

Parameters

Use client.stopInteractiveBrowser(jobId) to end the browser session.

Async variants

All three methods have Async variants returning CompletableFuture<T>:

Notes

  • Naming style: All parameters use camelCase. Options use the builder pattern.
  • Deprecated aliases: scrapeExecute() is deprecated in favor of interact(). deleteScrapeBrowser() is deprecated in favor of stopInteractiveBrowser().
  • No prompt support: Unlike JS/Python/Rust, the Java SDK interact() method only accepts code, not natural-language prompt. Use the code parameter with "bash" language for agent-browser CLI commands.
  • Null handling: All option fields use @JsonInclude(NON_NULL), so null fields are omitted from the request body.

Source Of Truth

  • /firecrawl/apps/java-sdk/src/main/java/com/firecrawl/client/FirecrawlClient.java
  • /firecrawl/apps/java-sdk/src/main/java/com/firecrawl/models/ScrapeOptions.java
  • /firecrawl/apps/java-sdk/src/main/java/com/firecrawl/models/SearchOptions.java
  • /firecrawl-docs/api-reference/v2-openapi.json