firecrawl 1.13.0 → 1.14.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.
package/dist/index.cjs CHANGED
@@ -42,9 +42,11 @@ var import_isows = require("isows");
42
42
  var import_typescript_event_target = require("typescript-event-target");
43
43
  var FirecrawlError = class extends Error {
44
44
  statusCode;
45
- constructor(message, statusCode) {
45
+ details;
46
+ constructor(message, statusCode, details) {
46
47
  super(message);
47
48
  this.statusCode = statusCode;
49
+ this.details = details;
48
50
  }
49
51
  };
50
52
  var FirecrawlApp = class {
@@ -245,16 +247,26 @@ var FirecrawlApp = class {
245
247
  * Checks the status of a crawl job using the Firecrawl API.
246
248
  * @param id - The ID of the crawl operation.
247
249
  * @param getAllData - Paginate through all the pages of documents, returning the full list of all documents. (default: `false`)
250
+ * @param nextURL - The `next` URL from the previous crawl status. Only required if you're not manually increasing `skip`. Only used when `getAllData = false`.
251
+ * @param skip - How many entries to skip to paginate. Only required if you're not providing `nextURL`. Only used when `getAllData = false`.
252
+ * @param limit - How many entries to return. Only used when `getAllData = false`.
248
253
  * @returns The response containing the job status.
249
254
  */
250
- async checkCrawlStatus(id, getAllData = false) {
255
+ async checkCrawlStatus(id, getAllData = false, nextURL, skip, limit) {
251
256
  if (!id) {
252
257
  throw new FirecrawlError("No crawl ID provided", 400);
253
258
  }
254
259
  const headers = this.prepareHeaders();
260
+ const targetURL = new URL(nextURL ?? `${this.apiUrl}/v1/crawl/${id}`);
261
+ if (skip !== void 0) {
262
+ targetURL.searchParams.set("skip", skip.toString());
263
+ }
264
+ if (limit !== void 0) {
265
+ targetURL.searchParams.set("skip", limit.toString());
266
+ }
255
267
  try {
256
268
  const response = await this.getRequest(
257
- `${this.apiUrl}/v1/crawl/${id}`,
269
+ targetURL.href,
258
270
  headers
259
271
  );
260
272
  if (response.status === 200) {
@@ -279,6 +291,7 @@ var FirecrawlApp = class {
279
291
  total: response.data.total,
280
292
  completed: response.data.completed,
281
293
  creditsUsed: response.data.creditsUsed,
294
+ next: getAllData ? void 0 : response.data.next,
282
295
  expiresAt: new Date(response.data.expiresAt),
283
296
  data: allData
284
297
  };
@@ -452,16 +465,26 @@ var FirecrawlApp = class {
452
465
  * Checks the status of a batch scrape job using the Firecrawl API.
453
466
  * @param id - The ID of the batch scrape operation.
454
467
  * @param getAllData - Paginate through all the pages of documents, returning the full list of all documents. (default: `false`)
468
+ * @param nextURL - The `next` URL from the previous batch scrape status. Only required if you're not manually increasing `skip`. Only used when `getAllData = false`.
469
+ * @param skip - How many entries to skip to paginate. Only used when `getAllData = false`.
470
+ * @param limit - How many entries to return. Only used when `getAllData = false`.
455
471
  * @returns The response containing the job status.
456
472
  */
457
- async checkBatchScrapeStatus(id, getAllData = false) {
473
+ async checkBatchScrapeStatus(id, getAllData = false, nextURL, skip, limit) {
458
474
  if (!id) {
459
475
  throw new FirecrawlError("No batch scrape ID provided", 400);
460
476
  }
461
477
  const headers = this.prepareHeaders();
478
+ const targetURL = new URL(nextURL ?? `${this.apiUrl}/v1/batch/scrape/${id}`);
479
+ if (skip !== void 0) {
480
+ targetURL.searchParams.set("skip", skip.toString());
481
+ }
482
+ if (limit !== void 0) {
483
+ targetURL.searchParams.set("skip", limit.toString());
484
+ }
462
485
  try {
463
486
  const response = await this.getRequest(
464
- `${this.apiUrl}/v1/batch/scrape/${id}`,
487
+ targetURL.href,
465
488
  headers
466
489
  );
467
490
  if (response.status === 200) {
@@ -486,6 +509,7 @@ var FirecrawlApp = class {
486
509
  total: response.data.total,
487
510
  completed: response.data.completed,
488
511
  creditsUsed: response.data.creditsUsed,
512
+ next: getAllData ? void 0 : response.data.next,
489
513
  expiresAt: new Date(response.data.expiresAt),
490
514
  data: allData
491
515
  };
@@ -565,7 +589,7 @@ var FirecrawlApp = class {
565
589
  this.handleError(response, "extract");
566
590
  }
567
591
  } catch (error) {
568
- throw new FirecrawlError(error.message, 500);
592
+ throw new FirecrawlError(error.message, 500, error.response?.data?.details);
569
593
  }
570
594
  return { success: false, error: "Internal server error." };
571
595
  }
@@ -601,7 +625,7 @@ var FirecrawlApp = class {
601
625
  this.handleError(response, "start extract job");
602
626
  }
603
627
  } catch (error) {
604
- throw new FirecrawlError(error.message, 500);
628
+ throw new FirecrawlError(error.message, 500, error.response?.data?.details);
605
629
  }
606
630
  return { success: false, error: "Internal server error." };
607
631
  }
package/dist/index.d.cts CHANGED
@@ -258,7 +258,8 @@ interface ErrorResponse {
258
258
  */
259
259
  declare class FirecrawlError extends Error {
260
260
  statusCode: number;
261
- constructor(message: string, statusCode: number);
261
+ details?: any;
262
+ constructor(message: string, statusCode: number, details?: any);
262
263
  }
263
264
  /**
264
265
  * Parameters for search operations.
@@ -326,9 +327,12 @@ declare class FirecrawlApp {
326
327
  * Checks the status of a crawl job using the Firecrawl API.
327
328
  * @param id - The ID of the crawl operation.
328
329
  * @param getAllData - Paginate through all the pages of documents, returning the full list of all documents. (default: `false`)
330
+ * @param nextURL - The `next` URL from the previous crawl status. Only required if you're not manually increasing `skip`. Only used when `getAllData = false`.
331
+ * @param skip - How many entries to skip to paginate. Only required if you're not providing `nextURL`. Only used when `getAllData = false`.
332
+ * @param limit - How many entries to return. Only used when `getAllData = false`.
329
333
  * @returns The response containing the job status.
330
334
  */
331
- checkCrawlStatus(id?: string, getAllData?: boolean): Promise<CrawlStatusResponse | ErrorResponse>;
335
+ checkCrawlStatus(id?: string, getAllData?: boolean, nextURL?: string, skip?: number, limit?: number): Promise<CrawlStatusResponse | ErrorResponse>;
332
336
  /**
333
337
  * Cancels a crawl job using the Firecrawl API.
334
338
  * @param id - The ID of the crawl operation.
@@ -373,9 +377,12 @@ declare class FirecrawlApp {
373
377
  * Checks the status of a batch scrape job using the Firecrawl API.
374
378
  * @param id - The ID of the batch scrape operation.
375
379
  * @param getAllData - Paginate through all the pages of documents, returning the full list of all documents. (default: `false`)
380
+ * @param nextURL - The `next` URL from the previous batch scrape status. Only required if you're not manually increasing `skip`. Only used when `getAllData = false`.
381
+ * @param skip - How many entries to skip to paginate. Only used when `getAllData = false`.
382
+ * @param limit - How many entries to return. Only used when `getAllData = false`.
376
383
  * @returns The response containing the job status.
377
384
  */
378
- checkBatchScrapeStatus(id?: string, getAllData?: boolean): Promise<BatchScrapeStatusResponse | ErrorResponse>;
385
+ checkBatchScrapeStatus(id?: string, getAllData?: boolean, nextURL?: string, skip?: number, limit?: number): Promise<BatchScrapeStatusResponse | ErrorResponse>;
379
386
  /**
380
387
  * Extracts information from URLs using the Firecrawl API.
381
388
  * Currently in Beta. Expect breaking changes on future minor versions.
package/dist/index.d.ts CHANGED
@@ -258,7 +258,8 @@ interface ErrorResponse {
258
258
  */
259
259
  declare class FirecrawlError extends Error {
260
260
  statusCode: number;
261
- constructor(message: string, statusCode: number);
261
+ details?: any;
262
+ constructor(message: string, statusCode: number, details?: any);
262
263
  }
263
264
  /**
264
265
  * Parameters for search operations.
@@ -326,9 +327,12 @@ declare class FirecrawlApp {
326
327
  * Checks the status of a crawl job using the Firecrawl API.
327
328
  * @param id - The ID of the crawl operation.
328
329
  * @param getAllData - Paginate through all the pages of documents, returning the full list of all documents. (default: `false`)
330
+ * @param nextURL - The `next` URL from the previous crawl status. Only required if you're not manually increasing `skip`. Only used when `getAllData = false`.
331
+ * @param skip - How many entries to skip to paginate. Only required if you're not providing `nextURL`. Only used when `getAllData = false`.
332
+ * @param limit - How many entries to return. Only used when `getAllData = false`.
329
333
  * @returns The response containing the job status.
330
334
  */
331
- checkCrawlStatus(id?: string, getAllData?: boolean): Promise<CrawlStatusResponse | ErrorResponse>;
335
+ checkCrawlStatus(id?: string, getAllData?: boolean, nextURL?: string, skip?: number, limit?: number): Promise<CrawlStatusResponse | ErrorResponse>;
332
336
  /**
333
337
  * Cancels a crawl job using the Firecrawl API.
334
338
  * @param id - The ID of the crawl operation.
@@ -373,9 +377,12 @@ declare class FirecrawlApp {
373
377
  * Checks the status of a batch scrape job using the Firecrawl API.
374
378
  * @param id - The ID of the batch scrape operation.
375
379
  * @param getAllData - Paginate through all the pages of documents, returning the full list of all documents. (default: `false`)
380
+ * @param nextURL - The `next` URL from the previous batch scrape status. Only required if you're not manually increasing `skip`. Only used when `getAllData = false`.
381
+ * @param skip - How many entries to skip to paginate. Only used when `getAllData = false`.
382
+ * @param limit - How many entries to return. Only used when `getAllData = false`.
376
383
  * @returns The response containing the job status.
377
384
  */
378
- checkBatchScrapeStatus(id?: string, getAllData?: boolean): Promise<BatchScrapeStatusResponse | ErrorResponse>;
385
+ checkBatchScrapeStatus(id?: string, getAllData?: boolean, nextURL?: string, skip?: number, limit?: number): Promise<BatchScrapeStatusResponse | ErrorResponse>;
379
386
  /**
380
387
  * Extracts information from URLs using the Firecrawl API.
381
388
  * Currently in Beta. Expect breaking changes on future minor versions.
package/dist/index.js CHANGED
@@ -6,9 +6,11 @@ import { WebSocket } from "isows";
6
6
  import { TypedEventTarget } from "typescript-event-target";
7
7
  var FirecrawlError = class extends Error {
8
8
  statusCode;
9
- constructor(message, statusCode) {
9
+ details;
10
+ constructor(message, statusCode, details) {
10
11
  super(message);
11
12
  this.statusCode = statusCode;
13
+ this.details = details;
12
14
  }
13
15
  };
14
16
  var FirecrawlApp = class {
@@ -209,16 +211,26 @@ var FirecrawlApp = class {
209
211
  * Checks the status of a crawl job using the Firecrawl API.
210
212
  * @param id - The ID of the crawl operation.
211
213
  * @param getAllData - Paginate through all the pages of documents, returning the full list of all documents. (default: `false`)
214
+ * @param nextURL - The `next` URL from the previous crawl status. Only required if you're not manually increasing `skip`. Only used when `getAllData = false`.
215
+ * @param skip - How many entries to skip to paginate. Only required if you're not providing `nextURL`. Only used when `getAllData = false`.
216
+ * @param limit - How many entries to return. Only used when `getAllData = false`.
212
217
  * @returns The response containing the job status.
213
218
  */
214
- async checkCrawlStatus(id, getAllData = false) {
219
+ async checkCrawlStatus(id, getAllData = false, nextURL, skip, limit) {
215
220
  if (!id) {
216
221
  throw new FirecrawlError("No crawl ID provided", 400);
217
222
  }
218
223
  const headers = this.prepareHeaders();
224
+ const targetURL = new URL(nextURL ?? `${this.apiUrl}/v1/crawl/${id}`);
225
+ if (skip !== void 0) {
226
+ targetURL.searchParams.set("skip", skip.toString());
227
+ }
228
+ if (limit !== void 0) {
229
+ targetURL.searchParams.set("skip", limit.toString());
230
+ }
219
231
  try {
220
232
  const response = await this.getRequest(
221
- `${this.apiUrl}/v1/crawl/${id}`,
233
+ targetURL.href,
222
234
  headers
223
235
  );
224
236
  if (response.status === 200) {
@@ -243,6 +255,7 @@ var FirecrawlApp = class {
243
255
  total: response.data.total,
244
256
  completed: response.data.completed,
245
257
  creditsUsed: response.data.creditsUsed,
258
+ next: getAllData ? void 0 : response.data.next,
246
259
  expiresAt: new Date(response.data.expiresAt),
247
260
  data: allData
248
261
  };
@@ -416,16 +429,26 @@ var FirecrawlApp = class {
416
429
  * Checks the status of a batch scrape job using the Firecrawl API.
417
430
  * @param id - The ID of the batch scrape operation.
418
431
  * @param getAllData - Paginate through all the pages of documents, returning the full list of all documents. (default: `false`)
432
+ * @param nextURL - The `next` URL from the previous batch scrape status. Only required if you're not manually increasing `skip`. Only used when `getAllData = false`.
433
+ * @param skip - How many entries to skip to paginate. Only used when `getAllData = false`.
434
+ * @param limit - How many entries to return. Only used when `getAllData = false`.
419
435
  * @returns The response containing the job status.
420
436
  */
421
- async checkBatchScrapeStatus(id, getAllData = false) {
437
+ async checkBatchScrapeStatus(id, getAllData = false, nextURL, skip, limit) {
422
438
  if (!id) {
423
439
  throw new FirecrawlError("No batch scrape ID provided", 400);
424
440
  }
425
441
  const headers = this.prepareHeaders();
442
+ const targetURL = new URL(nextURL ?? `${this.apiUrl}/v1/batch/scrape/${id}`);
443
+ if (skip !== void 0) {
444
+ targetURL.searchParams.set("skip", skip.toString());
445
+ }
446
+ if (limit !== void 0) {
447
+ targetURL.searchParams.set("skip", limit.toString());
448
+ }
426
449
  try {
427
450
  const response = await this.getRequest(
428
- `${this.apiUrl}/v1/batch/scrape/${id}`,
451
+ targetURL.href,
429
452
  headers
430
453
  );
431
454
  if (response.status === 200) {
@@ -450,6 +473,7 @@ var FirecrawlApp = class {
450
473
  total: response.data.total,
451
474
  completed: response.data.completed,
452
475
  creditsUsed: response.data.creditsUsed,
476
+ next: getAllData ? void 0 : response.data.next,
453
477
  expiresAt: new Date(response.data.expiresAt),
454
478
  data: allData
455
479
  };
@@ -529,7 +553,7 @@ var FirecrawlApp = class {
529
553
  this.handleError(response, "extract");
530
554
  }
531
555
  } catch (error) {
532
- throw new FirecrawlError(error.message, 500);
556
+ throw new FirecrawlError(error.message, 500, error.response?.data?.details);
533
557
  }
534
558
  return { success: false, error: "Internal server error." };
535
559
  }
@@ -565,7 +589,7 @@ var FirecrawlApp = class {
565
589
  this.handleError(response, "start extract job");
566
590
  }
567
591
  } catch (error) {
568
- throw new FirecrawlError(error.message, 500);
592
+ throw new FirecrawlError(error.message, 500, error.response?.data?.details);
569
593
  }
570
594
  return { success: false, error: "Internal server error." };
571
595
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "firecrawl",
3
- "version": "1.13.0",
3
+ "version": "1.14.1",
4
4
  "description": "JavaScript SDK for Firecrawl API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/index.ts CHANGED
@@ -279,9 +279,11 @@ export interface ErrorResponse {
279
279
  */
280
280
  export class FirecrawlError extends Error {
281
281
  statusCode: number;
282
- constructor(message: string, statusCode: number) {
282
+ details?: any;
283
+ constructor(message: string, statusCode: number, details?: any) {
283
284
  super(message);
284
285
  this.statusCode = statusCode;
286
+ this.details = details;
285
287
  }
286
288
  }
287
289
 
@@ -545,17 +547,28 @@ export default class FirecrawlApp {
545
547
  * Checks the status of a crawl job using the Firecrawl API.
546
548
  * @param id - The ID of the crawl operation.
547
549
  * @param getAllData - Paginate through all the pages of documents, returning the full list of all documents. (default: `false`)
550
+ * @param nextURL - The `next` URL from the previous crawl status. Only required if you're not manually increasing `skip`. Only used when `getAllData = false`.
551
+ * @param skip - How many entries to skip to paginate. Only required if you're not providing `nextURL`. Only used when `getAllData = false`.
552
+ * @param limit - How many entries to return. Only used when `getAllData = false`.
548
553
  * @returns The response containing the job status.
549
554
  */
550
- async checkCrawlStatus(id?: string, getAllData = false): Promise<CrawlStatusResponse | ErrorResponse> {
555
+ async checkCrawlStatus(id?: string, getAllData = false, nextURL?: string, skip?: number, limit?: number): Promise<CrawlStatusResponse | ErrorResponse> {
551
556
  if (!id) {
552
557
  throw new FirecrawlError("No crawl ID provided", 400);
553
558
  }
554
559
 
555
560
  const headers: AxiosRequestHeaders = this.prepareHeaders();
561
+ const targetURL = new URL(nextURL ?? `${this.apiUrl}/v1/crawl/${id}`);
562
+ if (skip !== undefined) {
563
+ targetURL.searchParams.set("skip", skip.toString());
564
+ }
565
+ if (limit !== undefined) {
566
+ targetURL.searchParams.set("skip", limit.toString());
567
+ }
568
+
556
569
  try {
557
570
  const response: AxiosResponse = await this.getRequest(
558
- `${this.apiUrl}/v1/crawl/${id}`,
571
+ targetURL.href,
559
572
  headers
560
573
  );
561
574
  if (response.status === 200) {
@@ -581,6 +594,7 @@ export default class FirecrawlApp {
581
594
  total: response.data.total,
582
595
  completed: response.data.completed,
583
596
  creditsUsed: response.data.creditsUsed,
597
+ next: getAllData ? undefined : response.data.next,
584
598
  expiresAt: new Date(response.data.expiresAt),
585
599
  data: allData
586
600
  }
@@ -795,17 +809,28 @@ export default class FirecrawlApp {
795
809
  * Checks the status of a batch scrape job using the Firecrawl API.
796
810
  * @param id - The ID of the batch scrape operation.
797
811
  * @param getAllData - Paginate through all the pages of documents, returning the full list of all documents. (default: `false`)
812
+ * @param nextURL - The `next` URL from the previous batch scrape status. Only required if you're not manually increasing `skip`. Only used when `getAllData = false`.
813
+ * @param skip - How many entries to skip to paginate. Only used when `getAllData = false`.
814
+ * @param limit - How many entries to return. Only used when `getAllData = false`.
798
815
  * @returns The response containing the job status.
799
816
  */
800
- async checkBatchScrapeStatus(id?: string, getAllData = false): Promise<BatchScrapeStatusResponse | ErrorResponse> {
817
+ async checkBatchScrapeStatus(id?: string, getAllData = false, nextURL?: string, skip?: number, limit?: number): Promise<BatchScrapeStatusResponse | ErrorResponse> {
801
818
  if (!id) {
802
819
  throw new FirecrawlError("No batch scrape ID provided", 400);
803
820
  }
804
821
 
805
822
  const headers: AxiosRequestHeaders = this.prepareHeaders();
823
+ const targetURL = new URL(nextURL ?? `${this.apiUrl}/v1/batch/scrape/${id}`);
824
+ if (skip !== undefined) {
825
+ targetURL.searchParams.set("skip", skip.toString());
826
+ }
827
+ if (limit !== undefined) {
828
+ targetURL.searchParams.set("skip", limit.toString());
829
+ }
830
+
806
831
  try {
807
832
  const response: AxiosResponse = await this.getRequest(
808
- `${this.apiUrl}/v1/batch/scrape/${id}`,
833
+ targetURL.href,
809
834
  headers
810
835
  );
811
836
  if (response.status === 200) {
@@ -831,6 +856,7 @@ export default class FirecrawlApp {
831
856
  total: response.data.total,
832
857
  completed: response.data.completed,
833
858
  creditsUsed: response.data.creditsUsed,
859
+ next: getAllData ? undefined : response.data.next,
834
860
  expiresAt: new Date(response.data.expiresAt),
835
861
  data: allData
836
862
  }
@@ -917,9 +943,9 @@ export default class FirecrawlApp {
917
943
  this.handleError(response, "extract");
918
944
  }
919
945
  } catch (error: any) {
920
- throw new FirecrawlError(error.message, 500);
946
+ throw new FirecrawlError(error.message, 500, error.response?.data?.details);
921
947
  }
922
- return { success: false, error: "Internal server error." };
948
+ return { success: false, error: "Internal server error."};
923
949
  }
924
950
 
925
951
  /**
@@ -961,7 +987,7 @@ export default class FirecrawlApp {
961
987
  this.handleError(response, "start extract job");
962
988
  }
963
989
  } catch (error: any) {
964
- throw new FirecrawlError(error.message, 500);
990
+ throw new FirecrawlError(error.message, 500, error.response?.data?.details);
965
991
  }
966
992
  return { success: false, error: "Internal server error." };
967
993
  }