firecrawl 1.18.4 → 1.18.5
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 +1149 -0
- package/dist/index.d.cts +669 -0
- package/dist/index.d.ts +669 -0
- package/dist/index.js +1113 -0
- package/dump.rdb +0 -0
- package/package.json +1 -1
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,669 @@
|
|
|
1
|
+
import { AxiosRequestHeaders, AxiosResponse } from 'axios';
|
|
2
|
+
import * as zt from 'zod';
|
|
3
|
+
import { TypedEventTarget } from 'typescript-event-target';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Configuration interface for FirecrawlApp.
|
|
7
|
+
* @param apiKey - Optional API key for authentication.
|
|
8
|
+
* @param apiUrl - Optional base URL of the API; defaults to 'https://api.firecrawl.dev'.
|
|
9
|
+
*/
|
|
10
|
+
interface FirecrawlAppConfig {
|
|
11
|
+
apiKey?: string | null;
|
|
12
|
+
apiUrl?: string | null;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Metadata for a Firecrawl document.
|
|
16
|
+
* Includes various optional properties for document metadata.
|
|
17
|
+
*/
|
|
18
|
+
interface FirecrawlDocumentMetadata {
|
|
19
|
+
title?: string;
|
|
20
|
+
description?: string;
|
|
21
|
+
language?: string;
|
|
22
|
+
keywords?: string;
|
|
23
|
+
robots?: string;
|
|
24
|
+
ogTitle?: string;
|
|
25
|
+
ogDescription?: string;
|
|
26
|
+
ogUrl?: string;
|
|
27
|
+
ogImage?: string;
|
|
28
|
+
ogAudio?: string;
|
|
29
|
+
ogDeterminer?: string;
|
|
30
|
+
ogLocale?: string;
|
|
31
|
+
ogLocaleAlternate?: string[];
|
|
32
|
+
ogSiteName?: string;
|
|
33
|
+
ogVideo?: string;
|
|
34
|
+
dctermsCreated?: string;
|
|
35
|
+
dcDateCreated?: string;
|
|
36
|
+
dcDate?: string;
|
|
37
|
+
dctermsType?: string;
|
|
38
|
+
dcType?: string;
|
|
39
|
+
dctermsAudience?: string;
|
|
40
|
+
dctermsSubject?: string;
|
|
41
|
+
dcSubject?: string;
|
|
42
|
+
dcDescription?: string;
|
|
43
|
+
dctermsKeywords?: string;
|
|
44
|
+
modifiedTime?: string;
|
|
45
|
+
publishedTime?: string;
|
|
46
|
+
articleTag?: string;
|
|
47
|
+
articleSection?: string;
|
|
48
|
+
sourceURL?: string;
|
|
49
|
+
statusCode?: number;
|
|
50
|
+
error?: string;
|
|
51
|
+
[key: string]: any;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Document interface for Firecrawl.
|
|
55
|
+
* Represents a document retrieved or processed by Firecrawl.
|
|
56
|
+
*/
|
|
57
|
+
interface FirecrawlDocument<T = any, ActionsSchema extends (ActionsResult | never) = never> {
|
|
58
|
+
url?: string;
|
|
59
|
+
markdown?: string;
|
|
60
|
+
html?: string;
|
|
61
|
+
rawHtml?: string;
|
|
62
|
+
links?: string[];
|
|
63
|
+
extract?: T;
|
|
64
|
+
json?: T;
|
|
65
|
+
screenshot?: string;
|
|
66
|
+
metadata?: FirecrawlDocumentMetadata;
|
|
67
|
+
actions: ActionsSchema;
|
|
68
|
+
title?: string;
|
|
69
|
+
description?: string;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Parameters for scraping operations.
|
|
73
|
+
* Defines the options and configurations available for scraping web content.
|
|
74
|
+
*/
|
|
75
|
+
interface CrawlScrapeOptions {
|
|
76
|
+
formats?: ("markdown" | "html" | "rawHtml" | "content" | "links" | "screenshot" | "screenshot@fullPage" | "extract" | "json")[];
|
|
77
|
+
headers?: Record<string, string>;
|
|
78
|
+
includeTags?: string[];
|
|
79
|
+
excludeTags?: string[];
|
|
80
|
+
onlyMainContent?: boolean;
|
|
81
|
+
waitFor?: number;
|
|
82
|
+
timeout?: number;
|
|
83
|
+
location?: {
|
|
84
|
+
country?: string;
|
|
85
|
+
languages?: string[];
|
|
86
|
+
};
|
|
87
|
+
mobile?: boolean;
|
|
88
|
+
skipTlsVerification?: boolean;
|
|
89
|
+
removeBase64Images?: boolean;
|
|
90
|
+
blockAds?: boolean;
|
|
91
|
+
proxy?: "basic" | "stealth";
|
|
92
|
+
}
|
|
93
|
+
type Action = {
|
|
94
|
+
type: "wait";
|
|
95
|
+
milliseconds?: number;
|
|
96
|
+
selector?: string;
|
|
97
|
+
} | {
|
|
98
|
+
type: "click";
|
|
99
|
+
selector: string;
|
|
100
|
+
} | {
|
|
101
|
+
type: "screenshot";
|
|
102
|
+
fullPage?: boolean;
|
|
103
|
+
} | {
|
|
104
|
+
type: "write";
|
|
105
|
+
text: string;
|
|
106
|
+
} | {
|
|
107
|
+
type: "press";
|
|
108
|
+
key: string;
|
|
109
|
+
} | {
|
|
110
|
+
type: "scroll";
|
|
111
|
+
direction?: "up" | "down";
|
|
112
|
+
selector?: string;
|
|
113
|
+
} | {
|
|
114
|
+
type: "scrape";
|
|
115
|
+
} | {
|
|
116
|
+
type: "executeJavascript";
|
|
117
|
+
script: string;
|
|
118
|
+
};
|
|
119
|
+
interface ScrapeParams<LLMSchema extends zt.ZodSchema = any, ActionsSchema extends (Action[] | undefined) = undefined> extends CrawlScrapeOptions {
|
|
120
|
+
extract?: {
|
|
121
|
+
prompt?: string;
|
|
122
|
+
schema?: LLMSchema;
|
|
123
|
+
systemPrompt?: string;
|
|
124
|
+
};
|
|
125
|
+
jsonOptions?: {
|
|
126
|
+
prompt?: string;
|
|
127
|
+
schema?: LLMSchema;
|
|
128
|
+
systemPrompt?: string;
|
|
129
|
+
};
|
|
130
|
+
actions?: ActionsSchema;
|
|
131
|
+
}
|
|
132
|
+
interface ActionsResult {
|
|
133
|
+
screenshots: string[];
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Response interface for scraping operations.
|
|
137
|
+
* Defines the structure of the response received after a scraping operation.
|
|
138
|
+
*/
|
|
139
|
+
interface ScrapeResponse<LLMResult = any, ActionsSchema extends (ActionsResult | never) = never> extends FirecrawlDocument<LLMResult, ActionsSchema> {
|
|
140
|
+
success: true;
|
|
141
|
+
warning?: string;
|
|
142
|
+
error?: string;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Parameters for crawling operations.
|
|
146
|
+
* Includes options for both scraping and mapping during a crawl.
|
|
147
|
+
*/
|
|
148
|
+
interface CrawlParams {
|
|
149
|
+
includePaths?: string[];
|
|
150
|
+
excludePaths?: string[];
|
|
151
|
+
maxDepth?: number;
|
|
152
|
+
limit?: number;
|
|
153
|
+
allowBackwardLinks?: boolean;
|
|
154
|
+
allowExternalLinks?: boolean;
|
|
155
|
+
ignoreSitemap?: boolean;
|
|
156
|
+
scrapeOptions?: CrawlScrapeOptions;
|
|
157
|
+
webhook?: string | {
|
|
158
|
+
url: string;
|
|
159
|
+
headers?: Record<string, string>;
|
|
160
|
+
metadata?: Record<string, string>;
|
|
161
|
+
events?: ["completed", "failed", "page", "started"][number][];
|
|
162
|
+
};
|
|
163
|
+
deduplicateSimilarURLs?: boolean;
|
|
164
|
+
ignoreQueryParameters?: boolean;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Response interface for crawling operations.
|
|
168
|
+
* Defines the structure of the response received after initiating a crawl.
|
|
169
|
+
*/
|
|
170
|
+
interface CrawlResponse {
|
|
171
|
+
id?: string;
|
|
172
|
+
url?: string;
|
|
173
|
+
success: true;
|
|
174
|
+
error?: string;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Response interface for batch scrape operations.
|
|
178
|
+
* Defines the structure of the response received after initiating a crawl.
|
|
179
|
+
*/
|
|
180
|
+
interface BatchScrapeResponse {
|
|
181
|
+
id?: string;
|
|
182
|
+
url?: string;
|
|
183
|
+
success: true;
|
|
184
|
+
error?: string;
|
|
185
|
+
invalidURLs?: string[];
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Response interface for job status checks.
|
|
189
|
+
* Provides detailed status of a crawl job including progress and results.
|
|
190
|
+
*/
|
|
191
|
+
interface CrawlStatusResponse {
|
|
192
|
+
success: true;
|
|
193
|
+
status: "scraping" | "completed" | "failed" | "cancelled";
|
|
194
|
+
completed: number;
|
|
195
|
+
total: number;
|
|
196
|
+
creditsUsed: number;
|
|
197
|
+
expiresAt: Date;
|
|
198
|
+
next?: string;
|
|
199
|
+
data: FirecrawlDocument<undefined>[];
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Response interface for batch scrape job status checks.
|
|
203
|
+
* Provides detailed status of a batch scrape job including progress and results.
|
|
204
|
+
*/
|
|
205
|
+
interface BatchScrapeStatusResponse {
|
|
206
|
+
success: true;
|
|
207
|
+
status: "scraping" | "completed" | "failed" | "cancelled";
|
|
208
|
+
completed: number;
|
|
209
|
+
total: number;
|
|
210
|
+
creditsUsed: number;
|
|
211
|
+
expiresAt: Date;
|
|
212
|
+
next?: string;
|
|
213
|
+
data: FirecrawlDocument<undefined>[];
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Parameters for mapping operations.
|
|
217
|
+
* Defines options for mapping URLs during a crawl.
|
|
218
|
+
*/
|
|
219
|
+
interface MapParams {
|
|
220
|
+
search?: string;
|
|
221
|
+
ignoreSitemap?: boolean;
|
|
222
|
+
includeSubdomains?: boolean;
|
|
223
|
+
sitemapOnly?: boolean;
|
|
224
|
+
limit?: number;
|
|
225
|
+
timeout?: number;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Response interface for mapping operations.
|
|
229
|
+
* Defines the structure of the response received after a mapping operation.
|
|
230
|
+
*/
|
|
231
|
+
interface MapResponse {
|
|
232
|
+
success: true;
|
|
233
|
+
links?: string[];
|
|
234
|
+
error?: string;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Parameters for extracting information from URLs.
|
|
238
|
+
* Defines options for extracting information from URLs.
|
|
239
|
+
*/
|
|
240
|
+
interface ExtractParams<LLMSchema extends zt.ZodSchema = any> {
|
|
241
|
+
prompt?: string;
|
|
242
|
+
schema?: LLMSchema | object;
|
|
243
|
+
systemPrompt?: string;
|
|
244
|
+
allowExternalLinks?: boolean;
|
|
245
|
+
enableWebSearch?: boolean;
|
|
246
|
+
includeSubdomains?: boolean;
|
|
247
|
+
origin?: string;
|
|
248
|
+
showSources?: boolean;
|
|
249
|
+
scrapeOptions?: CrawlScrapeOptions;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Response interface for extracting information from URLs.
|
|
253
|
+
* Defines the structure of the response received after extracting information from URLs.
|
|
254
|
+
*/
|
|
255
|
+
interface ExtractResponse<LLMSchema extends zt.ZodSchema = any> {
|
|
256
|
+
success: boolean;
|
|
257
|
+
data: LLMSchema;
|
|
258
|
+
error?: string;
|
|
259
|
+
warning?: string;
|
|
260
|
+
sources?: string[];
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Error response interface.
|
|
264
|
+
* Defines the structure of the response received when an error occurs.
|
|
265
|
+
*/
|
|
266
|
+
interface ErrorResponse {
|
|
267
|
+
success: false;
|
|
268
|
+
error: string;
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Custom error class for Firecrawl.
|
|
272
|
+
* Extends the built-in Error class to include a status code.
|
|
273
|
+
*/
|
|
274
|
+
declare class FirecrawlError extends Error {
|
|
275
|
+
statusCode: number;
|
|
276
|
+
details?: any;
|
|
277
|
+
constructor(message: string, statusCode: number, details?: any);
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Parameters for search operations.
|
|
281
|
+
* Defines options for searching and scraping search results.
|
|
282
|
+
*/
|
|
283
|
+
interface SearchParams {
|
|
284
|
+
limit?: number;
|
|
285
|
+
tbs?: string;
|
|
286
|
+
filter?: string;
|
|
287
|
+
lang?: string;
|
|
288
|
+
country?: string;
|
|
289
|
+
location?: string;
|
|
290
|
+
origin?: string;
|
|
291
|
+
timeout?: number;
|
|
292
|
+
scrapeOptions?: ScrapeParams;
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Response interface for search operations.
|
|
296
|
+
* Defines the structure of the response received after a search operation.
|
|
297
|
+
*/
|
|
298
|
+
interface SearchResponse {
|
|
299
|
+
success: boolean;
|
|
300
|
+
data: FirecrawlDocument<undefined>[];
|
|
301
|
+
warning?: string;
|
|
302
|
+
error?: string;
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Response interface for crawl/batch scrape error monitoring.
|
|
306
|
+
*/
|
|
307
|
+
interface CrawlErrorsResponse {
|
|
308
|
+
/**
|
|
309
|
+
* Scrapes that errored out + error details
|
|
310
|
+
*/
|
|
311
|
+
errors: {
|
|
312
|
+
id: string;
|
|
313
|
+
timestamp?: string;
|
|
314
|
+
url: string;
|
|
315
|
+
error: string;
|
|
316
|
+
}[];
|
|
317
|
+
/**
|
|
318
|
+
* URLs blocked by robots.txt
|
|
319
|
+
*/
|
|
320
|
+
robotsBlocked: string[];
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Parameters for deep research operations.
|
|
324
|
+
* Defines options for conducting deep research on a topic.
|
|
325
|
+
*/
|
|
326
|
+
interface DeepResearchParams {
|
|
327
|
+
/**
|
|
328
|
+
* Maximum depth of research iterations (1-10)
|
|
329
|
+
* @default 7
|
|
330
|
+
*/
|
|
331
|
+
maxDepth?: number;
|
|
332
|
+
/**
|
|
333
|
+
* Time limit in seconds (30-300)
|
|
334
|
+
* @default 270
|
|
335
|
+
*/
|
|
336
|
+
timeLimit?: number;
|
|
337
|
+
/**
|
|
338
|
+
* Maximum number of URLs to analyze (1-1000)
|
|
339
|
+
* @default 20
|
|
340
|
+
*/
|
|
341
|
+
maxUrls?: number;
|
|
342
|
+
/**
|
|
343
|
+
* Experimental flag for streaming steps
|
|
344
|
+
*/
|
|
345
|
+
__experimental_streamSteps?: boolean;
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* Response interface for deep research operations.
|
|
349
|
+
*/
|
|
350
|
+
interface DeepResearchResponse {
|
|
351
|
+
success: boolean;
|
|
352
|
+
id: string;
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Status response interface for deep research operations.
|
|
356
|
+
*/
|
|
357
|
+
interface DeepResearchStatusResponse {
|
|
358
|
+
success: boolean;
|
|
359
|
+
data: {
|
|
360
|
+
findings: Array<{
|
|
361
|
+
text: string;
|
|
362
|
+
source: string;
|
|
363
|
+
}>;
|
|
364
|
+
finalAnalysis: string;
|
|
365
|
+
analysis: string;
|
|
366
|
+
completedSteps: number;
|
|
367
|
+
totalSteps: number;
|
|
368
|
+
};
|
|
369
|
+
status: "processing" | "completed" | "failed";
|
|
370
|
+
error?: string;
|
|
371
|
+
expiresAt: string;
|
|
372
|
+
currentDepth: number;
|
|
373
|
+
maxDepth: number;
|
|
374
|
+
activities: Array<{
|
|
375
|
+
type: string;
|
|
376
|
+
status: string;
|
|
377
|
+
message: string;
|
|
378
|
+
timestamp: string;
|
|
379
|
+
depth: number;
|
|
380
|
+
}>;
|
|
381
|
+
sources: Array<{
|
|
382
|
+
url: string;
|
|
383
|
+
title: string;
|
|
384
|
+
description: string;
|
|
385
|
+
}>;
|
|
386
|
+
summaries: string[];
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* Parameters for LLMs.txt generation operations.
|
|
390
|
+
*/
|
|
391
|
+
interface GenerateLLMsTextParams {
|
|
392
|
+
/**
|
|
393
|
+
* Maximum number of URLs to process (1-100)
|
|
394
|
+
* @default 10
|
|
395
|
+
*/
|
|
396
|
+
maxUrls?: number;
|
|
397
|
+
/**
|
|
398
|
+
* Whether to show the full LLMs-full.txt in the response
|
|
399
|
+
* @default false
|
|
400
|
+
*/
|
|
401
|
+
showFullText?: boolean;
|
|
402
|
+
/**
|
|
403
|
+
* Experimental flag for streaming
|
|
404
|
+
*/
|
|
405
|
+
__experimental_stream?: boolean;
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* Response interface for LLMs.txt generation operations.
|
|
409
|
+
*/
|
|
410
|
+
interface GenerateLLMsTextResponse {
|
|
411
|
+
success: boolean;
|
|
412
|
+
id: string;
|
|
413
|
+
}
|
|
414
|
+
/**
|
|
415
|
+
* Status response interface for LLMs.txt generation operations.
|
|
416
|
+
*/
|
|
417
|
+
interface GenerateLLMsTextStatusResponse {
|
|
418
|
+
success: boolean;
|
|
419
|
+
data: {
|
|
420
|
+
llmstxt: string;
|
|
421
|
+
llmsfulltxt?: string;
|
|
422
|
+
};
|
|
423
|
+
status: "processing" | "completed" | "failed";
|
|
424
|
+
error?: string;
|
|
425
|
+
expiresAt: string;
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* Main class for interacting with the Firecrawl API.
|
|
429
|
+
* Provides methods for scraping, searching, crawling, and mapping web content.
|
|
430
|
+
*/
|
|
431
|
+
declare class FirecrawlApp {
|
|
432
|
+
apiKey: string;
|
|
433
|
+
apiUrl: string;
|
|
434
|
+
private isCloudService;
|
|
435
|
+
/**
|
|
436
|
+
* Initializes a new instance of the FirecrawlApp class.
|
|
437
|
+
* @param config - Configuration options for the FirecrawlApp instance.
|
|
438
|
+
*/
|
|
439
|
+
constructor({ apiKey, apiUrl }: FirecrawlAppConfig);
|
|
440
|
+
/**
|
|
441
|
+
* Scrapes a URL using the Firecrawl API.
|
|
442
|
+
* @param url - The URL to scrape.
|
|
443
|
+
* @param params - Additional parameters for the scrape request.
|
|
444
|
+
* @returns The response from the scrape operation.
|
|
445
|
+
*/
|
|
446
|
+
scrapeUrl<T extends zt.ZodSchema, ActionsSchema extends (Action[] | undefined) = undefined>(url: string, params?: ScrapeParams<T, ActionsSchema>): Promise<ScrapeResponse<zt.infer<T>, ActionsSchema extends Action[] ? ActionsResult : never> | ErrorResponse>;
|
|
447
|
+
/**
|
|
448
|
+
* Searches using the Firecrawl API and optionally scrapes the results.
|
|
449
|
+
* @param query - The search query string.
|
|
450
|
+
* @param params - Optional parameters for the search request.
|
|
451
|
+
* @returns The response from the search operation.
|
|
452
|
+
*/
|
|
453
|
+
search(query: string, params?: SearchParams | Record<string, any>): Promise<SearchResponse>;
|
|
454
|
+
/**
|
|
455
|
+
* Initiates a crawl job for a URL using the Firecrawl API.
|
|
456
|
+
* @param url - The URL to crawl.
|
|
457
|
+
* @param params - Additional parameters for the crawl request.
|
|
458
|
+
* @param pollInterval - Time in seconds for job status checks.
|
|
459
|
+
* @param idempotencyKey - Optional idempotency key for the request.
|
|
460
|
+
* @returns The response from the crawl operation.
|
|
461
|
+
*/
|
|
462
|
+
crawlUrl(url: string, params?: CrawlParams, pollInterval?: number, idempotencyKey?: string): Promise<CrawlStatusResponse | ErrorResponse>;
|
|
463
|
+
asyncCrawlUrl(url: string, params?: CrawlParams, idempotencyKey?: string): Promise<CrawlResponse | ErrorResponse>;
|
|
464
|
+
/**
|
|
465
|
+
* Checks the status of a crawl job using the Firecrawl API.
|
|
466
|
+
* @param id - The ID of the crawl operation.
|
|
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 crawl 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 required if you're not providing `nextURL`. Only used when `getAllData = false`.
|
|
470
|
+
* @param limit - How many entries to return. Only used when `getAllData = false`.
|
|
471
|
+
* @returns The response containing the job status.
|
|
472
|
+
*/
|
|
473
|
+
checkCrawlStatus(id?: string, getAllData?: boolean, nextURL?: string, skip?: number, limit?: number): Promise<CrawlStatusResponse | ErrorResponse>;
|
|
474
|
+
/**
|
|
475
|
+
* Returns information about crawl errors.
|
|
476
|
+
* @param id - The ID of the crawl operation.
|
|
477
|
+
* @returns Information about crawl errors.
|
|
478
|
+
*/
|
|
479
|
+
checkCrawlErrors(id: string): Promise<CrawlErrorsResponse | ErrorResponse>;
|
|
480
|
+
/**
|
|
481
|
+
* Cancels a crawl job using the Firecrawl API.
|
|
482
|
+
* @param id - The ID of the crawl operation.
|
|
483
|
+
* @returns The response from the cancel crawl operation.
|
|
484
|
+
*/
|
|
485
|
+
cancelCrawl(id: string): Promise<ErrorResponse>;
|
|
486
|
+
/**
|
|
487
|
+
* Initiates a crawl job and returns a CrawlWatcher to monitor the job via WebSocket.
|
|
488
|
+
* @param url - The URL to crawl.
|
|
489
|
+
* @param params - Additional parameters for the crawl request.
|
|
490
|
+
* @param idempotencyKey - Optional idempotency key for the request.
|
|
491
|
+
* @returns A CrawlWatcher instance to monitor the crawl job.
|
|
492
|
+
*/
|
|
493
|
+
crawlUrlAndWatch(url: string, params?: CrawlParams, idempotencyKey?: string): Promise<CrawlWatcher>;
|
|
494
|
+
/**
|
|
495
|
+
* Maps a URL using the Firecrawl API.
|
|
496
|
+
* @param url - The URL to map.
|
|
497
|
+
* @param params - Additional parameters for the map request.
|
|
498
|
+
* @returns The response from the map operation.
|
|
499
|
+
*/
|
|
500
|
+
mapUrl(url: string, params?: MapParams): Promise<MapResponse | ErrorResponse>;
|
|
501
|
+
/**
|
|
502
|
+
* Initiates a batch scrape job for multiple URLs using the Firecrawl API.
|
|
503
|
+
* @param url - The URLs to scrape.
|
|
504
|
+
* @param params - Additional parameters for the scrape request.
|
|
505
|
+
* @param pollInterval - Time in seconds for job status checks.
|
|
506
|
+
* @param idempotencyKey - Optional idempotency key for the request.
|
|
507
|
+
* @param webhook - Optional webhook for the batch scrape.
|
|
508
|
+
* @returns The response from the crawl operation.
|
|
509
|
+
*/
|
|
510
|
+
batchScrapeUrls(urls: string[], params?: ScrapeParams, pollInterval?: number, idempotencyKey?: string, webhook?: CrawlParams["webhook"], ignoreInvalidURLs?: boolean): Promise<BatchScrapeStatusResponse | ErrorResponse>;
|
|
511
|
+
asyncBatchScrapeUrls(urls: string[], params?: ScrapeParams, idempotencyKey?: string, webhook?: CrawlParams["webhook"], ignoreInvalidURLs?: boolean): Promise<BatchScrapeResponse | ErrorResponse>;
|
|
512
|
+
/**
|
|
513
|
+
* Initiates a batch scrape job and returns a CrawlWatcher to monitor the job via WebSocket.
|
|
514
|
+
* @param urls - The URL to scrape.
|
|
515
|
+
* @param params - Additional parameters for the scrape request.
|
|
516
|
+
* @param idempotencyKey - Optional idempotency key for the request.
|
|
517
|
+
* @returns A CrawlWatcher instance to monitor the crawl job.
|
|
518
|
+
*/
|
|
519
|
+
batchScrapeUrlsAndWatch(urls: string[], params?: ScrapeParams, idempotencyKey?: string, webhook?: CrawlParams["webhook"], ignoreInvalidURLs?: boolean): Promise<CrawlWatcher>;
|
|
520
|
+
/**
|
|
521
|
+
* Checks the status of a batch scrape job using the Firecrawl API.
|
|
522
|
+
* @param id - The ID of the batch scrape operation.
|
|
523
|
+
* @param getAllData - Paginate through all the pages of documents, returning the full list of all documents. (default: `false`)
|
|
524
|
+
* @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`.
|
|
525
|
+
* @param skip - How many entries to skip to paginate. Only used when `getAllData = false`.
|
|
526
|
+
* @param limit - How many entries to return. Only used when `getAllData = false`.
|
|
527
|
+
* @returns The response containing the job status.
|
|
528
|
+
*/
|
|
529
|
+
checkBatchScrapeStatus(id?: string, getAllData?: boolean, nextURL?: string, skip?: number, limit?: number): Promise<BatchScrapeStatusResponse | ErrorResponse>;
|
|
530
|
+
/**
|
|
531
|
+
* Returns information about batch scrape errors.
|
|
532
|
+
* @param id - The ID of the batch scrape operation.
|
|
533
|
+
* @returns Information about batch scrape errors.
|
|
534
|
+
*/
|
|
535
|
+
checkBatchScrapeErrors(id: string): Promise<CrawlErrorsResponse | ErrorResponse>;
|
|
536
|
+
/**
|
|
537
|
+
* Extracts information from URLs using the Firecrawl API.
|
|
538
|
+
* Currently in Beta. Expect breaking changes on future minor versions.
|
|
539
|
+
* @param url - The URL to extract information from.
|
|
540
|
+
* @param params - Additional parameters for the extract request.
|
|
541
|
+
* @returns The response from the extract operation.
|
|
542
|
+
*/
|
|
543
|
+
extract<T extends zt.ZodSchema = any>(urls: string[], params?: ExtractParams<T>): Promise<ExtractResponse<zt.infer<T>> | ErrorResponse>;
|
|
544
|
+
/**
|
|
545
|
+
* Initiates an asynchronous extract job for a URL using the Firecrawl API.
|
|
546
|
+
* @param url - The URL to extract data from.
|
|
547
|
+
* @param params - Additional parameters for the extract request.
|
|
548
|
+
* @param idempotencyKey - Optional idempotency key for the request.
|
|
549
|
+
* @returns The response from the extract operation.
|
|
550
|
+
*/
|
|
551
|
+
asyncExtract(urls: string[], params?: ExtractParams, idempotencyKey?: string): Promise<ExtractResponse | ErrorResponse>;
|
|
552
|
+
/**
|
|
553
|
+
* Retrieves the status of an extract job.
|
|
554
|
+
* @param jobId - The ID of the extract job.
|
|
555
|
+
* @returns The status of the extract job.
|
|
556
|
+
*/
|
|
557
|
+
getExtractStatus(jobId: string): Promise<any>;
|
|
558
|
+
/**
|
|
559
|
+
* Prepares the headers for an API request.
|
|
560
|
+
* @param idempotencyKey - Optional key to ensure idempotency.
|
|
561
|
+
* @returns The prepared headers.
|
|
562
|
+
*/
|
|
563
|
+
prepareHeaders(idempotencyKey?: string): AxiosRequestHeaders;
|
|
564
|
+
/**
|
|
565
|
+
* Sends a POST request to the specified URL.
|
|
566
|
+
* @param url - The URL to send the request to.
|
|
567
|
+
* @param data - The data to send in the request.
|
|
568
|
+
* @param headers - The headers for the request.
|
|
569
|
+
* @returns The response from the POST request.
|
|
570
|
+
*/
|
|
571
|
+
postRequest(url: string, data: any, headers: AxiosRequestHeaders): Promise<AxiosResponse>;
|
|
572
|
+
/**
|
|
573
|
+
* Sends a GET request to the specified URL.
|
|
574
|
+
* @param url - The URL to send the request to.
|
|
575
|
+
* @param headers - The headers for the request.
|
|
576
|
+
* @returns The response from the GET request.
|
|
577
|
+
*/
|
|
578
|
+
getRequest(url: string, headers: AxiosRequestHeaders): Promise<AxiosResponse>;
|
|
579
|
+
/**
|
|
580
|
+
* Sends a DELETE request to the specified URL.
|
|
581
|
+
* @param url - The URL to send the request to.
|
|
582
|
+
* @param headers - The headers for the request.
|
|
583
|
+
* @returns The response from the DELETE request.
|
|
584
|
+
*/
|
|
585
|
+
deleteRequest(url: string, headers: AxiosRequestHeaders): Promise<AxiosResponse>;
|
|
586
|
+
/**
|
|
587
|
+
* Monitors the status of a crawl job until completion or failure.
|
|
588
|
+
* @param id - The ID of the crawl operation.
|
|
589
|
+
* @param headers - The headers for the request.
|
|
590
|
+
* @param checkInterval - Interval in seconds for job status checks.
|
|
591
|
+
* @param checkUrl - Optional URL to check the status (used for v1 API)
|
|
592
|
+
* @returns The final job status or data.
|
|
593
|
+
*/
|
|
594
|
+
monitorJobStatus(id: string, headers: AxiosRequestHeaders, checkInterval: number): Promise<CrawlStatusResponse | ErrorResponse>;
|
|
595
|
+
/**
|
|
596
|
+
* Handles errors from API responses.
|
|
597
|
+
* @param {AxiosResponse} response - The response from the API.
|
|
598
|
+
* @param {string} action - The action being performed when the error occurred.
|
|
599
|
+
*/
|
|
600
|
+
handleError(response: AxiosResponse, action: string): void;
|
|
601
|
+
/**
|
|
602
|
+
* Initiates a deep research operation on a given topic and polls until completion.
|
|
603
|
+
* @param topic - The topic to research.
|
|
604
|
+
* @param params - Parameters for the deep research operation.
|
|
605
|
+
* @param onActivity - Optional callback to receive activity updates in real-time.
|
|
606
|
+
* @returns The final research results.
|
|
607
|
+
*/
|
|
608
|
+
__deepResearch(topic: string, params: DeepResearchParams, onActivity?: (activity: {
|
|
609
|
+
type: string;
|
|
610
|
+
status: string;
|
|
611
|
+
message: string;
|
|
612
|
+
timestamp: string;
|
|
613
|
+
depth: number;
|
|
614
|
+
}) => void): Promise<DeepResearchStatusResponse | ErrorResponse>;
|
|
615
|
+
/**
|
|
616
|
+
* Initiates a deep research operation on a given topic without polling.
|
|
617
|
+
* @param params - Parameters for the deep research operation.
|
|
618
|
+
* @returns The response containing the research job ID.
|
|
619
|
+
*/
|
|
620
|
+
__asyncDeepResearch(topic: string, params: DeepResearchParams): Promise<DeepResearchResponse | ErrorResponse>;
|
|
621
|
+
/**
|
|
622
|
+
* Checks the status of a deep research operation.
|
|
623
|
+
* @param id - The ID of the deep research operation.
|
|
624
|
+
* @returns The current status and results of the research operation.
|
|
625
|
+
*/
|
|
626
|
+
__checkDeepResearchStatus(id: string): Promise<DeepResearchStatusResponse | ErrorResponse>;
|
|
627
|
+
/**
|
|
628
|
+
* Generates LLMs.txt for a given URL and polls until completion.
|
|
629
|
+
* @param url - The URL to generate LLMs.txt from.
|
|
630
|
+
* @param params - Parameters for the LLMs.txt generation operation.
|
|
631
|
+
* @returns The final generation results.
|
|
632
|
+
*/
|
|
633
|
+
generateLLMsText(url: string, params?: GenerateLLMsTextParams): Promise<GenerateLLMsTextStatusResponse | ErrorResponse>;
|
|
634
|
+
/**
|
|
635
|
+
* Initiates a LLMs.txt generation operation without polling.
|
|
636
|
+
* @param url - The URL to generate LLMs.txt from.
|
|
637
|
+
* @param params - Parameters for the LLMs.txt generation operation.
|
|
638
|
+
* @returns The response containing the generation job ID.
|
|
639
|
+
*/
|
|
640
|
+
asyncGenerateLLMsText(url: string, params?: GenerateLLMsTextParams): Promise<GenerateLLMsTextResponse | ErrorResponse>;
|
|
641
|
+
/**
|
|
642
|
+
* Checks the status of a LLMs.txt generation operation.
|
|
643
|
+
* @param id - The ID of the LLMs.txt generation operation.
|
|
644
|
+
* @returns The current status and results of the generation operation.
|
|
645
|
+
*/
|
|
646
|
+
checkGenerateLLMsTextStatus(id: string): Promise<GenerateLLMsTextStatusResponse | ErrorResponse>;
|
|
647
|
+
}
|
|
648
|
+
interface CrawlWatcherEvents {
|
|
649
|
+
document: CustomEvent<FirecrawlDocument<undefined>>;
|
|
650
|
+
done: CustomEvent<{
|
|
651
|
+
status: CrawlStatusResponse["status"];
|
|
652
|
+
data: FirecrawlDocument<undefined>[];
|
|
653
|
+
}>;
|
|
654
|
+
error: CustomEvent<{
|
|
655
|
+
status: CrawlStatusResponse["status"];
|
|
656
|
+
data: FirecrawlDocument<undefined>[];
|
|
657
|
+
error: string;
|
|
658
|
+
}>;
|
|
659
|
+
}
|
|
660
|
+
declare class CrawlWatcher extends TypedEventTarget<CrawlWatcherEvents> {
|
|
661
|
+
private ws;
|
|
662
|
+
data: FirecrawlDocument<undefined>[];
|
|
663
|
+
status: CrawlStatusResponse["status"];
|
|
664
|
+
id: string;
|
|
665
|
+
constructor(id: string, app: FirecrawlApp);
|
|
666
|
+
close(): void;
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
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 GenerateLLMsTextParams, type GenerateLLMsTextResponse, type GenerateLLMsTextStatusResponse, type MapParams, type MapResponse, type ScrapeParams, type ScrapeResponse, type SearchParams, type SearchResponse, FirecrawlApp as default };
|