Skip to main content

Firecrawl Java Agent Quickstart

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

Install

Maven:
Gradle:

Authenticate

Builder options: A convenience factory FirecrawlClient.fromEnv() reads the API key from the FIRECRAWL_API_KEY env var or firecrawl.apiKey system property.

When To Use What

  • search — Use when you start with a query and need to discover relevant pages. Returns search results grouped by source type, optionally with scraped content.
  • scrape — Use when you already have a URL and want its content. Returns markdown, HTML, structured data, screenshots, or other formats.
  • interact — Use when the page needs post-scrape browser actions like clicking, filling forms, or executing code in the browser sandbox.

Why use it

Search the web and optionally scrape each result in one call. Start here when you have a question or topic but not a specific URL.

Preferred SDK method

Example

Parameters

All fields on SearchOptions are nullable and optional. An async variant is available: client.searchAsync(query, options) returns CompletableFuture<SearchData>.

Scrape

Why use it

Fetch and extract content from a single URL. Use when you have a specific page to read.

Preferred SDK method

Example

Parameters

All fields on ScrapeOptions are nullable and optional. An async variant is available: client.scrapeAsync(url, options) returns CompletableFuture<Document>.

Interact

Why use it

Execute code in the browser sandbox associated with a scrape job. Use after a scrape to click buttons, fill forms, navigate, or extract additional data.

Preferred SDK method

Example

Parameters

Async variants are available: client.interactAsync(...) returns CompletableFuture<BrowserExecuteResponse>.
Stops the interactive browser session and returns billing info as BrowserDeleteResponse.

Notes

  • Naming style: All parameters use camelCase.
  • Builder pattern: ScrapeOptions and SearchOptions use builder pattern (ScrapeOptions.builder()...build()).
  • Deprecated aliases:
    • scrapeExecute() → use interact() instead.
    • deleteScrapeBrowser() → use stopInteractiveBrowser() instead.
  • Async methods: Every sync method has an async counterpart suffixed with Async that returns CompletableFuture<T>.
  • Interact limitations: The Java SDK’s interact method requires code as a string parameter. Unlike the JS and Python SDKs, it does not support a prompt parameter for natural-language browser instructions.

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/apps/java-sdk/build.gradle.kts
  • firecrawl-docs/api-reference/v2-openapi.json