Skip to main content

Firecrawl Java Agent Quickstart

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

Install

Maven

Gradle

Authenticate

Or set the FIRECRAWL_API_KEY environment variable:

When To Use What

  • search — Use when you start with a query and need to discover relevant pages. Returns web results, news, images, and optionally scraped page content.
  • scrape — Use when you already have a URL and want structured page content (markdown, HTML, JSON extraction, screenshots, etc.).
  • interact — Use when a page needs browser automation after scraping — clicks, form fills, or post-scrape dynamic content extraction.

Why use it

Search the web for a query and get results with titles, URLs, descriptions, and optionally full page content. Supports filtering by domain, time range, category, and source type.

Preferred SDK method

Example

Parameters

SearchOptions builder methods (all nullable, default null unless noted):

Overloads

  • client.search(query) — Search with defaults.
  • client.search(query, options) — Search with options.
  • client.searchAsync(query, options) — Returns CompletableFuture<SearchData>.

Scrape

Why use it

Scrape a URL and get its content in your chosen format — markdown, HTML, JSON (with schema-based extraction), screenshots, and more. Supports browser actions, caching, proxies, and PDF parsing.

Preferred SDK method

Example

Parameters

ScrapeOptions builder methods (all nullable, default null unless noted):

Overloads

  • client.scrape(url) — Scrape with defaults.
  • client.scrape(url, options) — Scrape with options.
  • client.scrapeAsync(url, options) — Returns CompletableFuture<Document>.

Interact

Why use it

After scraping a page, interact with it in a live browser session — execute code to click buttons, fill forms, navigate, and extract dynamic content.

Preferred SDK method

Example

Parameters

Overloads

  • client.interact(jobId, code) — Execute with defaults (language: "node").
  • client.interact(jobId, code, language, timeout) — Specify language and timeout.
  • client.interact(jobId, code, language, timeout, origin) — Full control.
  • All have corresponding interactAsync(...) variants returning CompletableFuture<BrowserExecuteResponse>.

Stopping an interaction

Call client.stopInteractiveBrowser(jobId) to close the browser session and stop billing.

Notes

  • Deprecated aliases: scrapeExecute → interact, deleteScrapeBrowser → stopInteractiveBrowser. Always use the preferred names.
  • Parameter naming: All parameters use camelCase (Java convention).
  • Builder pattern: ScrapeOptions and SearchOptions use the builder pattern.
  • Package coordinates: com.firecrawl:firecrawl (Maven Central).
  • Constants: Default API URL: https://api.firecrawl.dev, default timeout: 300,000ms, default max retries: 3.
  • Note: The Java SDK interact method requires code as a positional parameter. Natural-language prompt-based interaction is not yet supported in the Java SDK — use code to automate browser actions.

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