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(dot-net-sdk): add developer search (#5277)
Erik Engervalla4e6748eb20a
diff --git a/apps/dot-net-sdk/Firecrawl.Tests/DeveloperSearchTests.cs b/apps/dot-net-sdk/Firecrawl.Tests/DeveloperSearchTests.csnew file mode 100644index 000000000..3a567e94e--- /dev/null+++ b/apps/dot-net-sdk/Firecrawl.Tests/DeveloperSearchTests.cs@@ -0,0 +1,89 @@+using System.Net;+using System.Text;+using System.Text.Json;+using Firecrawl.Models;+using Xunit;++namespace Firecrawl.Tests;++public class DeveloperSearchTests+{+ private const string ResponseBody =+ "{\"success\":true,\"partial\":false,\"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}}]}";++ private sealed class StubHandler : HttpMessageHandler+ {+ public HttpRequestMessage? Request { get; private set; }++ public string? RequestBody { get; private set; }++ protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)+ {+ Request = request;+ RequestBody = request.Content is null ? null : await request.Content.ReadAsStringAsync(cancellationToken);+ return new HttpResponseMessage(HttpStatusCode.OK)+ {+ Content = new StringContent(ResponseBody, Encoding.UTF8, "application/json"),+ };+ }+ }++ private static FirecrawlClient NewClient(StubHandler handler) =>+ new(apiKey: "fc-test-key", apiUrl: "http://localhost", maxRetries: 0, httpClient: new HttpClient(handler));++ [Fact]+ public async Task DeveloperSearchAsync_PostsQueryAndOptions()+ {+ var handler = new StubHandler();+ var client = NewClient(handler);++ var response = await client.DeveloperSearchAsync("retry backoff", new DeveloperSearchOptions+ {+ K = 5,+ Types = new List<string> { "issue" },+ Repos = new List<string> { "square/okhttp" },+ MinStars = 100,+ });++ Assert.Equal(HttpMethod.Post, handler.Request!.Method);+ Assert.Equal("http://localhost/v2/search/developer", handler.Request.RequestUri!.ToString());+ using var body = JsonDocument.Parse(handler.RequestBody!);+ var root = body.RootElement;+ Assert.Equal("retry backoff", root.GetProperty("query").GetString());+ Assert.Equal(5, root.GetProperty("k").GetInt32());+ Assert.Equal("issue", root.GetProperty("types")[0].GetString());+ Assert.Equal("square/okhttp", root.GetProperty("repos")[0].GetString());+ Assert.Equal(100, root.GetProperty("min_stars").GetInt64());+ Assert.StartsWith("dotnet-sdk@", root.GetProperty("origin").GetString());+ Assert.False(root.TryGetProperty("max_stars", out _));+ Assert.False(root.TryGetProperty("language", out _));++ Assert.True(response.Success);+ Assert.False(response.Partial);+ Assert.Equal(2, response.Results!.Count);+ Assert.Equal("https://github.com/square/okhttp/issues/1#c1", response.Results[0].Passages![0].CitationUrl);+ Assert.Equal("Apache-2.0", response.Results[0].License!.Value.GetProperty("spdx_id").GetString());+ Assert.Equal("Apache-2.0", response.Results[1].License!.Value.GetString());+ Assert.True(response.Repos![0].Indexed);+ Assert.True(response.Repos[0].Types!.PullRequest);+ Assert.Null(response.Sources);+ }++ [Theory]+ [InlineData("")]+ [InlineData(" ")]+ public async Task DeveloperSearchAsync_RejectsBlankQueryBeforeRequest(string query)+ {+ var handler = new StubHandler();+ var client = NewClient(handler);++ await Assert.ThrowsAsync<ArgumentException>(() => client.DeveloperSearchAsync(query));+ Assert.Null(handler.Request);+ }+}diff --git a/apps/dot-net-sdk/Firecrawl/Firecrawl.csproj b/apps/dot-net-sdk/Firecrawl/Firecrawl.csprojindex 86e62ecf5..c1c1ad2f2 100644--- a/apps/dot-net-sdk/Firecrawl/Firecrawl.csproj+++ b/apps/dot-net-sdk/Firecrawl/Firecrawl.csproj@@ -8,7 +8,7 @@<!-- NuGet package metadata --><PackageId>firecrawl-sdk</PackageId>- <Version>1.15.0</Version>+ <Version>1.15.1</Version><Authors>Firecrawl</Authors><Company>Firecrawl</Company><Description>.NET SDK for Firecrawl, the context API for AI agents: search, scrape, parse, crawl, and map the web, and run Monitor jobs.</Description>diff --git a/apps/dot-net-sdk/Firecrawl/FirecrawlClient.cs b/apps/dot-net-sdk/Firecrawl/FirecrawlClient.csindex 291be71f9..9215e3080 100644--- a/apps/dot-net-sdk/Firecrawl/FirecrawlClient.cs+++ b/apps/dot-net-sdk/Firecrawl/FirecrawlClient.cs@@ -626,7 +626,7 @@ public class FirecrawlClient/// <summary>/// Searches GitHub research content./// </summary>- [Obsolete("Stops responding after 2026-11-03. Use the developer index at GET or POST /v2/search/developer; this SDK does not wrap it yet, so call it directly. It does not carry over the score breakdown or the web fallback results.")]+ [Obsolete("Stops responding after 2026-11-03. Use DeveloperSearchAsync, which does not carry over the score breakdown or the web fallback results.")]public async Task<GitHubSearchResponse> SearchGitHubAsync(string query,SearchGitHubOptions? options = null,@@ -644,6 +644,25 @@ public class FirecrawlClientcancellationToken);}+ /// <summary>+ /// Searches the developer index: public repositories, GitHub issues,+ /// merged pull requests, READMEs and code documentation.+ /// </summary>+ /// <exception cref="ArgumentException">The query is blank.</exception>+ public async Task<DeveloperSearchResponse> DeveloperSearchAsync(+ string query,+ DeveloperSearchOptions? options = null,+ CancellationToken cancellationToken = default)+ {+ ArgumentException.ThrowIfNullOrWhiteSpace(query);++ var body = BuildBody(options);+ body["query"] = query;++ return await _http.PostAsync<DeveloperSearchResponse>(+ "/v2/search/developer", body, cancellationToken: cancellationToken);+ }+// ================================================================// AGENT// ================================================================@@ -902,7 +921,7 @@ public class FirecrawlClient// INTERNAL UTILITIES// ================================================================- private const string SdkOrigin = "[email protected]";+ private const string SdkOrigin = "[email protected]";private static Dictionary<string, object> BuildBody(object? options){diff --git a/apps/dot-net-sdk/Firecrawl/Models/ResearchModels.cs b/apps/dot-net-sdk/Firecrawl/Models/ResearchModels.csindex be794f5c2..38d00d717 100644--- a/apps/dot-net-sdk/Firecrawl/Models/ResearchModels.cs+++ b/apps/dot-net-sdk/Firecrawl/Models/ResearchModels.cs@@ -1,3 +1,4 @@+using System.Text.Json;using System.Text.Json.Serialization;namespace Firecrawl.Models;@@ -113,6 +114,60 @@ public class GitHubSearchResponsepublic List<GitHubSearchItem>? Results { get; set; }}+public class DeveloperSearchPassage+{+ public string? Text { get; set; }++ [JsonPropertyName("citation_url")]+ public string? CitationUrl { get; set; }+}++/// <summary>+/// One ranked developer search result. <see cref="License"/> is either an SPDX+/// string or a disclosure object, so it is kept as raw JSON.+/// </summary>+public class DeveloperSearchResult+{+ public string? Id { get; set; }+ public string? Url { get; set; }+ public string? Title { get; set; }+ public List<DeveloperSearchPassage>? Passages { get; set; }+ public JsonElement? License { get; set; }+}++public class DeveloperSearchRepoTypes+{+ public bool Issue { get; set; }+ public bool PullRequest { get; set; }+ public bool Readme { get; set; }+}++public class DeveloperSearchRepoStatus+{+ public string? Repo { get; set; }+ public bool Indexed { get; set; }+ public DeveloperSearchRepoTypes? Types { get; set; }+}++public class DeveloperSearchSourceStatus+{+ public string? Source { get; set; }+ public bool Indexed { get; set; }+}++/// <summary>+/// Response from <c>DeveloperSearchAsync</c>. <see cref="Repos"/> and+/// <see cref="Sources"/> are set only when those filters were requested.+/// </summary>+public class DeveloperSearchResponse+{+ public bool Success { get; set; }+ public bool Partial { get; set; }+ public List<DeveloperSearchResult>? Results { get; set; }+ public List<DeveloperSearchRepoStatus>? Repos { get; set; }+ public List<DeveloperSearchSourceStatus>? Sources { get; set; }+}+public class SearchPapersOptions{public int? K { get; set; }@@ -139,3 +194,42 @@ public class SearchGitHubOptions{public int? K { get; set; }}++public class DeveloperSearchOptions+{+ /// <summary>Total ranked results, 1 to 100 (default 10).</summary>+ public int? K { get; set; }++ /// <summary>Passages per result, 1 to 5 (default 1).</summary>+ public int? Passages { get; set; }++ /// <summary>Result kinds: "doc", "issue", "pull_request", "readme" (default all).</summary>+ public List<string>? Types { get; set; }++ /// <summary>GitHub owner/name filters, at most 20.</summary>+ public List<string>? Repos { get; set; }++ /// <summary>Developer documentation source IDs, at most 20.</summary>+ public List<string>? Sources { get; set; }++ /// <summary>One case-insensitive GitHub Linguist primary language.</summary>+ public string? Language { get; set; }++ /// <summary>Repository topics that must all match, at most 8.</summary>+ public List<string>? Topic { get; set; }++ /// <summary>One case-insensitive SPDX repository license identifier.</summary>+ public string? License { get; set; }++ [JsonPropertyName("min_stars")]+ public long? MinStars { get; set; }++ [JsonPropertyName("max_stars")]+ public long? MaxStars { get; set; }++ public bool? Archived { get; set; }+ public bool? Fork { get; set; }++ /// <summary>"only" returns packaged agent-skill evidence only.</summary>+ public string? Skills { get; set; }+}diff --git a/apps/dot-net-sdk/README.md b/apps/dot-net-sdk/README.mdindex 5368aa59c..25f34bd1a 100644--- a/apps/dot-net-sdk/README.md+++ b/apps/dot-net-sdk/README.md@@ -305,6 +305,25 @@ var results = await client.SearchAsync("firecrawl web scraping",});```+### Developer Search++Search public repositories, GitHub issues, merged pull requests, READMEs and code documentation. `DeveloperSearchAsync` replaces the deprecated `SearchGitHubAsync`.++```csharp+var response = await client.DeveloperSearchAsync("retry an http request with exponential backoff",+ new DeveloperSearchOptions+ {+ K = 5,+ Types = new List<string> { "issue", "pull_request" },+ Repos = new List<string> { "square/okhttp" }+ });++foreach (var result in response.Results!)+{+ Console.WriteLine($"{result.Title} {result.Url}");+}+```+### Usage & Metrics```csharp