@mendable/firecrawl-js 1.17.0 → 1.18.0-beta.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
@@ -851,6 +851,61 @@ var FirecrawlApp = class {
851
851
  );
852
852
  }
853
853
  }
854
+ /**
855
+ * Initiates a deep research operation on a given topic.
856
+ * @param params - Parameters for the deep research operation.
857
+ * @returns The response containing the research job ID.
858
+ */
859
+ async __deepResearch(params) {
860
+ const headers = this.prepareHeaders();
861
+ try {
862
+ const response = await this.postRequest(
863
+ `${this.apiUrl}/v1/deep-research`,
864
+ params,
865
+ headers
866
+ );
867
+ if (response.status === 200) {
868
+ return response.data;
869
+ } else {
870
+ this.handleError(response, "start deep research");
871
+ }
872
+ } catch (error) {
873
+ if (error.response?.data?.error) {
874
+ throw new FirecrawlError(`Request failed with status code ${error.response.status}. Error: ${error.response.data.error} ${error.response.data.details ? ` - ${JSON.stringify(error.response.data.details)}` : ""}`, error.response.status);
875
+ } else {
876
+ throw new FirecrawlError(error.message, 500);
877
+ }
878
+ }
879
+ return { success: false, error: "Internal server error." };
880
+ }
881
+ /**
882
+ * Checks the status of a deep research operation.
883
+ * @param id - The ID of the deep research operation.
884
+ * @returns The current status and results of the research operation.
885
+ */
886
+ async __checkDeepResearchStatus(id) {
887
+ const headers = this.prepareHeaders();
888
+ try {
889
+ const response = await this.getRequest(
890
+ `${this.apiUrl}/v1/deep-research/${id}`,
891
+ headers
892
+ );
893
+ if (response.status === 200) {
894
+ return response.data;
895
+ } else if (response.status === 404) {
896
+ throw new FirecrawlError("Deep research job not found", 404);
897
+ } else {
898
+ this.handleError(response, "check deep research status");
899
+ }
900
+ } catch (error) {
901
+ if (error.response?.data?.error) {
902
+ throw new FirecrawlError(`Request failed with status code ${error.response.status}. Error: ${error.response.data.error} ${error.response.data.details ? ` - ${JSON.stringify(error.response.data.details)}` : ""}`, error.response.status);
903
+ } else {
904
+ throw new FirecrawlError(error.message, 500);
905
+ }
906
+ }
907
+ return { success: false, error: "Internal server error." };
908
+ }
854
909
  };
855
910
  var CrawlWatcher = class extends import_typescript_event_target.TypedEventTarget {
856
911
  ws;
package/dist/index.d.cts CHANGED
@@ -317,6 +317,71 @@ interface CrawlErrorsResponse {
317
317
  */
318
318
  robotsBlocked: string[];
319
319
  }
320
+ /**
321
+ * Parameters for deep research operations.
322
+ * Defines options for conducting deep research on a topic.
323
+ */
324
+ interface DeepResearchParams {
325
+ /**
326
+ * The topic or question to research
327
+ */
328
+ topic: string;
329
+ /**
330
+ * Maximum depth of research iterations (1-10)
331
+ * @default 7
332
+ */
333
+ maxDepth?: number;
334
+ /**
335
+ * Time limit in seconds (30-300)
336
+ * @default 270
337
+ */
338
+ timeLimit?: number;
339
+ /**
340
+ * Experimental flag for streaming steps
341
+ */
342
+ __experimental_streamSteps?: boolean;
343
+ }
344
+ /**
345
+ * Response interface for deep research operations.
346
+ */
347
+ interface DeepResearchResponse {
348
+ success: boolean;
349
+ id: string;
350
+ }
351
+ /**
352
+ * Status response interface for deep research operations.
353
+ */
354
+ interface DeepResearchStatusResponse {
355
+ success: boolean;
356
+ data: {
357
+ findings: Array<{
358
+ text: string;
359
+ source: string;
360
+ }>;
361
+ finalAnalysis: string;
362
+ analysis: string;
363
+ completedSteps: number;
364
+ totalSteps: number;
365
+ };
366
+ status: "processing" | "completed" | "failed";
367
+ error?: string;
368
+ expiresAt: string;
369
+ currentDepth: number;
370
+ maxDepth: number;
371
+ activities: Array<{
372
+ type: string;
373
+ status: string;
374
+ message: string;
375
+ timestamp: string;
376
+ depth: number;
377
+ }>;
378
+ sources: Array<{
379
+ url: string;
380
+ title: string;
381
+ description: string;
382
+ }>;
383
+ summaries: string[];
384
+ }
320
385
  /**
321
386
  * Main class for interacting with the Firecrawl API.
322
387
  * Provides methods for scraping, searching, crawling, and mapping web content.
@@ -491,6 +556,18 @@ declare class FirecrawlApp {
491
556
  * @param {string} action - The action being performed when the error occurred.
492
557
  */
493
558
  handleError(response: AxiosResponse, action: string): void;
559
+ /**
560
+ * Initiates a deep research operation on a given topic.
561
+ * @param params - Parameters for the deep research operation.
562
+ * @returns The response containing the research job ID.
563
+ */
564
+ __deepResearch(params: DeepResearchParams): Promise<DeepResearchResponse | ErrorResponse>;
565
+ /**
566
+ * Checks the status of a deep research operation.
567
+ * @param id - The ID of the deep research operation.
568
+ * @returns The current status and results of the research operation.
569
+ */
570
+ __checkDeepResearchStatus(id: string): Promise<DeepResearchStatusResponse | ErrorResponse>;
494
571
  }
495
572
  interface CrawlWatcherEvents {
496
573
  document: CustomEvent<FirecrawlDocument<undefined>>;
@@ -513,4 +590,4 @@ declare class CrawlWatcher extends TypedEventTarget<CrawlWatcherEvents> {
513
590
  close(): void;
514
591
  }
515
592
 
516
- export { type Action, type ActionsResult, type BatchScrapeResponse, type BatchScrapeStatusResponse, type CrawlErrorsResponse, type CrawlParams, type CrawlResponse, type CrawlScrapeOptions, type CrawlStatusResponse, CrawlWatcher, type ErrorResponse, type ExtractParams, type ExtractResponse, type FirecrawlAppConfig, type FirecrawlDocument, type FirecrawlDocumentMetadata, FirecrawlError, type MapParams, type MapResponse, type ScrapeParams, type ScrapeResponse, type SearchParams, type SearchResponse, FirecrawlApp as default };
593
+ export { type Action, type ActionsResult, type BatchScrapeResponse, type BatchScrapeStatusResponse, type CrawlErrorsResponse, type CrawlParams, type CrawlResponse, type CrawlScrapeOptions, type CrawlStatusResponse, CrawlWatcher, type DeepResearchParams, type DeepResearchResponse, type DeepResearchStatusResponse, type ErrorResponse, type ExtractParams, type ExtractResponse, type FirecrawlAppConfig, type FirecrawlDocument, type FirecrawlDocumentMetadata, FirecrawlError, type MapParams, type MapResponse, type ScrapeParams, type ScrapeResponse, type SearchParams, type SearchResponse, FirecrawlApp as default };
package/dist/index.d.ts CHANGED
@@ -317,6 +317,71 @@ interface CrawlErrorsResponse {
317
317
  */
318
318
  robotsBlocked: string[];
319
319
  }
320
+ /**
321
+ * Parameters for deep research operations.
322
+ * Defines options for conducting deep research on a topic.
323
+ */
324
+ interface DeepResearchParams {
325
+ /**
326
+ * The topic or question to research
327
+ */
328
+ topic: string;
329
+ /**
330
+ * Maximum depth of research iterations (1-10)
331
+ * @default 7
332
+ */
333
+ maxDepth?: number;
334
+ /**
335
+ * Time limit in seconds (30-300)
336
+ * @default 270
337
+ */
338
+ timeLimit?: number;
339
+ /**
340
+ * Experimental flag for streaming steps
341
+ */
342
+ __experimental_streamSteps?: boolean;
343
+ }
344
+ /**
345
+ * Response interface for deep research operations.
346
+ */
347
+ interface DeepResearchResponse {
348
+ success: boolean;
349
+ id: string;
350
+ }
351
+ /**
352
+ * Status response interface for deep research operations.
353
+ */
354
+ interface DeepResearchStatusResponse {
355
+ success: boolean;
356
+ data: {
357
+ findings: Array<{
358
+ text: string;
359
+ source: string;
360
+ }>;
361
+ finalAnalysis: string;
362
+ analysis: string;
363
+ completedSteps: number;
364
+ totalSteps: number;
365
+ };
366
+ status: "processing" | "completed" | "failed";
367
+ error?: string;
368
+ expiresAt: string;
369
+ currentDepth: number;
370
+ maxDepth: number;
371
+ activities: Array<{
372
+ type: string;
373
+ status: string;
374
+ message: string;
375
+ timestamp: string;
376
+ depth: number;
377
+ }>;
378
+ sources: Array<{
379
+ url: string;
380
+ title: string;
381
+ description: string;
382
+ }>;
383
+ summaries: string[];
384
+ }
320
385
  /**
321
386
  * Main class for interacting with the Firecrawl API.
322
387
  * Provides methods for scraping, searching, crawling, and mapping web content.
@@ -491,6 +556,18 @@ declare class FirecrawlApp {
491
556
  * @param {string} action - The action being performed when the error occurred.
492
557
  */
493
558
  handleError(response: AxiosResponse, action: string): void;
559
+ /**
560
+ * Initiates a deep research operation on a given topic.
561
+ * @param params - Parameters for the deep research operation.
562
+ * @returns The response containing the research job ID.
563
+ */
564
+ __deepResearch(params: DeepResearchParams): Promise<DeepResearchResponse | ErrorResponse>;
565
+ /**
566
+ * Checks the status of a deep research operation.
567
+ * @param id - The ID of the deep research operation.
568
+ * @returns The current status and results of the research operation.
569
+ */
570
+ __checkDeepResearchStatus(id: string): Promise<DeepResearchStatusResponse | ErrorResponse>;
494
571
  }
495
572
  interface CrawlWatcherEvents {
496
573
  document: CustomEvent<FirecrawlDocument<undefined>>;
@@ -513,4 +590,4 @@ declare class CrawlWatcher extends TypedEventTarget<CrawlWatcherEvents> {
513
590
  close(): void;
514
591
  }
515
592
 
516
- export { type Action, type ActionsResult, type BatchScrapeResponse, type BatchScrapeStatusResponse, type CrawlErrorsResponse, type CrawlParams, type CrawlResponse, type CrawlScrapeOptions, type CrawlStatusResponse, CrawlWatcher, type ErrorResponse, type ExtractParams, type ExtractResponse, type FirecrawlAppConfig, type FirecrawlDocument, type FirecrawlDocumentMetadata, FirecrawlError, type MapParams, type MapResponse, type ScrapeParams, type ScrapeResponse, type SearchParams, type SearchResponse, FirecrawlApp as default };
593
+ export { type Action, type ActionsResult, type BatchScrapeResponse, type BatchScrapeStatusResponse, type CrawlErrorsResponse, type CrawlParams, type CrawlResponse, type CrawlScrapeOptions, type CrawlStatusResponse, CrawlWatcher, type DeepResearchParams, type DeepResearchResponse, type DeepResearchStatusResponse, type ErrorResponse, type ExtractParams, type ExtractResponse, type FirecrawlAppConfig, type FirecrawlDocument, type FirecrawlDocumentMetadata, FirecrawlError, type MapParams, type MapResponse, type ScrapeParams, type ScrapeResponse, type SearchParams, type SearchResponse, FirecrawlApp as default };
package/dist/index.js CHANGED
@@ -815,6 +815,61 @@ var FirecrawlApp = class {
815
815
  );
816
816
  }
817
817
  }
818
+ /**
819
+ * Initiates a deep research operation on a given topic.
820
+ * @param params - Parameters for the deep research operation.
821
+ * @returns The response containing the research job ID.
822
+ */
823
+ async __deepResearch(params) {
824
+ const headers = this.prepareHeaders();
825
+ try {
826
+ const response = await this.postRequest(
827
+ `${this.apiUrl}/v1/deep-research`,
828
+ params,
829
+ headers
830
+ );
831
+ if (response.status === 200) {
832
+ return response.data;
833
+ } else {
834
+ this.handleError(response, "start deep research");
835
+ }
836
+ } catch (error) {
837
+ if (error.response?.data?.error) {
838
+ throw new FirecrawlError(`Request failed with status code ${error.response.status}. Error: ${error.response.data.error} ${error.response.data.details ? ` - ${JSON.stringify(error.response.data.details)}` : ""}`, error.response.status);
839
+ } else {
840
+ throw new FirecrawlError(error.message, 500);
841
+ }
842
+ }
843
+ return { success: false, error: "Internal server error." };
844
+ }
845
+ /**
846
+ * Checks the status of a deep research operation.
847
+ * @param id - The ID of the deep research operation.
848
+ * @returns The current status and results of the research operation.
849
+ */
850
+ async __checkDeepResearchStatus(id) {
851
+ const headers = this.prepareHeaders();
852
+ try {
853
+ const response = await this.getRequest(
854
+ `${this.apiUrl}/v1/deep-research/${id}`,
855
+ headers
856
+ );
857
+ if (response.status === 200) {
858
+ return response.data;
859
+ } else if (response.status === 404) {
860
+ throw new FirecrawlError("Deep research job not found", 404);
861
+ } else {
862
+ this.handleError(response, "check deep research status");
863
+ }
864
+ } catch (error) {
865
+ if (error.response?.data?.error) {
866
+ throw new FirecrawlError(`Request failed with status code ${error.response.status}. Error: ${error.response.data.error} ${error.response.data.details ? ` - ${JSON.stringify(error.response.data.details)}` : ""}`, error.response.status);
867
+ } else {
868
+ throw new FirecrawlError(error.message, 500);
869
+ }
870
+ }
871
+ return { success: false, error: "Internal server error." };
872
+ }
818
873
  };
819
874
  var CrawlWatcher = class extends TypedEventTarget {
820
875
  ws;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mendable/firecrawl-js",
3
- "version": "1.17.0",
3
+ "version": "1.18.0-beta.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
@@ -347,6 +347,74 @@ export interface CrawlErrorsResponse {
347
347
  robotsBlocked: string[];
348
348
  };
349
349
 
350
+ /**
351
+ * Parameters for deep research operations.
352
+ * Defines options for conducting deep research on a topic.
353
+ */
354
+ export interface DeepResearchParams {
355
+ /**
356
+ * The topic or question to research
357
+ */
358
+ topic: string;
359
+ /**
360
+ * Maximum depth of research iterations (1-10)
361
+ * @default 7
362
+ */
363
+ maxDepth?: number;
364
+ /**
365
+ * Time limit in seconds (30-300)
366
+ * @default 270
367
+ */
368
+ timeLimit?: number;
369
+ /**
370
+ * Experimental flag for streaming steps
371
+ */
372
+ __experimental_streamSteps?: boolean;
373
+ }
374
+
375
+ /**
376
+ * Response interface for deep research operations.
377
+ */
378
+ export interface DeepResearchResponse {
379
+ success: boolean;
380
+ id: string;
381
+ }
382
+
383
+ /**
384
+ * Status response interface for deep research operations.
385
+ */
386
+ export interface DeepResearchStatusResponse {
387
+ success: boolean;
388
+ data: {
389
+ findings: Array<{
390
+ text: string;
391
+ source: string;
392
+ }>;
393
+ finalAnalysis: string;
394
+ analysis: string;
395
+ completedSteps: number;
396
+ totalSteps: number;
397
+ };
398
+ status: "processing" | "completed" | "failed";
399
+ error?: string;
400
+ expiresAt: string;
401
+ currentDepth: number;
402
+ maxDepth: number;
403
+ activities: Array<{
404
+ type: string;
405
+ status: string;
406
+ message: string;
407
+ timestamp: string;
408
+ depth: number;
409
+ }>;
410
+ sources: Array<{
411
+ url: string;
412
+ title: string;
413
+ description: string;
414
+ }>;
415
+ summaries: string[];
416
+ }
417
+
350
418
  /**
351
419
  * Main class for interacting with the Firecrawl API.
352
420
  * Provides methods for scraping, searching, crawling, and mapping web content.
@@ -1280,6 +1348,65 @@ export default class FirecrawlApp {
1280
1348
  );
1281
1349
  }
1282
1350
  }
1351
+
1352
+ /**
1353
+ * Initiates a deep research operation on a given topic.
1354
+ * @param params - Parameters for the deep research operation.
1355
+ * @returns The response containing the research job ID.
1356
+ */
1357
+ async __deepResearch(params: DeepResearchParams): Promise<DeepResearchResponse | ErrorResponse> {
1358
+ const headers = this.prepareHeaders();
1359
+ try {
1360
+ const response: AxiosResponse = await this.postRequest(
1361
+ `${this.apiUrl}/v1/deep-research`,
1362
+ params,
1363
+ headers
1364
+ );
1365
+
1366
+ if (response.status === 200) {
1367
+ return response.data;
1368
+ } else {
1369
+ this.handleError(response, "start deep research");
1370
+ }
1371
+ } catch (error: any) {
1372
+ if (error.response?.data?.error) {
1373
+ throw new FirecrawlError(`Request failed with status code ${error.response.status}. Error: ${error.response.data.error} ${error.response.data.details ? ` - ${JSON.stringify(error.response.data.details)}` : ''}`, error.response.status);
1374
+ } else {
1375
+ throw new FirecrawlError(error.message, 500);
1376
+ }
1377
+ }
1378
+ return { success: false, error: "Internal server error." };
1379
+ }
1380
+
1381
+ /**
1382
+ * Checks the status of a deep research operation.
1383
+ * @param id - The ID of the deep research operation.
1384
+ * @returns The current status and results of the research operation.
1385
+ */
1386
+ async __checkDeepResearchStatus(id: string): Promise<DeepResearchStatusResponse | ErrorResponse> {
1387
+ const headers = this.prepareHeaders();
1388
+ try {
1389
+ const response: AxiosResponse = await this.getRequest(
1390
+ `${this.apiUrl}/v1/deep-research/${id}`,
1391
+ headers
1392
+ );
1393
+
1394
+ if (response.status === 200) {
1395
+ return response.data;
1396
+ } else if (response.status === 404) {
1397
+ throw new FirecrawlError("Deep research job not found", 404);
1398
+ } else {
1399
+ this.handleError(response, "check deep research status");
1400
+ }
1401
+ } catch (error: any) {
1402
+ if (error.response?.data?.error) {
1403
+ throw new FirecrawlError(`Request failed with status code ${error.response.status}. Error: ${error.response.data.error} ${error.response.data.details ? ` - ${JSON.stringify(error.response.data.details)}` : ''}`, error.response.status);
1404
+ } else {
1405
+ throw new FirecrawlError(error.message, 500);
1406
+ }
1407
+ }
1408
+ return { success: false, error: "Internal server error." };
1409
+ }
1283
1410
  }
1284
1411
 
1285
1412
  interface CrawlWatcherEvents {