Skip to content

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

fix(js-sdk/batchScrapeUrls): zod support

Gergő Móriczfe6b003fcf11
diff --git a/apps/js-sdk/firecrawl/package-lock.json b/apps/js-sdk/firecrawl/package-lock.json
index 81a4a1463..ff78d90e8 100644
--- a/apps/js-sdk/firecrawl/package-lock.json
+++ b/apps/js-sdk/firecrawl/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "@mendable/firecrawl-js",
- "version": "1.4.4",
+ "version": "1.9.1",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@mendable/firecrawl-js",
- "version": "1.4.4",
+ "version": "1.9.1",
"license": "MIT",
"dependencies": {
"axios": "^1.6.8",
diff --git a/apps/js-sdk/firecrawl/src/index.ts b/apps/js-sdk/firecrawl/src/index.ts
index 248443d0d..eb402b4d9 100644
--- a/apps/js-sdk/firecrawl/src/index.ts
+++ b/apps/js-sdk/firecrawl/src/index.ts
@@ -577,7 +577,24 @@ export default class FirecrawlApp {
webhook?: CrawlParams["webhook"],
): Promise<BatchScrapeStatusResponse | ErrorResponse> {
const headers = this.prepareHeaders(idempotencyKey);
- let jsonData: any = { urls, ...(params ?? {}), webhook };
+ let jsonData: any = { urls, ...params };
+ if (jsonData?.extract?.schema) {
+ let schema = jsonData.extract.schema;
+
+ // Try parsing the schema as a Zod schema
+ try {
+ schema = zodToJsonSchema(schema);
+ } catch (error) {
+
+ }
+ jsonData = {
+ ...jsonData,
+ extract: {
+ ...jsonData.extract,
+ schema: schema,
+ },
+ };
+ }
try {
const response: AxiosResponse = await this.postRequest(
this.apiUrl + `/v1/batch/scrape`,