Firecrawl Java Agent Quickstart
This file is the canonical quickstart for external agents integrating with Firecrawl using the Java SDK. It is generated from SDK source and OpenAPI spec.Install
Gradle:Authenticate
FIRECRAWL_API_KEY environment variable:
When To Use What
search: Use when you start with a query and need to discover relevant pages. Returns ranked results with optional scraping of each result.scrape: Use when you already have a URL and want its content in markdown, HTML, JSON, or other formats.interact: Use when a page needs post-scrape browser actions — clicking, filling forms, running code in the browser sandbox.
Search
Why use it
Search the web for a query and get back ranked results. Optionally scrape each result page inline by passingscrapeOptions.
Preferred SDK method
Example
Parameters
All fields onSearchOptions are nullable and set via the builder.
Returns:
SearchData with getWeb(), getNews(), and getImages() lists.
Async variant: searchAsync(query, options) returns CompletableFuture<SearchData>.
Scrape
Why use it
Scrape a single URL and get its content as markdown, HTML, structured JSON, screenshots, or other formats.Preferred SDK method
Example
Parameters
All fields onScrapeOptions are nullable and set via the builder.
Returns:
Document with getters like getMarkdown(), getHtml(), getRawHtml(), getLinks(), getImages(), getScreenshot(), getMetadata(), etc.
Async variant: scrapeAsync(url, options) returns CompletableFuture<Document>.
Interact
Why use it
Execute code in the browser session of a previous scrape job. Use this for clicking buttons, filling forms, navigating multi-step flows, or running arbitrary JavaScript/Python/Bash in the browser sandbox.Preferred SDK method
Example
Parameters
Returns:
BrowserExecuteResponse with isSuccess(), getStdout(), getStderr(), getResult(), getExitCode(), getKilled(), getError().
Async variants: interactAsync(jobId, code), interactAsync(jobId, code, language, timeout), etc.
Stop the session:
Notes
- All parameter names use camelCase (e.g.
onlyMainContent,skipTlsVerification,scrapeOptions). - Options classes use the builder pattern:
ScrapeOptions.builder().formats(...).build(). - All
Booleanoptions use boxedBoolean(not primitiveboolean), so unset fields arenulland omitted from JSON. - The
interactmethod takescodeas a required positionalStringparameter. Thepromptparameter (natural-language browser instruction) is not available in the Java SDK; usecodeinstead. - Every sync method has an
*Asyncvariant returningCompletableFuture. - Deprecated aliases (use the preferred names instead):
scrapeExecute()→interact()deleteScrapeBrowser()→stopInteractiveBrowser()
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-docs/api-reference/v2-openapi.json

