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:Authenticate
FIRECRAWL_API_KEY environment variable (or firecrawl.apiKey system property):
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.
Search
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
.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
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()andSearchOptions.builder()...build(). Options objects are immutable after construction.ScrapeOptionsalso hastoBuilder()for copying and modifying. - Interact uses overloads — The
interactmethod has three overloads (2-arg, 4-arg, 5-arg) instead of a builder. - Null options are safe — Passing
nullfor the options parameter onscrapeandsearchis explicitly handled. SearchDatauses loose maps —getWeb(),getNews(),getImages()returnList<Map<String, Object>>. Individual result items are not strongly typed.- Deprecated aliases —
scrapeExecute()maps tointeract().deleteScrapeBrowser()maps tostopInteractiveBrowser(). Always use the preferred names. - Async methods — All main methods have
*Asyncvariants returningCompletableFuture, running on the configured executor (defaultForkJoinPool.commonPool()).
Source Of Truth
firecrawl/apps/java-sdk/src/main/java/com/firecrawl/client/FirecrawlClient.javafirecrawl/apps/java-sdk/src/main/java/com/firecrawl/models/ScrapeOptions.javafirecrawl/apps/java-sdk/src/main/java/com/firecrawl/models/SearchOptions.javafirecrawl/apps/java-sdk/build.gradle.ktsfirecrawl-docs/api-reference/v2-openapi.json

