@mendable/firecrawl 4.3.8 → 4.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,7 +8,7 @@ var require_package = __commonJS({
8
8
  "package.json"(exports, module) {
9
9
  module.exports = {
10
10
  name: "@mendable/firecrawl-js",
11
- version: "4.3.8",
11
+ version: "4.4.1",
12
12
  description: "JavaScript SDK for Firecrawl API",
13
13
  main: "dist/index.js",
14
14
  types: "dist/index.d.ts",
package/dist/index.cjs CHANGED
@@ -35,7 +35,7 @@ var require_package = __commonJS({
35
35
  "package.json"(exports2, module2) {
36
36
  module2.exports = {
37
37
  name: "@mendable/firecrawl-js",
38
- version: "4.3.8",
38
+ version: "4.4.1",
39
39
  description: "JavaScript SDK for Firecrawl API",
40
40
  main: "dist/index.js",
41
41
  types: "dist/index.d.ts",
@@ -953,6 +953,9 @@ var Watcher = class extends import_events.EventEmitter {
953
953
  var zt = require("zod");
954
954
  var FirecrawlClient = class {
955
955
  http;
956
+ isCloudService(url) {
957
+ return url.includes("api.firecrawl.dev");
958
+ }
956
959
  /**
957
960
  * Create a v2 client.
958
961
  * @param options Transport configuration (API key, base URL, timeouts, retries).
@@ -960,8 +963,8 @@ var FirecrawlClient = class {
960
963
  constructor(options = {}) {
961
964
  const apiKey = options.apiKey ?? process.env.FIRECRAWL_API_KEY ?? "";
962
965
  const apiUrl = (options.apiUrl ?? process.env.FIRECRAWL_API_URL ?? "https://api.firecrawl.dev").replace(/\/$/, "");
963
- if (!apiKey) {
964
- throw new Error("API key is required. Set FIRECRAWL_API_KEY env or pass apiKey.");
966
+ if (this.isCloudService(apiUrl) && !apiKey) {
967
+ throw new Error("API key is required for the cloud API. Set FIRECRAWL_API_KEY env or pass apiKey.");
965
968
  }
966
969
  this.http = new HttpClient({
967
970
  apiKey,
package/dist/index.d.cts CHANGED
@@ -223,14 +223,14 @@ interface SearchData {
223
223
  images?: Array<SearchResultImages | Document>;
224
224
  }
225
225
  interface CategoryOption {
226
- type: 'github' | 'research';
226
+ type: 'github' | 'research' | 'pdf';
227
227
  }
228
228
  interface SearchRequest {
229
229
  query: string;
230
230
  sources?: Array<'web' | 'news' | 'images' | {
231
231
  type: 'web' | 'news' | 'images';
232
232
  }>;
233
- categories?: Array<'github' | 'research' | CategoryOption>;
233
+ categories?: Array<'github' | 'research' | 'pdf' | CategoryOption>;
234
234
  limit?: number;
235
235
  tbs?: string;
236
236
  location?: string;
@@ -486,6 +486,7 @@ interface FirecrawlClientOptions {
486
486
  */
487
487
  declare class FirecrawlClient {
488
488
  private readonly http;
489
+ private isCloudService;
489
490
  /**
490
491
  * Create a v2 client.
491
492
  * @param options Transport configuration (API key, base URL, timeouts, retries).
package/dist/index.d.ts CHANGED
@@ -223,14 +223,14 @@ interface SearchData {
223
223
  images?: Array<SearchResultImages | Document>;
224
224
  }
225
225
  interface CategoryOption {
226
- type: 'github' | 'research';
226
+ type: 'github' | 'research' | 'pdf';
227
227
  }
228
228
  interface SearchRequest {
229
229
  query: string;
230
230
  sources?: Array<'web' | 'news' | 'images' | {
231
231
  type: 'web' | 'news' | 'images';
232
232
  }>;
233
- categories?: Array<'github' | 'research' | CategoryOption>;
233
+ categories?: Array<'github' | 'research' | 'pdf' | CategoryOption>;
234
234
  limit?: number;
235
235
  tbs?: string;
236
236
  location?: string;
@@ -486,6 +486,7 @@ interface FirecrawlClientOptions {
486
486
  */
487
487
  declare class FirecrawlClient {
488
488
  private readonly http;
489
+ private isCloudService;
489
490
  /**
490
491
  * Create a v2 client.
491
492
  * @param options Transport configuration (API key, base URL, timeouts, retries).
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  require_package
3
- } from "./chunk-I2FDKS37.js";
3
+ } from "./chunk-J3BEBX3Y.js";
4
4
 
5
5
  // src/v2/utils/httpClient.ts
6
6
  import axios from "axios";
@@ -837,6 +837,9 @@ var Watcher = class extends EventEmitter {
837
837
  import "zod";
838
838
  var FirecrawlClient = class {
839
839
  http;
840
+ isCloudService(url) {
841
+ return url.includes("api.firecrawl.dev");
842
+ }
840
843
  /**
841
844
  * Create a v2 client.
842
845
  * @param options Transport configuration (API key, base URL, timeouts, retries).
@@ -844,8 +847,8 @@ var FirecrawlClient = class {
844
847
  constructor(options = {}) {
845
848
  const apiKey = options.apiKey ?? process.env.FIRECRAWL_API_KEY ?? "";
846
849
  const apiUrl = (options.apiUrl ?? process.env.FIRECRAWL_API_URL ?? "https://api.firecrawl.dev").replace(/\/$/, "");
847
- if (!apiKey) {
848
- throw new Error("API key is required. Set FIRECRAWL_API_KEY env or pass apiKey.");
850
+ if (this.isCloudService(apiUrl) && !apiKey) {
851
+ throw new Error("API key is required for the cloud API. Set FIRECRAWL_API_KEY env or pass apiKey.");
849
852
  }
850
853
  this.http = new HttpClient({
851
854
  apiKey,
@@ -1068,7 +1071,7 @@ var FirecrawlApp = class {
1068
1071
  if (typeof process !== "undefined" && process.env && process.env.npm_package_version) {
1069
1072
  return process.env.npm_package_version;
1070
1073
  }
1071
- const packageJson = await import("./package-O3Y6ICGR.js");
1074
+ const packageJson = await import("./package-SYKCM5JT.js");
1072
1075
  return packageJson.default.version;
1073
1076
  } catch (error) {
1074
1077
  const isTest = typeof process !== "undefined" && (process.env.JEST_WORKER_ID != null || false);
@@ -1,4 +1,4 @@
1
1
  import {
2
2
  require_package
3
- } from "./chunk-I2FDKS37.js";
3
+ } from "./chunk-J3BEBX3Y.js";
4
4
  export default require_package();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mendable/firecrawl",
3
- "version": "4.3.8",
3
+ "version": "4.4.1",
4
4
  "description": "JavaScript SDK for Firecrawl API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -36,7 +36,7 @@ describe('FirecrawlApp E2E Tests', () => {
36
36
  test.concurrent('should throw error for blocklisted URL on scrape', async () => {
37
37
  const app = new FirecrawlApp({ apiKey: TEST_API_KEY, apiUrl: API_URL });
38
38
  const blocklistedUrl = "https://facebook.com/fake-test";
39
- await expect(app.scrapeUrl(blocklistedUrl)).rejects.toThrow("This website is no longer supported");
39
+ await expect(app.scrapeUrl(blocklistedUrl)).rejects.toThrow("This website is not currently supported");
40
40
  });
41
41
 
42
42
  test.concurrent('should return successful response for valid scrape', async () => {
@@ -52,13 +52,13 @@ describe('FirecrawlApp E2E Tests', () => {
52
52
  const app = new FirecrawlApp({ apiKey: TEST_API_KEY, apiUrl: API_URL });
53
53
  const response = await app.scrapeUrl(
54
54
  'https://roastmywebsite.ai', {
55
- formats: ['markdown', 'html', 'rawHtml', 'screenshot', 'links'],
56
- headers: { "x-key": "test" },
57
- includeTags: ['h1'],
58
- excludeTags: ['h2'],
59
- onlyMainContent: true,
60
- timeout: 30000,
61
- waitFor: 1000
55
+ formats: ['markdown', 'html', 'rawHtml', 'screenshot', 'links'],
56
+ headers: { "x-key": "test" },
57
+ includeTags: ['h1'],
58
+ excludeTags: ['h2'],
59
+ onlyMainContent: true,
60
+ timeout: 30000,
61
+ waitFor: 1000
62
62
  });
63
63
 
64
64
  if (!response.success) {
@@ -70,7 +70,7 @@ describe('FirecrawlApp E2E Tests', () => {
70
70
  const app = new FirecrawlApp({ apiKey: TEST_API_KEY, apiUrl: API_URL });
71
71
  const response = await app.scrapeUrl(
72
72
  'https://roastmywebsite.ai', {
73
- formats: ['screenshot@fullPage'],
73
+ formats: ['screenshot@fullPage'],
74
74
  });
75
75
  if (!response.success) {
76
76
  throw new Error(response.error);
@@ -149,7 +149,7 @@ describe('FirecrawlApp E2E Tests', () => {
149
149
  }
150
150
  }, 60000); // 60 seconds timeout
151
151
 
152
- test.concurrent('should return successful response for crawl with options and wait for completion', async () => {
152
+ test.concurrent('should return successful response for crawl with options and wait for completion', async () => {
153
153
  const app = new FirecrawlApp({ apiKey: TEST_API_KEY, apiUrl: API_URL });
154
154
  const response = await app.crawlUrl('https://roastmywebsite.ai', {
155
155
  excludePaths: ['blog/*'],
@@ -192,7 +192,7 @@ describe('FirecrawlApp E2E Tests', () => {
192
192
 
193
193
  test.concurrent('should check crawl status', async () => {
194
194
  const app = new FirecrawlApp({ apiKey: TEST_API_KEY, apiUrl: API_URL });
195
- const response = await app.asyncCrawlUrl('https://firecrawl.dev', { limit: 20, scrapeOptions: { formats: ['markdown', 'html', 'rawHtml', 'screenshot', 'links']}} as CrawlParams) as CrawlResponse;
195
+ const response = await app.asyncCrawlUrl('https://firecrawl.dev', { limit: 20, scrapeOptions: { formats: ['markdown', 'html', 'rawHtml', 'screenshot', 'links'] } } as CrawlParams) as CrawlResponse;
196
196
  expect(response).not.toBeNull();
197
197
  expect(response.id).toBeDefined();
198
198
 
@@ -250,16 +250,16 @@ describe('FirecrawlApp E2E Tests', () => {
250
250
  });
251
251
 
252
252
  test.concurrent('should return successful response for valid map', async () => {
253
- const app = new FirecrawlApp({ apiKey: TEST_API_KEY, apiUrl: API_URL }); const response = await app.mapUrl('https://roastmywebsite.ai') as MapResponse;
253
+ const app = new FirecrawlApp({ apiKey: TEST_API_KEY, apiUrl: API_URL }); const response = await app.mapUrl('https://roastmywebsite.ai') as MapResponse;
254
254
  expect(response).not.toBeNull();
255
-
255
+
256
256
  expect(response.links?.length).toBeGreaterThan(0);
257
257
  expect(response.links?.[0]).toContain("https://");
258
258
  const filteredLinks = response.links?.filter((link: string) => link.includes("roastmywebsite.ai"));
259
259
  expect(filteredLinks?.length).toBeGreaterThan(0);
260
260
  }, 30000); // 30 seconds timeout
261
261
 
262
-
262
+
263
263
 
264
264
  test('should search with string query', async () => {
265
265
  const app = new FirecrawlApp({ apiUrl: API_URL, apiKey: TEST_API_KEY });
package/src/v2/client.ts CHANGED
@@ -72,9 +72,14 @@ export interface FirecrawlClientOptions {
72
72
  /**
73
73
  * Firecrawl v2 client. Provides typed access to all v2 endpoints and utilities.
74
74
  */
75
+
75
76
  export class FirecrawlClient {
76
77
  private readonly http: HttpClient;
77
78
 
79
+ private isCloudService(url: string): boolean {
80
+ return url.includes('api.firecrawl.dev');
81
+ }
82
+
78
83
  /**
79
84
  * Create a v2 client.
80
85
  * @param options Transport configuration (API key, base URL, timeouts, retries).
@@ -82,9 +87,11 @@ export class FirecrawlClient {
82
87
  constructor(options: FirecrawlClientOptions = {}) {
83
88
  const apiKey = options.apiKey ?? process.env.FIRECRAWL_API_KEY ?? "";
84
89
  const apiUrl = (options.apiUrl ?? process.env.FIRECRAWL_API_URL ?? "https://api.firecrawl.dev").replace(/\/$/, "");
85
- if (!apiKey) {
86
- throw new Error("API key is required. Set FIRECRAWL_API_KEY env or pass apiKey.");
90
+
91
+ if (this.isCloudService(apiUrl) && !apiKey) {
92
+ throw new Error("API key is required for the cloud API. Set FIRECRAWL_API_KEY env or pass apiKey.");
87
93
  }
94
+
88
95
  this.http = new HttpClient({
89
96
  apiKey,
90
97
  apiUrl,
package/src/v2/types.ts CHANGED
@@ -286,7 +286,7 @@ export interface SearchData {
286
286
  }
287
287
 
288
288
  export interface CategoryOption {
289
- type: 'github' | 'research';
289
+ type: 'github' | 'research' | 'pdf';
290
290
  }
291
291
 
292
292
  export interface SearchRequest {
@@ -294,7 +294,7 @@ export interface SearchRequest {
294
294
  sources?: Array<
295
295
  'web' | 'news' | 'images' | { type: 'web' | 'news' | 'images' }
296
296
  >;
297
- categories?: Array<'github' | 'research' | CategoryOption>;
297
+ categories?: Array<'github' | 'research' | 'pdf' | CategoryOption>;
298
298
  limit?: number;
299
299
  tbs?: string;
300
300
  location?: string;