Skip to main content

Firecrawl Java Agent Quickstart

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

Install

Gradle:
Maven:

Authenticate

Or read the API key from the FIRECRAWL_API_KEY environment variable:
A null or blank key uses the keyless free tier (rate-limited per IP). Builder options:

When To Use What

  • search: Use when you start with a query and need to discover relevant pages. Returns ranked results with optional scraping of each result.
  • scrape: Use when you already have a URL and want its content in markdown, HTML, JSON, or other formats.
  • interact: Use when a page needs post-scrape browser actions — clicking, filling forms, running code in the browser sandbox.

Why use it

Search the web for a query and get back ranked results. Optionally scrape each result page inline by passing scrapeOptions.

Preferred SDK method

Example

Parameters

All fields on SearchOptions are nullable and set via the builder. Returns: SearchData with getWeb(), getNews(), and getImages() lists. Async variant: searchAsync(query, options) returns CompletableFuture<SearchData>.

Scrape

Why use it

Scrape a single URL and get its content as markdown, HTML, structured JSON, screenshots, or other formats.

Preferred SDK method

Example

Parameters

All fields on ScrapeOptions are nullable and set via the builder. Returns: Document with getters like getMarkdown(), getHtml(), getRawHtml(), getLinks(), getImages(), getScreenshot(), getMetadata(), etc. Async variant: scrapeAsync(url, options) returns CompletableFuture<Document>.

Interact

Why use it

Execute code in the browser session of a previous scrape job. Use this for clicking buttons, filling forms, navigating multi-step flows, or running arbitrary JavaScript/Python/Bash in the browser sandbox.

Preferred SDK method

Example

Parameters

Returns: BrowserExecuteResponse with isSuccess(), getStdout(), getStderr(), getResult(), getExitCode(), getKilled(), getError(). Async variants: interactAsync(jobId, code), interactAsync(jobId, code, language, timeout), etc. Stop the session:

Notes

  • All parameter names use camelCase (e.g. onlyMainContent, skipTlsVerification, scrapeOptions).
  • Options classes use the builder pattern: ScrapeOptions.builder().formats(...).build().
  • All Boolean options use boxed Boolean (not primitive boolean), so unset fields are null and omitted from JSON.
  • The interact method takes code as a required positional String parameter. The prompt parameter (natural-language browser instruction) is not available in the Java SDK; use code instead.
  • Every sync method has an *Async variant returning CompletableFuture.
  • Deprecated aliases (use the preferred names instead):
    • scrapeExecute()interact()
    • deleteScrapeBrowser()stopInteractiveBrowser()

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