firecrawl 1.3.0 → 1.4.2

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.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { AxiosRequestHeaders, AxiosResponse } from 'axios';
2
- import { ZodSchema } from 'zod';
2
+ import * as zt from 'zod';
3
3
  import { TypedEventTarget } from 'typescript-event-target';
4
4
 
5
5
  /**
@@ -54,13 +54,13 @@ interface FirecrawlDocumentMetadata {
54
54
  * Document interface for Firecrawl.
55
55
  * Represents a document retrieved or processed by Firecrawl.
56
56
  */
57
- interface FirecrawlDocument {
57
+ interface FirecrawlDocument<T> {
58
58
  url?: string;
59
59
  markdown?: string;
60
60
  html?: string;
61
61
  rawHtml?: string;
62
62
  links?: string[];
63
- extract?: Record<any, any>;
63
+ extract?: T;
64
64
  screenshot?: string;
65
65
  metadata?: FirecrawlDocumentMetadata;
66
66
  }
@@ -68,25 +68,27 @@ interface FirecrawlDocument {
68
68
  * Parameters for scraping operations.
69
69
  * Defines the options and configurations available for scraping web content.
70
70
  */
71
- interface ScrapeParams {
71
+ interface CrawlScrapeOptions {
72
72
  formats: ("markdown" | "html" | "rawHtml" | "content" | "links" | "screenshot" | "extract" | "full@scrennshot")[];
73
73
  headers?: Record<string, string>;
74
74
  includeTags?: string[];
75
75
  excludeTags?: string[];
76
76
  onlyMainContent?: boolean;
77
+ waitFor?: number;
78
+ timeout?: number;
79
+ }
80
+ interface ScrapeParams<LLMSchema extends zt.ZodSchema> extends CrawlScrapeOptions {
77
81
  extract?: {
78
82
  prompt?: string;
79
- schema?: ZodSchema | any;
83
+ schema?: LLMSchema;
80
84
  systemPrompt?: string;
81
85
  };
82
- waitFor?: number;
83
- timeout?: number;
84
86
  }
85
87
  /**
86
88
  * Response interface for scraping operations.
87
89
  * Defines the structure of the response received after a scraping operation.
88
90
  */
89
- interface ScrapeResponse extends FirecrawlDocument {
91
+ interface ScrapeResponse<LLMResult> extends FirecrawlDocument<LLMResult> {
90
92
  success: true;
91
93
  warning?: string;
92
94
  error?: string;
@@ -103,7 +105,7 @@ interface CrawlParams {
103
105
  allowBackwardLinks?: boolean;
104
106
  allowExternalLinks?: boolean;
105
107
  ignoreSitemap?: boolean;
106
- scrapeOptions?: ScrapeParams;
108
+ scrapeOptions?: CrawlScrapeOptions;
107
109
  webhook?: string;
108
110
  }
109
111
  /**
@@ -128,7 +130,7 @@ interface CrawlStatusResponse {
128
130
  creditsUsed: number;
129
131
  expiresAt: Date;
130
132
  next?: string;
131
- data: FirecrawlDocument[];
133
+ data: FirecrawlDocument<undefined>[];
132
134
  }
133
135
  /**
134
136
  * Parameters for mapping operations.
@@ -175,7 +177,7 @@ declare class FirecrawlApp {
175
177
  * @param params - Additional parameters for the scrape request.
176
178
  * @returns The response from the scrape operation.
177
179
  */
178
- scrapeUrl(url: string, params?: ScrapeParams): Promise<ScrapeResponse | ErrorResponse>;
180
+ scrapeUrl<T extends zt.ZodSchema>(url: string, params?: ScrapeParams<T>): Promise<ScrapeResponse<zt.infer<T>> | ErrorResponse>;
179
181
  /**
180
182
  * This method is intended to search for a query using the Firecrawl API. However, it is not supported in version 1 of the API.
181
183
  * @param query - The search query string.
@@ -240,23 +242,23 @@ declare class FirecrawlApp {
240
242
  handleError(response: AxiosResponse, action: string): void;
241
243
  }
242
244
  interface CrawlWatcherEvents {
243
- document: CustomEvent<FirecrawlDocument>;
245
+ document: CustomEvent<FirecrawlDocument<undefined>>;
244
246
  done: CustomEvent<{
245
247
  status: CrawlStatusResponse["status"];
246
- data: FirecrawlDocument[];
248
+ data: FirecrawlDocument<undefined>[];
247
249
  }>;
248
250
  error: CustomEvent<{
249
251
  status: CrawlStatusResponse["status"];
250
- data: FirecrawlDocument[];
252
+ data: FirecrawlDocument<undefined>[];
251
253
  error: string;
252
254
  }>;
253
255
  }
254
256
  declare class CrawlWatcher extends TypedEventTarget<CrawlWatcherEvents> {
255
257
  private ws;
256
- data: FirecrawlDocument[];
258
+ data: FirecrawlDocument<undefined>[];
257
259
  status: CrawlStatusResponse["status"];
258
260
  constructor(id: string, app: FirecrawlApp);
259
261
  close(): void;
260
262
  }
261
263
 
262
- export { type CrawlParams, type CrawlResponse, type CrawlStatusResponse, CrawlWatcher, type ErrorResponse, type FirecrawlAppConfig, type FirecrawlDocument, type FirecrawlDocumentMetadata, type MapParams, type MapResponse, type ScrapeParams, type ScrapeResponse, FirecrawlApp as default };
264
+ export { type CrawlParams, type CrawlResponse, type CrawlScrapeOptions, type CrawlStatusResponse, CrawlWatcher, type ErrorResponse, type FirecrawlAppConfig, type FirecrawlDocument, type FirecrawlDocumentMetadata, type MapParams, type MapResponse, type ScrapeParams, type ScrapeResponse, FirecrawlApp as default };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { AxiosRequestHeaders, AxiosResponse } from 'axios';
2
- import { ZodSchema } from 'zod';
2
+ import * as zt from 'zod';
3
3
  import { TypedEventTarget } from 'typescript-event-target';
4
4
 
5
5
  /**
@@ -54,13 +54,13 @@ interface FirecrawlDocumentMetadata {
54
54
  * Document interface for Firecrawl.
55
55
  * Represents a document retrieved or processed by Firecrawl.
56
56
  */
57
- interface FirecrawlDocument {
57
+ interface FirecrawlDocument<T> {
58
58
  url?: string;
59
59
  markdown?: string;
60
60
  html?: string;
61
61
  rawHtml?: string;
62
62
  links?: string[];
63
- extract?: Record<any, any>;
63
+ extract?: T;
64
64
  screenshot?: string;
65
65
  metadata?: FirecrawlDocumentMetadata;
66
66
  }
@@ -68,25 +68,27 @@ interface FirecrawlDocument {
68
68
  * Parameters for scraping operations.
69
69
  * Defines the options and configurations available for scraping web content.
70
70
  */
71
- interface ScrapeParams {
71
+ interface CrawlScrapeOptions {
72
72
  formats: ("markdown" | "html" | "rawHtml" | "content" | "links" | "screenshot" | "extract" | "full@scrennshot")[];
73
73
  headers?: Record<string, string>;
74
74
  includeTags?: string[];
75
75
  excludeTags?: string[];
76
76
  onlyMainContent?: boolean;
77
+ waitFor?: number;
78
+ timeout?: number;
79
+ }
80
+ interface ScrapeParams<LLMSchema extends zt.ZodSchema> extends CrawlScrapeOptions {
77
81
  extract?: {
78
82
  prompt?: string;
79
- schema?: ZodSchema | any;
83
+ schema?: LLMSchema;
80
84
  systemPrompt?: string;
81
85
  };
82
- waitFor?: number;
83
- timeout?: number;
84
86
  }
85
87
  /**
86
88
  * Response interface for scraping operations.
87
89
  * Defines the structure of the response received after a scraping operation.
88
90
  */
89
- interface ScrapeResponse extends FirecrawlDocument {
91
+ interface ScrapeResponse<LLMResult> extends FirecrawlDocument<LLMResult> {
90
92
  success: true;
91
93
  warning?: string;
92
94
  error?: string;
@@ -103,7 +105,7 @@ interface CrawlParams {
103
105
  allowBackwardLinks?: boolean;
104
106
  allowExternalLinks?: boolean;
105
107
  ignoreSitemap?: boolean;
106
- scrapeOptions?: ScrapeParams;
108
+ scrapeOptions?: CrawlScrapeOptions;
107
109
  webhook?: string;
108
110
  }
109
111
  /**
@@ -128,7 +130,7 @@ interface CrawlStatusResponse {
128
130
  creditsUsed: number;
129
131
  expiresAt: Date;
130
132
  next?: string;
131
- data: FirecrawlDocument[];
133
+ data: FirecrawlDocument<undefined>[];
132
134
  }
133
135
  /**
134
136
  * Parameters for mapping operations.
@@ -175,7 +177,7 @@ declare class FirecrawlApp {
175
177
  * @param params - Additional parameters for the scrape request.
176
178
  * @returns The response from the scrape operation.
177
179
  */
178
- scrapeUrl(url: string, params?: ScrapeParams): Promise<ScrapeResponse | ErrorResponse>;
180
+ scrapeUrl<T extends zt.ZodSchema>(url: string, params?: ScrapeParams<T>): Promise<ScrapeResponse<zt.infer<T>> | ErrorResponse>;
179
181
  /**
180
182
  * This method is intended to search for a query using the Firecrawl API. However, it is not supported in version 1 of the API.
181
183
  * @param query - The search query string.
@@ -240,23 +242,23 @@ declare class FirecrawlApp {
240
242
  handleError(response: AxiosResponse, action: string): void;
241
243
  }
242
244
  interface CrawlWatcherEvents {
243
- document: CustomEvent<FirecrawlDocument>;
245
+ document: CustomEvent<FirecrawlDocument<undefined>>;
244
246
  done: CustomEvent<{
245
247
  status: CrawlStatusResponse["status"];
246
- data: FirecrawlDocument[];
248
+ data: FirecrawlDocument<undefined>[];
247
249
  }>;
248
250
  error: CustomEvent<{
249
251
  status: CrawlStatusResponse["status"];
250
- data: FirecrawlDocument[];
252
+ data: FirecrawlDocument<undefined>[];
251
253
  error: string;
252
254
  }>;
253
255
  }
254
256
  declare class CrawlWatcher extends TypedEventTarget<CrawlWatcherEvents> {
255
257
  private ws;
256
- data: FirecrawlDocument[];
258
+ data: FirecrawlDocument<undefined>[];
257
259
  status: CrawlStatusResponse["status"];
258
260
  constructor(id: string, app: FirecrawlApp);
259
261
  close(): void;
260
262
  }
261
263
 
262
- export { type CrawlParams, type CrawlResponse, type CrawlStatusResponse, CrawlWatcher, type ErrorResponse, type FirecrawlAppConfig, type FirecrawlDocument, type FirecrawlDocumentMetadata, type MapParams, type MapResponse, type ScrapeParams, type ScrapeResponse, FirecrawlApp as default };
264
+ export { type CrawlParams, type CrawlResponse, type CrawlScrapeOptions, type CrawlStatusResponse, CrawlWatcher, type ErrorResponse, type FirecrawlAppConfig, type FirecrawlDocument, type FirecrawlDocumentMetadata, type MapParams, type MapResponse, type ScrapeParams, type ScrapeResponse, FirecrawlApp as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "firecrawl",
3
- "version": "1.3.0",
3
+ "version": "1.4.2",
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
@@ -1,5 +1,5 @@
1
1
  import axios, { type AxiosResponse, type AxiosRequestHeaders } from "axios";
2
- import type { ZodSchema } from "zod";
2
+ import type * as zt from "zod";
3
3
  import { zodToJsonSchema } from "zod-to-json-schema";
4
4
  import { WebSocket } from "isows";
5
5
  import { TypedEventTarget } from "typescript-event-target";
@@ -58,13 +58,13 @@ export interface FirecrawlDocumentMetadata {
58
58
  * Document interface for Firecrawl.
59
59
  * Represents a document retrieved or processed by Firecrawl.
60
60
  */
61
- export interface FirecrawlDocument {
61
+ export interface FirecrawlDocument<T> {
62
62
  url?: string;
63
63
  markdown?: string;
64
64
  html?: string;
65
65
  rawHtml?: string;
66
66
  links?: string[];
67
- extract?: Record<any, any>;
67
+ extract?: T;
68
68
  screenshot?: string;
69
69
  metadata?: FirecrawlDocumentMetadata;
70
70
  }
@@ -73,26 +73,29 @@ export interface FirecrawlDocument {
73
73
  * Parameters for scraping operations.
74
74
  * Defines the options and configurations available for scraping web content.
75
75
  */
76
- export interface ScrapeParams {
76
+ export interface CrawlScrapeOptions {
77
77
  formats: ("markdown" | "html" | "rawHtml" | "content" | "links" | "screenshot" | "extract" | "full@scrennshot")[];
78
78
  headers?: Record<string, string>;
79
79
  includeTags?: string[];
80
80
  excludeTags?: string[];
81
81
  onlyMainContent?: boolean;
82
+ waitFor?: number;
83
+ timeout?: number;
84
+ }
85
+
86
+ export interface ScrapeParams<LLMSchema extends zt.ZodSchema> extends CrawlScrapeOptions {
82
87
  extract?: {
83
88
  prompt?: string;
84
- schema?: ZodSchema | any;
89
+ schema?: LLMSchema;
85
90
  systemPrompt?: string;
86
91
  };
87
- waitFor?: number;
88
- timeout?: number;
89
92
  }
90
93
 
91
94
  /**
92
95
  * Response interface for scraping operations.
93
96
  * Defines the structure of the response received after a scraping operation.
94
97
  */
95
- export interface ScrapeResponse extends FirecrawlDocument {
98
+ export interface ScrapeResponse<LLMResult> extends FirecrawlDocument<LLMResult> {
96
99
  success: true;
97
100
  warning?: string;
98
101
  error?: string;
@@ -110,7 +113,7 @@ export interface CrawlParams {
110
113
  allowBackwardLinks?: boolean;
111
114
  allowExternalLinks?: boolean;
112
115
  ignoreSitemap?: boolean;
113
- scrapeOptions?: ScrapeParams;
116
+ scrapeOptions?: CrawlScrapeOptions;
114
117
  webhook?: string;
115
118
  }
116
119
 
@@ -137,7 +140,7 @@ export interface CrawlStatusResponse {
137
140
  creditsUsed: number;
138
141
  expiresAt: Date;
139
142
  next?: string;
140
- data: FirecrawlDocument[];
143
+ data: FirecrawlDocument<undefined>[];
141
144
  };
142
145
 
143
146
  /**
@@ -197,10 +200,10 @@ export default class FirecrawlApp {
197
200
  * @param params - Additional parameters for the scrape request.
198
201
  * @returns The response from the scrape operation.
199
202
  */
200
- async scrapeUrl(
203
+ async scrapeUrl<T extends zt.ZodSchema>(
201
204
  url: string,
202
- params?: ScrapeParams
203
- ): Promise<ScrapeResponse | ErrorResponse> {
205
+ params?: ScrapeParams<T>
206
+ ): Promise<ScrapeResponse<zt.infer<T>> | ErrorResponse> {
204
207
  const headers: AxiosRequestHeaders = {
205
208
  "Content-Type": "application/json",
206
209
  Authorization: `Bearer ${this.apiKey}`,
@@ -528,21 +531,21 @@ export default class FirecrawlApp {
528
531
  }
529
532
 
530
533
  interface CrawlWatcherEvents {
531
- document: CustomEvent<FirecrawlDocument>,
534
+ document: CustomEvent<FirecrawlDocument<undefined>>,
532
535
  done: CustomEvent<{
533
536
  status: CrawlStatusResponse["status"];
534
- data: FirecrawlDocument[];
537
+ data: FirecrawlDocument<undefined>[];
535
538
  }>,
536
539
  error: CustomEvent<{
537
540
  status: CrawlStatusResponse["status"],
538
- data: FirecrawlDocument[],
541
+ data: FirecrawlDocument<undefined>[],
539
542
  error: string,
540
543
  }>,
541
544
  }
542
545
 
543
546
  export class CrawlWatcher extends TypedEventTarget<CrawlWatcherEvents> {
544
547
  private ws: WebSocket;
545
- public data: FirecrawlDocument[];
548
+ public data: FirecrawlDocument<undefined>[];
546
549
  public status: CrawlStatusResponse["status"];
547
550
 
548
551
  constructor(id: string, app: FirecrawlApp) {
@@ -563,7 +566,7 @@ export class CrawlWatcher extends TypedEventTarget<CrawlWatcherEvents> {
563
566
 
564
567
  type DocumentMessage = {
565
568
  type: "document",
566
- data: FirecrawlDocument,
569
+ data: FirecrawlDocument<undefined>,
567
570
  }
568
571
 
569
572
  type DoneMessage = { type: "done" }