Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥
TypeScript aiai-agentsai-crawlerai-scrapingai-searchcrawlerdata-extractionhtml-to-markdownllmmarkdownscraperscrapingweb-crawlerweb-dataweb-data-extractionweb-scraperweb-scrapingweb-searchwebscraping
feat(java-sdk): add developerSearch (#5271)
Erik Engervalld7c85c30c700
diff --git a/apps/java-sdk/README.md b/apps/java-sdk/README.mdindex 4d28368d6..66d5e2597 100644--- a/apps/java-sdk/README.md+++ b/apps/java-sdk/README.md@@ -82,13 +82,13 @@ Before using the Java SDK, ensure you have the following installed:### Gradle (Kotlin DSL)```kotlin-implementation("com.firecrawl:firecrawl-java:1.16.0")+implementation("com.firecrawl:firecrawl-java:1.18.7")```### Gradle (Groovy)```groovy-implementation 'com.firecrawl:firecrawl-java:1.16.0'+implementation 'com.firecrawl:firecrawl-java:1.18.7'```### Maven@@ -97,7 +97,7 @@ implementation 'com.firecrawl:firecrawl-java:1.16.0'<dependency><groupId>com.firecrawl</groupId><artifactId>firecrawl-java</artifactId>- <version>1.16.0</version>+ <version>1.18.7</version></dependency>```@@ -350,6 +350,26 @@ if (results.getWeb() != null) {}```+### Developer Search++Search public repositories, GitHub issues, merged pull requests, READMEs and code documentation. `developerSearch` replaces the deprecated `searchGitHub`.++```java+import com.firecrawl.models.ResearchModels;++ResearchModels.DeveloperSearchOptions options = new ResearchModels.DeveloperSearchOptions();+options.k = 5;+options.types = List.of("issue", "pull_request");+options.repos = List.of("square/okhttp");++ResearchModels.DeveloperSearchResponse response =+ client.developerSearch("retry an http request with exponential backoff", options);++for (ResearchModels.DeveloperSearchResult result : response.results) {+ System.out.println(result.title + " " + result.url);+}+```+### AgentRun an AI-powered agent to research and extract data from the web.@@ -458,14 +478,14 @@ gradle build```bashgradle jar-# Output: build/libs/firecrawl-java-1.16.0.jar+# Output: build/libs/firecrawl-java-1.18.7.jar```### Install Locally```bashgradle publishToMavenLocal-# Now available as: com.firecrawl:firecrawl-java:1.16.0 in local Maven repository+# Now available as: com.firecrawl:firecrawl-java:1.18.7 in local Maven repository```## Running Testsdiff --git a/apps/java-sdk/build.gradle.kts b/apps/java-sdk/build.gradle.ktsindex a765cb938..2b46f856a 100644--- a/apps/java-sdk/build.gradle.kts+++ b/apps/java-sdk/build.gradle.kts@@ -4,7 +4,7 @@ plugins {}group = "com.firecrawl"-version = "1.18.6"+version = "1.18.7"java {sourceCompatibility = JavaVersion.VERSION_11diff --git a/apps/java-sdk/src/main/java/com/firecrawl/client/FirecrawlClient.java b/apps/java-sdk/src/main/java/com/firecrawl/client/FirecrawlClient.javaindex a0a27df63..bf591ec89 100644--- a/apps/java-sdk/src/main/java/com/firecrawl/client/FirecrawlClient.java+++ b/apps/java-sdk/src/main/java/com/firecrawl/client/FirecrawlClient.java@@ -37,7 +37,7 @@ import java.util.concurrent.ForkJoinPool;public class FirecrawlClient {private static final String DEFAULT_API_URL = "https://api.firecrawl.dev";- private static final String SDK_ORIGIN = "[email protected]";+ private static final String SDK_ORIGIN = "[email protected]";private static final long DEFAULT_TIMEOUT_MS = 300_000; // 5 minutesprivate static final int DEFAULT_MAX_RETRIES = 3;private static final double DEFAULT_BACKOFF_FACTOR = 0.5;@@ -648,10 +648,9 @@ public class FirecrawlClient {}/**- * @deprecated Stops responding after 2026-11-03. Use the developer index at- * GET or POST /v2/search/developer, which this SDK does not wrap- * yet, so call it directly. It does not carry over the score- * breakdown or the web fallback results.+ * @deprecated Stops responding after 2026-11-03. Use {@link #developerSearch},+ * which does not carry over the score breakdown or the web+ * fallback results.*/@Deprecatedpublic ResearchModels.GitHubSearchResponse searchGitHub(String query) {@@ -659,10 +658,9 @@ public class FirecrawlClient {}/**- * @deprecated Stops responding after 2026-11-03. Use the developer index at- * GET or POST /v2/search/developer, which this SDK does not wrap- * yet, so call it directly. It does not carry over the score- * breakdown or the web fallback results.+ * @deprecated Stops responding after 2026-11-03. Use {@link #developerSearch},+ * which does not carry over the score breakdown or the web+ * fallback results.*/@Deprecatedpublic ResearchModels.GitHubSearchResponse searchGitHub(String query, ResearchModels.SearchGitHubOptions options) {@@ -674,6 +672,37 @@ public class FirecrawlClient {return http.get("/v2/search/research/github" + researchQuery(params), ResearchModels.GitHubSearchResponse.class);}+ /**+ * Searches the developer index: public repositories, GitHub issues, merged+ * pull requests, READMEs and code documentation.+ *+ * @param query the search query+ * @return ranked developer search results+ */+ public ResearchModels.DeveloperSearchResponse developerSearch(String query) {+ return developerSearch(query, null);+ }++ /**+ * Searches the developer index with filters.+ *+ * @param query the search query+ * @param options developer search filters+ * @return ranked developer search results+ * @throws IllegalArgumentException if the query is blank+ */+ public ResearchModels.DeveloperSearchResponse developerSearch(String query, ResearchModels.DeveloperSearchOptions options) {+ Objects.requireNonNull(query, "Query is required");+ if (query.isBlank()) {+ throw new IllegalArgumentException("Query cannot be empty");+ }+ Map<String, Object> body = new LinkedHashMap<>();+ body.put("query", query);+ if (options != null) mergeOptions(body, options);+ body.put("origin", SDK_ORIGIN);+ return http.post("/v2/search/developer", body, ResearchModels.DeveloperSearchResponse.class);+ }+// ================================================================// AGENT// ================================================================@@ -1141,16 +1170,19 @@ public class FirecrawlClient {}/**- * @deprecated Stops responding after 2026-11-03. Use the developer index at- * GET or POST /v2/search/developer, which this SDK does not wrap- * yet, so call it directly. It does not carry over the score- * breakdown or the web fallback results.+ * @deprecated Stops responding after 2026-11-03. Use {@link #developerSearch},+ * which does not carry over the score breakdown or the web+ * fallback results.*/@Deprecatedpublic CompletableFuture<ResearchModels.GitHubSearchResponse> searchGitHubAsync(String query, ResearchModels.SearchGitHubOptions options) {return CompletableFuture.supplyAsync(() -> searchGitHub(query, options), asyncExecutor);}+ public CompletableFuture<ResearchModels.DeveloperSearchResponse> developerSearchAsync(String query, ResearchModels.DeveloperSearchOptions options) {+ return CompletableFuture.supplyAsync(() -> developerSearch(query, options), asyncExecutor);+ }+/*** Asynchronously runs a map operation.*diff --git a/apps/java-sdk/src/main/java/com/firecrawl/models/ResearchModels.java b/apps/java-sdk/src/main/java/com/firecrawl/models/ResearchModels.javaindex 6243119c1..5b19645d4 100644--- a/apps/java-sdk/src/main/java/com/firecrawl/models/ResearchModels.java+++ b/apps/java-sdk/src/main/java/com/firecrawl/models/ResearchModels.java@@ -1,5 +1,6 @@package com.firecrawl.models;+import com.fasterxml.jackson.annotation.JsonInclude;import com.fasterxml.jackson.annotation.JsonProperty;import java.util.List;import java.util.Map;@@ -116,4 +117,74 @@ public final class ResearchModels {public static class SearchGitHubOptions {public Integer k;}++ /** Options for {@code developerSearch}. Unset fields are omitted from the request. */+ @JsonInclude(JsonInclude.Include.NON_NULL)+ public static class DeveloperSearchOptions {+ /** Total ranked results, 1 to 100 (default 10). */+ public Integer k;+ /** Passages per result, 1 to 5 (default 1). */+ public Integer passages;+ /** Result kinds: "doc", "issue", "pull_request", "readme" (default all). */+ public List<String> types;+ /** GitHub owner/name filters, at most 20. */+ public List<String> repos;+ /** Developer documentation source IDs, at most 20. */+ public List<String> sources;+ /** One case-insensitive GitHub Linguist primary language. */+ public String language;+ /** Repository topics that must all match, at most 8. */+ public List<String> topic;+ /** One case-insensitive SPDX repository license identifier. */+ public String license;+ @JsonProperty("min_stars")+ public Long minStars;+ @JsonProperty("max_stars")+ public Long maxStars;+ public Boolean archived;+ public Boolean fork;+ /** "only" returns packaged agent-skill evidence only. */+ public String skills;+ }++ public static class DeveloperSearchPassage {+ public String text;+ @JsonProperty("citation_url")+ public String citationUrl;+ }++ /** One ranked developer search result. {@code license} is an SPDX string or a disclosure map. */+ public static class DeveloperSearchResult {+ public String id;+ public String url;+ public String title;+ public List<DeveloperSearchPassage> passages;+ public Object license;+ }++ public static class DeveloperSearchRepoTypes {+ public boolean issue;+ @JsonProperty("pullRequest")+ public boolean pullRequest;+ public boolean readme;+ }++ public static class DeveloperSearchRepoStatus {+ public String repo;+ public boolean indexed;+ public DeveloperSearchRepoTypes types;+ }++ public static class DeveloperSearchSourceStatus {+ public String source;+ public boolean indexed;+ }++ /** Response from {@code developerSearch}. {@code repos} and {@code sources} are set only when those filters were requested. */+ public static class DeveloperSearchResponse {+ public boolean success;+ public List<DeveloperSearchResult> results;+ public List<DeveloperSearchRepoStatus> repos;+ public List<DeveloperSearchSourceStatus> sources;+ }}diff --git a/apps/java-sdk/src/test/java/com/firecrawl/DeveloperSearchMockTest.java b/apps/java-sdk/src/test/java/com/firecrawl/DeveloperSearchMockTest.javanew file mode 100644index 000000000..96e41d31e--- /dev/null+++ b/apps/java-sdk/src/test/java/com/firecrawl/DeveloperSearchMockTest.java@@ -0,0 +1,113 @@+package com.firecrawl;++import com.firecrawl.client.FirecrawlClient;+import com.firecrawl.models.ResearchModels;+import com.sun.net.httpserver.HttpServer;+import org.junit.jupiter.api.AfterEach;+import org.junit.jupiter.api.BeforeEach;+import org.junit.jupiter.api.Test;++import java.io.IOException;+import java.io.OutputStream;+import java.net.InetSocketAddress;+import java.nio.charset.StandardCharsets;+import java.util.List;+import java.util.Map;+import java.util.concurrent.CompletionException;+import java.util.concurrent.atomic.AtomicReference;++import static org.junit.jupiter.api.Assertions.*;++class DeveloperSearchMockTest {++ private HttpServer server;+ private FirecrawlClient client;+ private final AtomicReference<String> requestLine = new AtomicReference<>();+ private final AtomicReference<String> requestBody = new AtomicReference<>();++ @BeforeEach+ void setup() throws IOException {+ server = HttpServer.create(new InetSocketAddress("127.0.0.1", 0), 0);+ server.createContext("/", exchange -> {+ requestLine.set(exchange.getRequestMethod() + " " + exchange.getRequestURI().getPath());+ requestBody.set(new String(exchange.getRequestBody().readAllBytes(), StandardCharsets.UTF_8));+ byte[] bytes = ("{\"success\":true,\"results\":[{\"id\":\"r1\","+ + "\"url\":\"https://github.com/square/okhttp/issues/1\",\"title\":\"retry\","+ + "\"passages\":[{\"text\":\"use backoff\",\"citation_url\":\"https://github.com/square/okhttp/issues/1#c1\"}],"+ + "\"license\":{\"state\":\"licensed\",\"spdx_id\":\"Apache-2.0\"}},"+ + "{\"id\":\"r2\",\"url\":\"https://github.com/square/okhttp\",\"passages\":[],\"license\":\"Apache-2.0\"}],"+ + "\"repos\":[{\"repo\":\"square/okhttp\",\"indexed\":true,"+ + "\"types\":{\"issue\":true,\"pullRequest\":true,\"readme\":false}}]}")+ .getBytes(StandardCharsets.UTF_8);+ exchange.getResponseHeaders().set("Content-Type", "application/json");+ exchange.sendResponseHeaders(200, bytes.length);+ try (OutputStream os = exchange.getResponseBody()) {+ os.write(bytes);+ }+ });+ server.start();+ client = FirecrawlClient.builder()+ .apiKey("fc-test-key")+ .apiUrl("http://127.0.0.1:" + server.getAddress().getPort())+ .maxRetries(0)+ .build();+ }++ @AfterEach+ void teardown() {+ server.stop(0);+ }++ @Test+ void developerSearchPostsQueryAndOptions() {+ ResearchModels.DeveloperSearchOptions options = new ResearchModels.DeveloperSearchOptions();+ options.k = 5;+ options.types = List.of("issue");+ options.repos = List.of("square/okhttp");+ options.minStars = 100L;++ ResearchModels.DeveloperSearchResponse response = client.developerSearch("retry backoff", options);++ assertEquals("POST /v2/search/developer", requestLine.get());+ String body = requestBody.get();+ for (String want : List.of("\"query\":\"retry backoff\"", "\"k\":5", "\"types\":[\"issue\"]",+ "\"repos\":[\"square/okhttp\"]", "\"min_stars\":100", "\"origin\":\"java-sdk@")) {+ assertTrue(body.contains(want), "request body missing " + want + ": " + body);+ }+ assertFalse(body.contains("null"), "unset options must be omitted: " + body);++ assertTrue(response.success);+ assertEquals(2, response.results.size());+ assertEquals("https://github.com/square/okhttp/issues/1#c1", response.results.get(0).passages.get(0).citationUrl);+ assertEquals("Apache-2.0", ((Map<?, ?>) response.results.get(0).license).get("spdx_id"));+ assertEquals("Apache-2.0", response.results.get(1).license);+ assertTrue(response.repos.get(0).indexed);+ assertTrue(response.repos.get(0).types.pullRequest);+ assertNull(response.sources);+ }++ @Test+ void developerSearchAsyncPostsQuery() {+ ResearchModels.DeveloperSearchResponse response = client.developerSearchAsync("okhttp interceptor", null).join();++ assertEquals("POST /v2/search/developer", requestLine.get());+ assertTrue(requestBody.get().contains("\"query\":\"okhttp interceptor\""), requestBody.get());+ assertTrue(response.success);+ assertEquals(2, response.results.size());+ }++ @Test+ void developerSearchAsyncFailsOnBlankQuery() {+ CompletionException error = assertThrows(CompletionException.class,+ () -> client.developerSearchAsync(" ", null).join());+ assertInstanceOf(IllegalArgumentException.class, error.getCause());+ assertNull(requestLine.get());+ }++ @Test+ void developerSearchRejectsBlankQuery() {+ assertThrows(IllegalArgumentException.class, () -> client.developerSearch(" "));+ assertThrows(NullPointerException.class, () -> client.developerSearch(null));+ assertNull(requestLine.get());+ }+}