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
fix(ruby-sdk): send the SDK origin on crawl, batch scrape and map (#5230)
Erik Engervall1597fd761d24
diff --git a/apps/ruby-sdk/lib/firecrawl/client.rb b/apps/ruby-sdk/lib/firecrawl/client.rbindex 55a7da16e..9d2233763 100644--- a/apps/ruby-sdk/lib/firecrawl/client.rb+++ b/apps/ruby-sdk/lib/firecrawl/client.rb@@ -222,6 +222,7 @@ module Firecrawlbody = { "url" => url }body.merge!(options.to_h) if options+ body["origin"] ||= "ruby-sdk@#{Firecrawl::VERSION}"raw = @http.post("/v2/crawl", body)Models::CrawlResponse.new(raw)end@@ -296,6 +297,7 @@ module Firecrawlbody.merge!(opts_hash)body.merge!(nested) if nestedend+ body["origin"] ||= "ruby-sdk@#{Firecrawl::VERSION}"raw = @http.post("/v2/batch/scrape", body, extra_headers: extra_headers)Models::BatchScrapeResponse.new(raw)end@@ -347,6 +349,7 @@ module Firecrawlbody = { "url" => url }body.merge!(options.to_h) if options+ body["origin"] ||= "ruby-sdk@#{Firecrawl::VERSION}"raw = @http.post("/v2/map", body)data = raw["data"] || rawModels::MapData.new(data)diff --git a/apps/ruby-sdk/test/firecrawl/client_test.rb b/apps/ruby-sdk/test/firecrawl/client_test.rbindex e6098934b..5417dae85 100644--- a/apps/ruby-sdk/test/firecrawl/client_test.rb+++ b/apps/ruby-sdk/test/firecrawl/client_test.rb@@ -508,6 +508,26 @@ class ClientTest < Minitest::Testassert_equal "batch-123", response.idend+ def test_start_calls_send_sdk_origin+ origin = "ruby-sdk@#{Firecrawl::VERSION}"+ stub_request(:post, "#{BASE_URL}/v2/crawl")+ .with(body: hash_including("origin" => origin))+ .to_return(status: 200, body: JSON.generate(id: "crawl-origin"), headers: { "Content-Type" => "application/json" })+ stub_request(:post, "#{BASE_URL}/v2/batch/scrape")+ .with(body: hash_including("origin" => origin, "formats" => ["markdown"]))+ .to_return(status: 200, body: JSON.generate(id: "batch-origin"), headers: { "Content-Type" => "application/json" })+ stub_request(:post, "#{BASE_URL}/v2/map")+ .with(body: hash_including("origin" => origin))+ .to_return(status: 200, body: JSON.generate(data: { links: [] }), headers: { "Content-Type" => "application/json" })++ batch_options = Firecrawl::Models::BatchScrapeOptions.new(+ options: Firecrawl::Models::ScrapeOptions.new(formats: ["markdown"])+ )+ assert_equal "crawl-origin", @client.start_crawl("https://example.com").id+ assert_equal "batch-origin", @client.start_batch_scrape(["https://a.com"], batch_options).id+ assert_empty @client.map("https://example.com").links+ end+def test_batch_scrape_with_idempotency_keystub_request(:post, "#{BASE_URL}/v2/batch/scrape").with(headers: { "x-idempotency-key" => "my-key" })