Skip to main content

Firecrawl Java Agent Quickstart

Canonical quickstart for external agents integrating Firecrawl with Java. Generated from SDK source and OpenAPI spec.

Install

Maven:
Gradle:

Authenticate

Or read from the FIRECRAWL_API_KEY environment variable:
Builder options:

When To Use What

  • search: Start with a query, discover relevant URLs, and get their content in one call.
  • scrape: You already have a URL and want its page content as markdown, HTML, JSON, or other formats.
  • interact: The page needs clicks, form fills, or post-scrape browser actions on a live session.

Why use it

Search the web for a query and get scraped content from the top results. Combines discovery and content extraction in one call.

Preferred SDK method

client.search(query) or client.search(query, options)

Example

Parameters

All fields on SearchOptions are nullable and default to null (API defaults apply). Response fields: results.getWeb(), results.getNews(), results.getImages() each return List<Map<String, Object>>.

Scrape

Why use it

Get the content of a single URL as markdown, HTML, JSON, screenshots, or other formats.

Preferred SDK method

client.scrape(url) or client.scrape(url, options)

Example

Parameters

All fields on ScrapeOptions are nullable and default to null (API defaults apply). Async variant: client.scrapeAsync(url, options) returns CompletableFuture<Document>.

Interact

Why use it

Control a live browser session tied to a scrape job. Execute code in the browser sandbox to click buttons, fill forms, navigate, and extract dynamic content.

Preferred SDK method

client.interact(jobId, code) or client.interact(jobId, code, language, timeout)

Example

Parameters

Stop the session when done:
Async variants: client.interactAsync(...) and client.stopInteractiveBrowserAsync(...) return CompletableFuture.

Notes

  • Parameter names use camelCase (e.g. onlyMainContent, includeTags, scrapeOptions).
  • All option classes use the builder pattern: ScrapeOptions.builder().field(value).build().
  • The Java interact method requires code — it does not support a prompt parameter. Use the code parameter with JavaScript to control the browser.
  • includeDomains and excludeDomains on search are mutually exclusive.
  • Deprecated aliases (do not use in new code):
    • scrapeExecute(...) → use interact(...)
    • deleteScrapeBrowser(...) → use 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/apps/java-sdk/build.gradle.kts
  • firecrawl-docs/api-reference/v2-openapi.json