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(rust-sdk): tag agent/crawl/batch/map/parse requests with SDK origin
mogeryb823457de066
diff --git a/apps/rust-sdk/CHANGELOG.md b/apps/rust-sdk/CHANGELOG.mdindex 4a1853b4f..ac2fa6914 100644--- a/apps/rust-sdk/CHANGELOG.md+++ b/apps/rust-sdk/CHANGELOG.md@@ -1,5 +1,15 @@## CHANGELOG+## [2.16.1] - 2026-08-26++### Fixed++- Agent, crawl, batch scrape, map, and parse requests now send+ `origin: "rust-sdk@<version>"` for request attribution, matching the other+ SDKs. Agent requests previously sent no origin at all, which made them+ indistinguishable from raw API traffic server-side. A caller-provided+ `origin` is still respected.+## [2.16.0] - 2026-08-21### Addeddiff --git a/apps/rust-sdk/Cargo.lock b/apps/rust-sdk/Cargo.lockindex 1aa48bbb1..8e1ffe827 100644--- a/apps/rust-sdk/Cargo.lock+++ b/apps/rust-sdk/Cargo.lock@@ -250,7 +250,7 @@ checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be"[[package]]name = "firecrawl"-version = "2.16.0"+version = "2.16.1"dependencies = ["mockito","reqwest",diff --git a/apps/rust-sdk/Cargo.toml b/apps/rust-sdk/Cargo.tomlindex a5b664721..874e495e8 100644--- a/apps/rust-sdk/Cargo.toml+++ b/apps/rust-sdk/Cargo.toml@@ -1,6 +1,6 @@[package]name = "firecrawl"-version = "2.16.0"+version = "2.16.1"edition = "2021"license = "MIT"homepage = "https://www.firecrawl.dev/"diff --git a/apps/rust-sdk/src/agent.rs b/apps/rust-sdk/src/agent.rsindex 5830225ca..789235868 100644--- a/apps/rust-sdk/src/agent.rs+++ b/apps/rust-sdk/src/agent.rs@@ -26,6 +26,10 @@ pub struct AgentOptions {/// Integration identifier for tracking.pub integration: Option<String>,+ /// Origin label for request attribution (e.g., "[email protected]").+ /// Defaults to `rust-sdk@<version>` when unset.+ pub origin: Option<String>,+/// Maximum credits the agent can use.pub max_credits: Option<u32>,@@ -135,6 +139,11 @@ impl Client {&self,options: AgentOptions,) -> Result<AgentResponse, FirecrawlError> {+ let mut options = options;+ if options.origin.is_none() {+ options.origin = Some(format!("rust-sdk@{}", env!("CARGO_PKG_VERSION")));+ }+let headers = self.prepare_headers(None);let response = self@@ -431,6 +440,7 @@ impl Client {#[cfg(test)]mod tests {use super::*;+ use mockito::Matcher;use serde_json::json;#[tokio::test]@@ -464,6 +474,59 @@ mod tests {mock.assert();}+ #[tokio::test]+ async fn test_start_agent_injects_sdk_origin() {+ let mut server = mockito::Server::new_async().await;++ // The mock only matches when the request body carries the SDK origin,+ // so a regression in the injection fails the request itself.+ let mock = server+ .mock("POST", "/v2/agent")+ .match_body(Matcher::PartialJson(json!({+ "origin": format!("rust-sdk@{}", env!("CARGO_PKG_VERSION"))+ })))+ .with_status(200)+ .with_header("content-type", "application/json")+ .with_body(json!({"success": true, "id": "agent-123"}).to_string())+ .create();++ let client = Client::new_selfhosted(server.url(), Some("test_key")).unwrap();+ let options = AgentOptions {+ prompt: "Find the contact information".to_string(),+ ..Default::default()+ };++ let response = client.start_agent(options).await.unwrap();++ assert!(response.success);+ mock.assert();+ }++ #[tokio::test]+ async fn test_start_agent_preserves_custom_origin() {+ let mut server = mockito::Server::new_async().await;++ let mock = server+ .mock("POST", "/v2/agent")+ .match_body(Matcher::PartialJson(json!({"origin": "[email protected]"})))+ .with_status(200)+ .with_header("content-type", "application/json")+ .with_body(json!({"success": true, "id": "agent-123"}).to_string())+ .create();++ let client = Client::new_selfhosted(server.url(), Some("test_key")).unwrap();+ let options = AgentOptions {+ prompt: "Find the contact information".to_string(),+ origin: Some("[email protected]".to_string()),+ ..Default::default()+ };++ let response = client.start_agent(options).await.unwrap();++ assert!(response.success);+ mock.assert();+ }+#[tokio::test]async fn test_get_agent_status_with_mock() {let mut server = mockito::Server::new_async().await;diff --git a/apps/rust-sdk/src/batch_scrape.rs b/apps/rust-sdk/src/batch_scrape.rsindex 6a6ad8f35..84d0d30c6 100644--- a/apps/rust-sdk/src/batch_scrape.rs+++ b/apps/rust-sdk/src/batch_scrape.rs@@ -39,6 +39,10 @@ pub struct BatchScrapeOptions {/// Integration identifier for tracking.pub integration: Option<String>,+ /// Origin label for request attribution (e.g., "[email protected]").+ /// Defaults to `rust-sdk@<version>` when unset.+ pub origin: Option<String>,+/// Poll interval for synchronous batch scrape (milliseconds).#[serde(skip)]pub poll_interval: Option<u64>,@@ -132,7 +136,10 @@ impl Client {urls: Vec<String>,options: impl Into<Option<BatchScrapeOptions>>,) -> Result<BatchScrapeResponse, FirecrawlError> {- let options = options.into().unwrap_or_default();+ let mut options = options.into().unwrap_or_default();+ if options.origin.is_none() {+ options.origin = Some(format!("rust-sdk@{}", env!("CARGO_PKG_VERSION")));+ }let body = BatchScrapeRequest {urls,options: options.clone(),@@ -372,6 +379,7 @@ impl Client {#[cfg(test)]mod tests {use super::*;+ use mockito::Matcher;use serde_json::json;#[tokio::test]@@ -405,6 +413,38 @@ mod tests {mock.assert();}+ #[tokio::test]+ async fn test_start_batch_scrape_injects_sdk_origin() {+ let mut server = mockito::Server::new_async().await;++ // The mock only matches when the request body carries the SDK origin,+ // so a regression in the injection fails the request itself.+ let mock = server+ .mock("POST", "/v2/batch/scrape")+ .match_body(Matcher::PartialJson(json!({+ "origin": format!("rust-sdk@{}", env!("CARGO_PKG_VERSION"))+ })))+ .with_status(200)+ .with_header("content-type", "application/json")+ .with_body(+ json!({+ "success": true,+ "id": "batch-123",+ "url": "https://api.firecrawl.dev/v2/batch/scrape/batch-123"+ })+ .to_string(),+ )+ .create();++ let client = Client::new_selfhosted(server.url(), Some("test_key")).unwrap();+ let urls = vec!["https://example.com".to_string()];++ let response = client.start_batch_scrape(urls, None).await.unwrap();++ assert!(response.success);+ mock.assert();+ }+#[tokio::test]async fn test_get_batch_scrape_status_with_mock() {let mut server = mockito::Server::new_async().await;diff --git a/apps/rust-sdk/src/crawl.rs b/apps/rust-sdk/src/crawl.rsindex f849b0922..e9c8fba2b 100644--- a/apps/rust-sdk/src/crawl.rs+++ b/apps/rust-sdk/src/crawl.rs@@ -60,6 +60,10 @@ pub struct CrawlOptions {/// Integration identifier for tracking.pub integration: Option<String>,+ /// Origin label for request attribution (e.g., "[email protected]").+ /// Defaults to `rust-sdk@<version>` when unset.+ pub origin: Option<String>,+/// Idempotency key for the request.#[serde(skip)]pub idempotency_key: Option<String>,@@ -157,7 +161,10 @@ impl Client {url: impl AsRef<str>,options: impl Into<Option<CrawlOptions>>,) -> Result<CrawlResponse, FirecrawlError> {- let options = options.into().unwrap_or_default();+ let mut options = options.into().unwrap_or_default();+ if options.origin.is_none() {+ options.origin = Some(format!("rust-sdk@{}", env!("CARGO_PKG_VERSION")));+ }let body = CrawlRequest {url: url.as_ref().to_string(),options: options.clone(),@@ -419,6 +426,7 @@ impl Client {#[cfg(test)]mod tests {use super::*;+ use mockito::Matcher;use serde_json::json;#[tokio::test]@@ -450,6 +458,39 @@ mod tests {mock.assert();}+ #[tokio::test]+ async fn test_start_crawl_injects_sdk_origin() {+ let mut server = mockito::Server::new_async().await;++ // The mock only matches when the request body carries the SDK origin,+ // so a regression in the injection fails the request itself.+ let mock = server+ .mock("POST", "/v2/crawl")+ .match_body(Matcher::PartialJson(json!({+ "origin": format!("rust-sdk@{}", env!("CARGO_PKG_VERSION"))+ })))+ .with_status(200)+ .with_header("content-type", "application/json")+ .with_body(+ json!({+ "success": true,+ "id": "crawl-123",+ "url": "https://api.firecrawl.dev/v2/crawl/crawl-123"+ })+ .to_string(),+ )+ .create();++ let client = Client::new_selfhosted(server.url(), Some("test_key")).unwrap();+ let response = client+ .start_crawl("https://example.com", None)+ .await+ .unwrap();++ assert!(response.success);+ mock.assert();+ }+#[tokio::test]async fn test_get_crawl_status_with_mock() {let mut server = mockito::Server::new_async().await;diff --git a/apps/rust-sdk/src/map.rs b/apps/rust-sdk/src/map.rsindex a49b10f8b..04f25f90c 100644--- a/apps/rust-sdk/src/map.rs+++ b/apps/rust-sdk/src/map.rs@@ -31,6 +31,10 @@ pub struct MapOptions {/// Integration identifier for tracking.pub integration: Option<String>,+ /// Origin label for request attribution (e.g., "[email protected]").+ /// Defaults to `rust-sdk@<version>` when unset.+ pub origin: Option<String>,+/// Location configuration for proxy routing.pub location: Option<LocationConfig>,@@ -108,9 +112,13 @@ impl Client {url: impl AsRef<str>,options: impl Into<Option<MapOptions>>,) -> Result<MapResponse, FirecrawlError> {+ let mut options = options.into().unwrap_or_default();+ if options.origin.is_none() {+ options.origin = Some(format!("rust-sdk@{}", env!("CARGO_PKG_VERSION")));+ }let body = MapRequest {url: url.as_ref().to_string(),- options: options.into().unwrap_or_default(),+ options,};let headers = self.prepare_headers(None);@@ -170,6 +178,7 @@ impl Client {#[cfg(test)]mod tests {use super::*;+ use mockito::Matcher;use serde_json::json;#[tokio::test]@@ -212,6 +221,29 @@ mod tests {mock.assert();}+ #[tokio::test]+ async fn test_map_injects_sdk_origin() {+ let mut server = mockito::Server::new_async().await;++ // The mock only matches when the request body carries the SDK origin,+ // so a regression in the injection fails the request itself.+ let mock = server+ .mock("POST", "/v2/map")+ .match_body(Matcher::PartialJson(json!({+ "origin": format!("rust-sdk@{}", env!("CARGO_PKG_VERSION"))+ })))+ .with_status(200)+ .with_header("content-type", "application/json")+ .with_body(json!({"success": true, "links": []}).to_string())+ .create();++ let client = Client::new_selfhosted(server.url(), Some("test_key")).unwrap();+ let response = client.map("https://example.com", None).await.unwrap();++ assert!(response.success);+ mock.assert();+ }+#[tokio::test]async fn test_map_with_options() {let mut server = mockito::Server::new_async().await;diff --git a/apps/rust-sdk/src/parse.rs b/apps/rust-sdk/src/parse.rsindex 714cf1e23..4e7fc26c6 100644--- a/apps/rust-sdk/src/parse.rs+++ b/apps/rust-sdk/src/parse.rs@@ -134,7 +134,8 @@ pub struct ParseOptions {pub redact_pii: Option<bool>,/// User attribution to include with SIEM logging events.pub audit_metadata: Option<AuditMetadata>,- /// Request origin identifier.+ /// Origin label for request attribution (e.g., "[email protected]").+ /// Defaults to `rust-sdk@<version>` when unset.pub origin: Option<String>,/// Zero data retention mode.pub zero_data_retention: Option<bool>,@@ -164,7 +165,10 @@ impl Client {));}- let options = options.into().unwrap_or_default();+ let mut options = options.into().unwrap_or_default();+ if options.origin.is_none() {+ options.origin = Some(format!("rust-sdk@{}", env!("CARGO_PKG_VERSION")));+ }let options_json =serde_json::to_string(&options).map_err(FirecrawlError::ResponseParseError)?;@@ -234,6 +238,45 @@ mod tests {mock.assert();}+ #[tokio::test]+ async fn test_parse_injects_sdk_origin() {+ let mut server = mockito::Server::new_async().await;++ // The options travel as a JSON text field inside the multipart body;+ // the mock only matches when that JSON carries the SDK origin, so a+ // regression in the injection fails the request itself.+ let mock = server+ .mock("POST", "/v2/parse")+ .match_body(Matcher::Regex(format!(+ "\"origin\":\"rust-sdk@{}\"",+ env!("CARGO_PKG_VERSION")+ )))+ .with_status(200)+ .with_header("content-type", "application/json")+ .with_body(+ json!({+ "success": true,+ "data": {+ "markdown": "# Parsed File",+ "metadata": {+ "sourceURL": "https://parse.firecrawl.dev/uploads/upload.html",+ "statusCode": 200+ }+ }+ })+ .to_string(),+ )+ .create();++ let client = Client::new_selfhosted(server.url(), Some("test_key")).unwrap();+ let file = ParseFile::from_bytes("upload.html", b"<html><body>ok</body></html>".to_vec())+ .with_content_type("text/html");+ let doc = client.parse(file, None).await.unwrap();++ assert!(doc.markdown.is_some());+ mock.assert();+ }+#[test]fn test_parse_file_from_missing_path() {let result = ParseFile::from_path("/tmp/this-file-should-not-exist-for-parse-sdk-test");