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 the OpenAPI spec.

Install

Maven:
Gradle (Kotlin DSL):
Requires Java 11+.

Authenticate

Or read the key from the FIRECRAWL_API_KEY environment variable (or firecrawl.apiKey system property):
A null/blank API key is allowed — scrape, search, and interact fall back to a keyless free tier (rate-limited per IP). Builder options:

When To Use What

  • search — Use when you start with a query and need discovery. Returns web, news, and image results with optional scraping of each result.
  • scrape — Use when you already have a URL and want page content (markdown, HTML, screenshots, structured JSON, etc.).
  • interact — Use when the page needs clicks, form fills, or post-scrape browser actions. Runs code against an active browser session.

Why use it

Search the web with a query and get back structured results. Optionally scrape each result page inline. Useful for discovery, research, and finding relevant URLs before scraping them in detail.

Preferred SDK method

Example

Results are grouped under .getWeb(), .getNews(), and .getImages(). Each element is a Map<String, Object>.

Parameters

SearchOptions (built via SearchOptions.builder()): Async variant: client.searchAsync(query, options) returns CompletableFuture<SearchData>.

Scrape

Why use it

Fetch a single URL and get back structured page data — markdown, HTML, screenshots, extracted JSON, and more. The workhorse endpoint for turning a known URL into usable content.

Preferred SDK method

Example

Passing null for options uses defaults.

Parameters

ScrapeOptions (built via ScrapeOptions.builder()): Async variant: client.scrapeAsync(url, options) returns CompletableFuture<Document>.

Interact

Why use it

Run code against an active browser session tied to a scrape job. Use it for clicking buttons, filling forms, navigating multi-step flows, or extracting data that requires browser interaction after the initial scrape.

Preferred SDK method

Example

Parameters

The method uses positional overloads (not a builder): Async variants: client.interactAsync(jobId, code) and overloads return CompletableFuture<BrowserExecuteResponse>.

Stopping a session

Notes

  • Builder pattern — All options use ScrapeOptions.builder()...build() and SearchOptions.builder()...build(). Options objects are immutable after construction. ScrapeOptions also has toBuilder() for copying and modifying.
  • Interact uses overloads — The interact method has three overloads (2-arg, 4-arg, 5-arg) instead of a builder.
  • Null options are safe — Passing null for the options parameter on scrape and search is explicitly handled.
  • SearchData uses loose mapsgetWeb(), getNews(), getImages() return List<Map<String, Object>>. Individual result items are not strongly typed.
  • Deprecated aliasesscrapeExecute() maps to interact(). deleteScrapeBrowser() maps to stopInteractiveBrowser(). Always use the preferred names.
  • Async methods — All main methods have *Async variants returning CompletableFuture, running on the configured executor (default ForkJoinPool.commonPool()).

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