Skip to content

Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥

feat(rust-sdk): add get_parse_formats for GET /v2/parse/formats (#4911)

Gergő Móricz314f1d94a5c7
diff --git a/apps/rust-sdk/CHANGELOG.md b/apps/rust-sdk/CHANGELOG.md
index 267b483dd..f5363bb32 100644
--- a/apps/rust-sdk/CHANGELOG.md
+++ b/apps/rust-sdk/CHANGELOG.md
@@ -1,5 +1,14 @@
## CHANGELOG
+## [2.21.2] - 2026-10-02
+
+### Added
+
+- Added `Client::get_parse_formats` for `GET /v2/parse/formats`, returning the
+ upload formats `parse` accepts as `ParseFormatInfo` entries (`format`,
+ `kind`, `extensions`, `mime_types`, `available`). `ParseFormatKind` falls
+ back to `Unknown` for kinds this release does not know about.
+
## [2.21.1] - 2026-09-30
### Security
diff --git a/apps/rust-sdk/Cargo.lock b/apps/rust-sdk/Cargo.lock
index 7ee66a08e..717cf4418 100644
--- a/apps/rust-sdk/Cargo.lock
+++ b/apps/rust-sdk/Cargo.lock
@@ -250,7 +250,7 @@ checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be"
[[package]]
name = "firecrawl"
-version = "2.21.1"
+version = "2.21.2"
dependencies = [
"mockito",
"reqwest",
diff --git a/apps/rust-sdk/Cargo.toml b/apps/rust-sdk/Cargo.toml
index 933944eff..c9120059e 100644
--- a/apps/rust-sdk/Cargo.toml
+++ b/apps/rust-sdk/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "firecrawl"
-version = "2.21.1"
+version = "2.21.2"
edition = "2021"
license = "MIT"
homepage = "https://www.firecrawl.dev/"
diff --git a/apps/rust-sdk/README.md b/apps/rust-sdk/README.md
index f4a3bacec..fc58ccf91 100644
--- a/apps/rust-sdk/README.md
+++ b/apps/rust-sdk/README.md
@@ -122,6 +122,15 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
}
```
+To list the upload formats `parse` accepts, call `get_parse_formats`. Each entry has `format`, `kind` (`Document` or `Image`), `extensions`, `mime_types`, and `available` (image formats are unavailable when image OCR is disabled on the deployment).
+
+```rust
+let formats = client.get_parse_formats().await?;
+for f in formats.iter().filter(|f| f.available) {
+ println!("{} ({:?}): {:?}", f.format, f.kind, f.extensions);
+}
+```
+
### Scraping with Extract
With Extract, you can easily extract structured data from any URL. You need to specify your schema in the JSON Schema format, using the `serde_json::json!` macro.
diff --git a/apps/rust-sdk/src/parse.rs b/apps/rust-sdk/src/parse.rs
index 4e7fc26c6..89a7a2470 100644
--- a/apps/rust-sdk/src/parse.rs
+++ b/apps/rust-sdk/src/parse.rs
@@ -93,6 +93,44 @@ pub enum ParseFormat {
Attributes,
}
+/// Kind of upload a parse format covers.
+#[derive(Deserialize, Serialize, Clone, Copy, Debug, PartialEq, Eq)]
+#[serde(rename_all = "lowercase")]
+pub enum ParseFormatKind {
+ Document,
+ Image,
+ /// A kind this SDK release does not know about. Read-only catch-all so new
+ /// server-side kinds don't fail the whole response.
+ #[serde(other)]
+ Unknown,
+}
+
+/// One upload format listed by `GET /v2/parse/formats`.
+#[derive(Deserialize, Serialize, Clone, Debug, PartialEq, Eq)]
+#[serde(rename_all = "camelCase")]
+pub struct ParseFormatInfo {
+ /// Format name, e.g. `pdf` or `docx`.
+ pub format: String,
+ /// Whether this is a document or an image format.
+ pub kind: ParseFormatKind,
+ /// File extensions accepted for this format, e.g. `.pdf`.
+ pub extensions: Vec<String>,
+ /// MIME types accepted for this format.
+ pub mime_types: Vec<String>,
+ /// Whether this deployment currently accepts the format.
+ pub available: bool,
+}
+
+#[derive(Deserialize, Debug)]
+struct ParseFormatsData {
+ formats: Vec<ParseFormatInfo>,
+}
+
+#[derive(Deserialize, Debug)]
+struct ParseFormatsResponse {
+ data: ParseFormatsData,
+}
+
/// Options accepted by the `/v2/parse` endpoint.
///
/// This intentionally omits scrape-only fields that `/v2/parse` rejects
@@ -194,6 +232,21 @@ impl Client {
let response: ParseResponse = self.handle_response(response, "parse").await?;
Ok(response.data)
}
+
+ /// Lists the upload formats `/v2/parse` accepts on this deployment.
+ pub async fn get_parse_formats(&self) -> Result<Vec<ParseFormatInfo>, FirecrawlError> {
+ let response = self
+ .client
+ .get(self.url("/parse/formats"))
+ .headers(self.prepare_headers(None))
+ .send()
+ .await
+ .map_err(|e| FirecrawlError::HttpError("Getting parse formats".to_string(), e))?;
+
+ let response: ParseFormatsResponse =
+ self.handle_response(response, "get parse formats").await?;
+ Ok(response.data.formats)
+ }
}
#[cfg(test)]
@@ -277,6 +330,160 @@ mod tests {
mock.assert();
}
+ #[tokio::test]
+ async fn test_get_parse_formats() -> Result<(), FirecrawlError> {
+ let mut server = mockito::Server::new_async().await;
+ let mock = server
+ .mock("GET", "/v2/parse/formats")
+ .match_header("authorization", "Bearer test_key")
+ .with_status(200)
+ .with_header("content-type", "application/json")
+ .with_body(
+ json!({
+ "success": true,
+ "data": {
+ "formats": [
+ {
+ "format": "pdf",
+ "kind": "document",
+ "extensions": [".pdf"],
+ "mimeTypes": ["application/pdf"],
+ "available": true
+ },
+ {
+ "format": "png",
+ "kind": "image",
+ "extensions": [".png"],
+ "mimeTypes": ["image/png"],
+ "available": false
+ }
+ ]
+ }
+ })
+ .to_string(),
+ )
+ .create();
+
+ let client = Client::new_selfhosted(server.url(), Some("test_key"))?;
+ let formats = client.get_parse_formats().await?;
+
+ assert_eq!(
+ formats,
+ vec![
+ ParseFormatInfo {
+ format: "pdf".to_string(),
+ kind: ParseFormatKind::Document,
+ extensions: vec![".pdf".to_string()],
+ mime_types: vec!["application/pdf".to_string()],
+ available: true,
+ },
+ ParseFormatInfo {
+ format: "png".to_string(),
+ kind: ParseFormatKind::Image,
+ extensions: vec![".png".to_string()],
+ mime_types: vec!["image/png".to_string()],
+ available: false,
+ },
+ ]
+ );
+ mock.assert();
+ Ok(())
+ }
+
+ #[tokio::test]
+ async fn test_get_parse_formats_tolerates_unknown_kind_and_fields() -> Result<(), FirecrawlError>
+ {
+ let mut server = mockito::Server::new_async().await;
+ let mock = server
+ .mock("GET", "/v2/parse/formats")
+ .with_status(200)
+ .with_header("content-type", "application/json")
+ .with_body(
+ json!({
+ "success": true,
+ "data": {
+ "formats": [
+ {
+ "format": "glb",
+ "kind": "model",
+ "extensions": [".glb"],
+ "mimeTypes": ["model/gltf-binary"],
+ "available": true,
+ "maxBytes": 1048576
+ }
+ ],
+ "version": 2
+ }
+ })
+ .to_string(),
+ )
+ .create();
+
+ let client = Client::new_selfhosted(server.url(), Some("test_key"))?;
+ let formats = client.get_parse_formats().await?;
+
+ assert_eq!(formats.len(), 1);
+ assert_eq!(formats[0].format, "glb");
+ assert_eq!(formats[0].kind, ParseFormatKind::Unknown);
+ assert_eq!(formats[0].mime_types, vec!["model/gltf-binary"]);
+ assert!(formats[0].available);
+ mock.assert();
+ Ok(())
+ }
+
+ #[tokio::test]
+ async fn test_get_parse_formats_unauthorized() -> Result<(), FirecrawlError> {
+ let mut server = mockito::Server::new_async().await;
+ let mock = server
+ .mock("GET", "/v2/parse/formats")
+ .with_status(401)
+ .with_header("content-type", "application/json")
+ .with_body(
+ json!({
+ "success": false,
+ "error": "Unauthorized: Invalid token"
+ })
+ .to_string(),
+ )
+ .create();
+
+ let client = Client::new_selfhosted(server.url(), Some("bad_key"))?;
+ let result = client.get_parse_formats().await;
+
+ assert!(
+ matches!(
+ &result,
+ Err(FirecrawlError::APIError(_, api_error))
+ if api_error.error == "Unauthorized: Invalid token"
+ ),
+ "Expected APIError, got: {:?}",
+ result
+ );
+ mock.assert();
+ Ok(())
+ }
+
+ #[tokio::test]
+ async fn test_get_parse_formats_server_error() -> Result<(), FirecrawlError> {
+ let mut server = mockito::Server::new_async().await;
+ let mock = server
+ .mock("GET", "/v2/parse/formats")
+ .with_status(500)
+ .with_body("Internal Server Error")
+ .create();
+
+ let client = Client::new_selfhosted(server.url(), Some("test_key"))?;
+ let result = client.get_parse_formats().await;
+
+ assert!(
+ matches!(&result, Err(FirecrawlError::HttpRequestFailed(_, 500, _))),
+ "Expected HttpRequestFailed with 500, got: {:?}",
+ result
+ );
+ mock.assert();
+ Ok(())
+ }
+
#[test]
fn test_parse_file_from_missing_path() {
let result = ParseFile::from_path("/tmp/this-file-should-not-exist-for-parse-sdk-test");
diff --git a/apps/rust-sdk/tests/v2_e2e.rs b/apps/rust-sdk/tests/v2_e2e.rs
index ba9f33e58..e7aeb5e3b 100644
--- a/apps/rust-sdk/tests/v2_e2e.rs
+++ b/apps/rust-sdk/tests/v2_e2e.rs
@@ -7,8 +7,9 @@
//! Run with: cargo test --test v2_e2e -- --ignored
use firecrawl::{
- AgentOptions, BatchScrapeOptions, Client, CrawlOptions, Format, JobStatus, MapOptions,
- ParseFile, ParseFormat, ParseOptions, ScrapeOptions, SearchOptions, SitemapMode,
+ AgentOptions, BatchScrapeOptions, Client, CrawlOptions, FirecrawlError, Format, JobStatus,
+ MapOptions, ParseFile, ParseFormat, ParseFormatKind, ParseOptions, ScrapeOptions,
+ SearchOptions, SitemapMode,
};
use serde_json::json;
use std::env;
@@ -53,6 +54,32 @@ async fn test_parse() {
assert!(doc.markdown.is_some(), "Response should contain markdown");
}
+#[tokio::test]
+#[ignore = "Requires API access"]
+async fn test_get_parse_formats() -> Result<(), FirecrawlError> {
+ let client = get_client();
+ let formats = match client.get_parse_formats().await {
+ Err(FirecrawlError::APIError(_, e)) if e.code.as_deref() == Some("NOT_FOUND") => {
+ eprintln!("Skipping: /v2/parse/formats is not deployed on this API");
+ return Ok(());
+ }
+ Err(FirecrawlError::HttpRequestFailed(_, 404, _)) => {
+ eprintln!("Skipping: /v2/parse/formats is not deployed on this API");
+ return Ok(());
+ }
+ result => result?,
+ };
+
+ assert!(!formats.is_empty(), "Formats list should not be empty");
+ assert!(
+ formats
+ .iter()
+ .any(|f| f.format == "pdf" && f.kind == ParseFormatKind::Document),
+ "Formats should include a pdf document entry"
+ );
+ Ok(())
+}
+
#[tokio::test]
#[ignore = "Requires API access"]
async fn test_scrape_with_options() {