firecrawl 1.29.3 → 3.0.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/.env.example +4 -2
- package/LICENSE +0 -0
- package/README.md +85 -78
- package/audit-ci.jsonc +4 -0
- package/dist/chunk-JFWW4BWA.js +85 -0
- package/dist/index.cjs +964 -39
- package/dist/index.d.cts +529 -11
- package/dist/index.d.ts +529 -11
- package/dist/index.js +952 -27
- package/dist/package-KYZ3HXR5.js +4 -0
- package/dump.rdb +0 -0
- package/jest.config.js +0 -0
- package/package.json +6 -6
- package/src/__tests__/e2e/v2/batch.test.ts +74 -0
- package/src/__tests__/e2e/v2/crawl.test.ts +182 -0
- package/src/__tests__/e2e/v2/extract.test.ts +70 -0
- package/src/__tests__/e2e/v2/map.test.ts +55 -0
- package/src/__tests__/e2e/v2/scrape.test.ts +130 -0
- package/src/__tests__/e2e/v2/search.test.ts +247 -0
- package/src/__tests__/e2e/v2/usage.test.ts +36 -0
- package/src/__tests__/e2e/v2/utils/idmux.ts +58 -0
- package/src/__tests__/e2e/v2/watcher.test.ts +96 -0
- package/src/__tests__/unit/v2/errorHandler.test.ts +19 -0
- package/src/__tests__/unit/v2/scrape.unit.test.ts +11 -0
- package/src/__tests__/unit/v2/validation.test.ts +59 -0
- package/src/index.backup.ts +2146 -0
- package/src/index.ts +27 -2134
- package/src/v1/index.ts +2158 -0
- package/src/v2/client.ts +281 -0
- package/src/v2/methods/batch.ts +131 -0
- package/src/v2/methods/crawl.ts +160 -0
- package/src/v2/methods/extract.ts +86 -0
- package/src/v2/methods/map.ts +37 -0
- package/src/v2/methods/scrape.ts +26 -0
- package/src/v2/methods/search.ts +69 -0
- package/src/v2/methods/usage.ts +39 -0
- package/src/v2/types.ts +308 -0
- package/src/v2/utils/errorHandler.ts +18 -0
- package/src/v2/utils/getVersion.ts +14 -0
- package/src/v2/utils/httpClient.ts +99 -0
- package/src/v2/utils/validation.ts +50 -0
- package/src/v2/watcher.ts +159 -0
- package/tsconfig.json +2 -1
- package/tsup.config.ts +0 -0
- package/dist/package-Z6F7JDXI.js +0 -111
- /package/src/__tests__/{v1/e2e_withAuth → e2e/v1}/index.test.ts +0 -0
- /package/src/__tests__/{v1/unit → unit/v1}/monitor-job-status-retry.test.ts +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,514 @@
|
|
|
1
|
-
import { AxiosRequestHeaders, AxiosResponse } from 'axios';
|
|
2
1
|
import * as zt from 'zod';
|
|
2
|
+
import { ZodTypeAny, infer } from 'zod';
|
|
3
|
+
import { AxiosResponse, AxiosRequestHeaders } from 'axios';
|
|
4
|
+
import { EventEmitter } from 'events';
|
|
3
5
|
import { TypedEventTarget } from 'typescript-event-target';
|
|
4
6
|
|
|
7
|
+
type FormatString = "markdown" | "html" | "rawHtml" | "links" | "screenshot" | "summary" | "changeTracking" | "json";
|
|
8
|
+
interface Viewport {
|
|
9
|
+
width: number;
|
|
10
|
+
height: number;
|
|
11
|
+
}
|
|
12
|
+
interface Format {
|
|
13
|
+
type: FormatString;
|
|
14
|
+
}
|
|
15
|
+
interface JsonFormat extends Format {
|
|
16
|
+
type: "json";
|
|
17
|
+
prompt?: string;
|
|
18
|
+
schema?: Record<string, unknown> | ZodTypeAny;
|
|
19
|
+
}
|
|
20
|
+
interface ScreenshotFormat {
|
|
21
|
+
type: "screenshot";
|
|
22
|
+
fullPage?: boolean;
|
|
23
|
+
quality?: number;
|
|
24
|
+
viewport?: Viewport | {
|
|
25
|
+
width: number;
|
|
26
|
+
height: number;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
interface ChangeTrackingFormat extends Format {
|
|
30
|
+
type: "changeTracking";
|
|
31
|
+
modes: ("git-diff" | "json")[];
|
|
32
|
+
schema?: Record<string, unknown>;
|
|
33
|
+
prompt?: string;
|
|
34
|
+
tag?: string;
|
|
35
|
+
}
|
|
36
|
+
type FormatOption = FormatString | Format | JsonFormat | ChangeTrackingFormat | ScreenshotFormat;
|
|
37
|
+
interface LocationConfig {
|
|
38
|
+
country?: string;
|
|
39
|
+
languages?: string[];
|
|
40
|
+
}
|
|
41
|
+
interface WaitAction {
|
|
42
|
+
type: "wait";
|
|
43
|
+
milliseconds?: number;
|
|
44
|
+
selector?: string;
|
|
45
|
+
}
|
|
46
|
+
interface ScreenshotAction {
|
|
47
|
+
type: "screenshot";
|
|
48
|
+
fullPage?: boolean;
|
|
49
|
+
quality?: number;
|
|
50
|
+
viewport?: Viewport | {
|
|
51
|
+
width: number;
|
|
52
|
+
height: number;
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
interface ClickAction {
|
|
56
|
+
type: "click";
|
|
57
|
+
selector: string;
|
|
58
|
+
}
|
|
59
|
+
interface WriteAction {
|
|
60
|
+
type: "write";
|
|
61
|
+
text: string;
|
|
62
|
+
}
|
|
63
|
+
interface PressAction {
|
|
64
|
+
type: "press";
|
|
65
|
+
key: string;
|
|
66
|
+
}
|
|
67
|
+
interface ScrollAction {
|
|
68
|
+
type: "scroll";
|
|
69
|
+
direction: "up" | "down";
|
|
70
|
+
selector?: string;
|
|
71
|
+
}
|
|
72
|
+
interface ScrapeAction {
|
|
73
|
+
type: "scrape";
|
|
74
|
+
}
|
|
75
|
+
interface ExecuteJavascriptAction {
|
|
76
|
+
type: "executeJavascript";
|
|
77
|
+
script: string;
|
|
78
|
+
}
|
|
79
|
+
interface PDFAction {
|
|
80
|
+
type: "pdf";
|
|
81
|
+
format?: "A0" | "A1" | "A2" | "A3" | "A4" | "A5" | "A6" | "Letter" | "Legal" | "Tabloid" | "Ledger";
|
|
82
|
+
landscape?: boolean;
|
|
83
|
+
scale?: number;
|
|
84
|
+
}
|
|
85
|
+
type ActionOption = WaitAction | ScreenshotAction | ClickAction | WriteAction | PressAction | ScrollAction | ScrapeAction | ExecuteJavascriptAction | PDFAction;
|
|
86
|
+
interface ScrapeOptions {
|
|
87
|
+
formats?: FormatOption[];
|
|
88
|
+
headers?: Record<string, string>;
|
|
89
|
+
includeTags?: string[];
|
|
90
|
+
excludeTags?: string[];
|
|
91
|
+
onlyMainContent?: boolean;
|
|
92
|
+
timeout?: number;
|
|
93
|
+
waitFor?: number;
|
|
94
|
+
mobile?: boolean;
|
|
95
|
+
parsers?: string[];
|
|
96
|
+
actions?: ActionOption[];
|
|
97
|
+
location?: LocationConfig;
|
|
98
|
+
skipTlsVerification?: boolean;
|
|
99
|
+
removeBase64Images?: boolean;
|
|
100
|
+
fastMode?: boolean;
|
|
101
|
+
useMock?: string;
|
|
102
|
+
blockAds?: boolean;
|
|
103
|
+
proxy?: "basic" | "stealth" | "auto" | string;
|
|
104
|
+
maxAge?: number;
|
|
105
|
+
storeInCache?: boolean;
|
|
106
|
+
}
|
|
107
|
+
interface WebhookConfig {
|
|
108
|
+
url: string;
|
|
109
|
+
headers?: Record<string, string>;
|
|
110
|
+
metadata?: Record<string, string>;
|
|
111
|
+
events?: Array<"completed" | "failed" | "page" | "started">;
|
|
112
|
+
}
|
|
113
|
+
interface DocumentMetadata {
|
|
114
|
+
title?: string;
|
|
115
|
+
description?: string;
|
|
116
|
+
language?: string;
|
|
117
|
+
keywords?: string | string[];
|
|
118
|
+
robots?: string;
|
|
119
|
+
ogTitle?: string;
|
|
120
|
+
ogDescription?: string;
|
|
121
|
+
ogUrl?: string;
|
|
122
|
+
ogImage?: string;
|
|
123
|
+
sourceURL?: string;
|
|
124
|
+
statusCode?: number;
|
|
125
|
+
error?: string;
|
|
126
|
+
[key: string]: unknown;
|
|
127
|
+
}
|
|
128
|
+
interface Document {
|
|
129
|
+
markdown?: string;
|
|
130
|
+
html?: string;
|
|
131
|
+
rawHtml?: string;
|
|
132
|
+
json?: unknown;
|
|
133
|
+
summary?: string;
|
|
134
|
+
metadata?: DocumentMetadata;
|
|
135
|
+
links?: string[];
|
|
136
|
+
screenshot?: string;
|
|
137
|
+
actions?: Record<string, unknown>;
|
|
138
|
+
warning?: string;
|
|
139
|
+
changeTracking?: Record<string, unknown>;
|
|
140
|
+
}
|
|
141
|
+
interface SearchResult {
|
|
142
|
+
url: string;
|
|
143
|
+
title?: string;
|
|
144
|
+
description?: string;
|
|
145
|
+
}
|
|
146
|
+
interface SearchData {
|
|
147
|
+
web?: Array<SearchResult | Document>;
|
|
148
|
+
news?: Array<SearchResult | Document>;
|
|
149
|
+
images?: Array<SearchResult | Document>;
|
|
150
|
+
}
|
|
151
|
+
interface SearchRequest {
|
|
152
|
+
query: string;
|
|
153
|
+
sources?: Array<"web" | "news" | "images" | {
|
|
154
|
+
type: "web" | "news" | "images";
|
|
155
|
+
}>;
|
|
156
|
+
limit?: number;
|
|
157
|
+
tbs?: string;
|
|
158
|
+
location?: string;
|
|
159
|
+
ignoreInvalidURLs?: boolean;
|
|
160
|
+
timeout?: number;
|
|
161
|
+
scrapeOptions?: ScrapeOptions;
|
|
162
|
+
}
|
|
163
|
+
interface CrawlResponse$1 {
|
|
164
|
+
id: string;
|
|
165
|
+
url: string;
|
|
166
|
+
}
|
|
167
|
+
interface CrawlJob {
|
|
168
|
+
status: "scraping" | "completed" | "failed" | "cancelled";
|
|
169
|
+
total: number;
|
|
170
|
+
completed: number;
|
|
171
|
+
creditsUsed?: number;
|
|
172
|
+
expiresAt?: string;
|
|
173
|
+
next?: string | null;
|
|
174
|
+
data: Document[];
|
|
175
|
+
}
|
|
176
|
+
interface BatchScrapeResponse$1 {
|
|
177
|
+
id: string;
|
|
178
|
+
url: string;
|
|
179
|
+
invalidURLs?: string[];
|
|
180
|
+
}
|
|
181
|
+
interface BatchScrapeJob {
|
|
182
|
+
status: "scraping" | "completed" | "failed" | "cancelled";
|
|
183
|
+
completed: number;
|
|
184
|
+
total: number;
|
|
185
|
+
creditsUsed?: number;
|
|
186
|
+
expiresAt?: string;
|
|
187
|
+
next?: string | null;
|
|
188
|
+
data: Document[];
|
|
189
|
+
}
|
|
190
|
+
interface MapData {
|
|
191
|
+
links: SearchResult[];
|
|
192
|
+
}
|
|
193
|
+
interface MapOptions {
|
|
194
|
+
search?: string;
|
|
195
|
+
sitemap?: "only" | "include" | "skip";
|
|
196
|
+
includeSubdomains?: boolean;
|
|
197
|
+
limit?: number;
|
|
198
|
+
timeout?: number;
|
|
199
|
+
}
|
|
200
|
+
interface ExtractResponse$1 {
|
|
201
|
+
success?: boolean;
|
|
202
|
+
id?: string;
|
|
203
|
+
status?: "processing" | "completed" | "failed" | "cancelled";
|
|
204
|
+
data?: unknown;
|
|
205
|
+
error?: string;
|
|
206
|
+
warning?: string;
|
|
207
|
+
sources?: Record<string, unknown>;
|
|
208
|
+
expiresAt?: string;
|
|
209
|
+
}
|
|
210
|
+
interface ConcurrencyCheck {
|
|
211
|
+
concurrency: number;
|
|
212
|
+
maxConcurrency: number;
|
|
213
|
+
}
|
|
214
|
+
interface CreditUsage {
|
|
215
|
+
remainingCredits: number;
|
|
216
|
+
}
|
|
217
|
+
interface TokenUsage {
|
|
218
|
+
remainingTokens: number;
|
|
219
|
+
}
|
|
220
|
+
interface CrawlErrorsResponse$1 {
|
|
221
|
+
errors: {
|
|
222
|
+
id: string;
|
|
223
|
+
timestamp?: string;
|
|
224
|
+
url: string;
|
|
225
|
+
code?: string;
|
|
226
|
+
error: string;
|
|
227
|
+
}[];
|
|
228
|
+
robotsBlocked: string[];
|
|
229
|
+
}
|
|
230
|
+
interface ActiveCrawl {
|
|
231
|
+
id: string;
|
|
232
|
+
teamId: string;
|
|
233
|
+
url: string;
|
|
234
|
+
options?: Record<string, unknown> | null;
|
|
235
|
+
}
|
|
236
|
+
interface ActiveCrawlsResponse {
|
|
237
|
+
success: boolean;
|
|
238
|
+
crawls: ActiveCrawl[];
|
|
239
|
+
}
|
|
240
|
+
interface ErrorDetails {
|
|
241
|
+
code?: string;
|
|
242
|
+
message: string;
|
|
243
|
+
details?: Record<string, unknown>;
|
|
244
|
+
status?: number;
|
|
245
|
+
}
|
|
246
|
+
declare class SdkError extends Error {
|
|
247
|
+
status?: number;
|
|
248
|
+
code?: string;
|
|
249
|
+
details?: unknown;
|
|
250
|
+
constructor(message: string, status?: number, code?: string, details?: unknown);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
interface HttpClientOptions {
|
|
254
|
+
apiKey: string;
|
|
255
|
+
apiUrl: string;
|
|
256
|
+
timeoutMs?: number;
|
|
257
|
+
maxRetries?: number;
|
|
258
|
+
backoffFactor?: number;
|
|
259
|
+
}
|
|
260
|
+
declare class HttpClient {
|
|
261
|
+
private instance;
|
|
262
|
+
private readonly apiKey;
|
|
263
|
+
private readonly apiUrl;
|
|
264
|
+
private readonly maxRetries;
|
|
265
|
+
private readonly backoffFactor;
|
|
266
|
+
constructor(options: HttpClientOptions);
|
|
267
|
+
getApiUrl(): string;
|
|
268
|
+
getApiKey(): string;
|
|
269
|
+
private request;
|
|
270
|
+
private sleep;
|
|
271
|
+
post<T = any>(endpoint: string, body: Record<string, unknown>, headers?: Record<string, string>): Promise<AxiosResponse<T, any>>;
|
|
272
|
+
get<T = any>(endpoint: string, headers?: Record<string, string>): Promise<AxiosResponse<T, any>>;
|
|
273
|
+
delete<T = any>(endpoint: string, headers?: Record<string, string>): Promise<AxiosResponse<T, any>>;
|
|
274
|
+
prepareHeaders(idempotencyKey?: string): Record<string, string>;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
interface CrawlRequest {
|
|
278
|
+
url: string;
|
|
279
|
+
prompt?: string | null;
|
|
280
|
+
excludePaths?: string[] | null;
|
|
281
|
+
includePaths?: string[] | null;
|
|
282
|
+
maxDiscoveryDepth?: number | null;
|
|
283
|
+
sitemap?: "skip" | "include";
|
|
284
|
+
ignoreQueryParameters?: boolean;
|
|
285
|
+
limit?: number | null;
|
|
286
|
+
crawlEntireDomain?: boolean;
|
|
287
|
+
allowExternalLinks?: boolean;
|
|
288
|
+
allowSubdomains?: boolean;
|
|
289
|
+
delay?: number | null;
|
|
290
|
+
maxConcurrency?: number | null;
|
|
291
|
+
webhook?: string | WebhookConfig | null;
|
|
292
|
+
scrapeOptions?: ScrapeOptions | null;
|
|
293
|
+
zeroDataRetention?: boolean;
|
|
294
|
+
}
|
|
295
|
+
declare function startCrawl(http: HttpClient, request: CrawlRequest): Promise<CrawlResponse$1>;
|
|
296
|
+
|
|
297
|
+
interface StartBatchOptions {
|
|
298
|
+
options?: ScrapeOptions;
|
|
299
|
+
webhook?: string | WebhookConfig;
|
|
300
|
+
appendToId?: string;
|
|
301
|
+
ignoreInvalidURLs?: boolean;
|
|
302
|
+
maxConcurrency?: number;
|
|
303
|
+
zeroDataRetention?: boolean;
|
|
304
|
+
integration?: string;
|
|
305
|
+
idempotencyKey?: string;
|
|
306
|
+
}
|
|
307
|
+
declare function startBatchScrape(http: HttpClient, urls: string[], { options, webhook, appendToId, ignoreInvalidURLs, maxConcurrency, zeroDataRetention, integration, idempotencyKey, }?: StartBatchOptions): Promise<BatchScrapeResponse$1>;
|
|
308
|
+
|
|
309
|
+
declare function prepareExtractPayload(args: {
|
|
310
|
+
urls?: string[];
|
|
311
|
+
prompt?: string;
|
|
312
|
+
schema?: Record<string, unknown> | ZodTypeAny;
|
|
313
|
+
systemPrompt?: string;
|
|
314
|
+
allowExternalLinks?: boolean;
|
|
315
|
+
enableWebSearch?: boolean;
|
|
316
|
+
showSources?: boolean;
|
|
317
|
+
scrapeOptions?: ScrapeOptions;
|
|
318
|
+
ignoreInvalidURLs?: boolean;
|
|
319
|
+
}): Record<string, unknown>;
|
|
320
|
+
declare function startExtract(http: HttpClient, args: Parameters<typeof prepareExtractPayload>[0]): Promise<ExtractResponse$1>;
|
|
321
|
+
|
|
322
|
+
type JobKind = "crawl" | "batch";
|
|
323
|
+
interface WatcherOptions {
|
|
324
|
+
kind?: JobKind;
|
|
325
|
+
pollInterval?: number;
|
|
326
|
+
timeout?: number;
|
|
327
|
+
}
|
|
328
|
+
declare class Watcher extends EventEmitter {
|
|
329
|
+
private readonly http;
|
|
330
|
+
private readonly jobId;
|
|
331
|
+
private readonly kind;
|
|
332
|
+
private readonly pollInterval;
|
|
333
|
+
private readonly timeout?;
|
|
334
|
+
private ws?;
|
|
335
|
+
private closed;
|
|
336
|
+
constructor(http: HttpClient, jobId: string, opts?: WatcherOptions);
|
|
337
|
+
private buildWsUrl;
|
|
338
|
+
start(): Promise<void>;
|
|
339
|
+
private attachWsHandlers;
|
|
340
|
+
private emitDocuments;
|
|
341
|
+
private emitSnapshot;
|
|
342
|
+
private pollLoop;
|
|
343
|
+
close(): void;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
type ExtractJsonSchemaFromFormats<Formats> = Formats extends readonly any[] ? Extract<Formats[number], {
|
|
347
|
+
type: "json";
|
|
348
|
+
schema?: unknown;
|
|
349
|
+
}>["schema"] : never;
|
|
350
|
+
type InferredJsonFromOptions<Opts> = Opts extends {
|
|
351
|
+
formats?: infer Fmts;
|
|
352
|
+
} ? ExtractJsonSchemaFromFormats<Fmts> extends ZodTypeAny ? infer<ExtractJsonSchemaFromFormats<Fmts>> : unknown : unknown;
|
|
353
|
+
/**
|
|
354
|
+
* Configuration for the v2 client transport.
|
|
355
|
+
*/
|
|
356
|
+
interface FirecrawlClientOptions {
|
|
357
|
+
/** API key (falls back to FIRECRAWL_API_KEY). */
|
|
358
|
+
apiKey?: string | null;
|
|
359
|
+
/** API base URL (falls back to FIRECRAWL_API_URL or https://api.firecrawl.dev). */
|
|
360
|
+
apiUrl?: string | null;
|
|
361
|
+
/** Per-request timeout in milliseconds (optional). */
|
|
362
|
+
timeoutMs?: number;
|
|
363
|
+
/** Max automatic retries for transient failures (optional). */
|
|
364
|
+
maxRetries?: number;
|
|
365
|
+
/** Exponential backoff factor for retries (optional). */
|
|
366
|
+
backoffFactor?: number;
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* Firecrawl v2 client. Provides typed access to all v2 endpoints and utilities.
|
|
370
|
+
*/
|
|
371
|
+
declare class FirecrawlClient {
|
|
372
|
+
private readonly http;
|
|
373
|
+
/**
|
|
374
|
+
* Create a v2 client.
|
|
375
|
+
* @param options Transport configuration (API key, base URL, timeouts, retries).
|
|
376
|
+
*/
|
|
377
|
+
constructor(options?: FirecrawlClientOptions);
|
|
378
|
+
/**
|
|
379
|
+
* Scrape a single URL.
|
|
380
|
+
* @param url Target URL.
|
|
381
|
+
* @param options Optional scrape options (formats, headers, etc.).
|
|
382
|
+
* @returns Resolved document with requested formats.
|
|
383
|
+
*/
|
|
384
|
+
scrape<Opts extends ScrapeOptions>(url: string, options: Opts): Promise<Omit<Document, "json"> & {
|
|
385
|
+
json?: InferredJsonFromOptions<Opts>;
|
|
386
|
+
}>;
|
|
387
|
+
scrape(url: string, options?: ScrapeOptions): Promise<Document>;
|
|
388
|
+
/**
|
|
389
|
+
* Search the web and optionally scrape each result.
|
|
390
|
+
* @param query Search query string.
|
|
391
|
+
* @param req Additional search options (sources, limit, scrapeOptions, etc.).
|
|
392
|
+
* @returns Structured search results.
|
|
393
|
+
*/
|
|
394
|
+
search(query: string, req?: Omit<SearchRequest, "query">): Promise<SearchData>;
|
|
395
|
+
/**
|
|
396
|
+
* Map a site to discover URLs (sitemap-aware).
|
|
397
|
+
* @param url Root URL to map.
|
|
398
|
+
* @param options Mapping options (sitemap mode, includeSubdomains, limit, timeout).
|
|
399
|
+
* @returns Discovered links.
|
|
400
|
+
*/
|
|
401
|
+
map(url: string, options?: MapOptions): Promise<MapData>;
|
|
402
|
+
/**
|
|
403
|
+
* Start a crawl job (async).
|
|
404
|
+
* @param url Root URL to crawl.
|
|
405
|
+
* @param req Crawl configuration (paths, limits, scrapeOptions, webhook, etc.).
|
|
406
|
+
* @returns Job id and url.
|
|
407
|
+
*/
|
|
408
|
+
startCrawl(url: string, req?: Omit<Parameters<typeof startCrawl>[1], "url">): Promise<CrawlResponse$1>;
|
|
409
|
+
/**
|
|
410
|
+
* Get the status and partial data of a crawl job.
|
|
411
|
+
* @param jobId Crawl job id.
|
|
412
|
+
*/
|
|
413
|
+
getCrawlStatus(jobId: string): Promise<CrawlJob>;
|
|
414
|
+
/**
|
|
415
|
+
* Cancel a crawl job.
|
|
416
|
+
* @param jobId Crawl job id.
|
|
417
|
+
* @returns True if cancelled.
|
|
418
|
+
*/
|
|
419
|
+
cancelCrawl(jobId: string): Promise<boolean>;
|
|
420
|
+
/**
|
|
421
|
+
* Convenience waiter: start a crawl and poll until it finishes.
|
|
422
|
+
* @param url Root URL to crawl.
|
|
423
|
+
* @param req Crawl configuration plus waiter controls (pollInterval, timeout seconds).
|
|
424
|
+
* @returns Final job snapshot.
|
|
425
|
+
*/
|
|
426
|
+
crawl(url: string, req?: Omit<Parameters<typeof startCrawl>[1], "url"> & {
|
|
427
|
+
pollInterval?: number;
|
|
428
|
+
timeout?: number;
|
|
429
|
+
}): Promise<CrawlJob>;
|
|
430
|
+
/**
|
|
431
|
+
* Retrieve crawl errors and robots.txt blocks.
|
|
432
|
+
* @param crawlId Crawl job id.
|
|
433
|
+
*/
|
|
434
|
+
getCrawlErrors(crawlId: string): Promise<CrawlErrorsResponse$1>;
|
|
435
|
+
/**
|
|
436
|
+
* List active crawls for the authenticated team.
|
|
437
|
+
*/
|
|
438
|
+
getActiveCrawls(): Promise<ActiveCrawlsResponse>;
|
|
439
|
+
/**
|
|
440
|
+
* Preview normalized crawl parameters produced by a natural-language prompt.
|
|
441
|
+
* @param url Root URL.
|
|
442
|
+
* @param prompt Natural-language instruction.
|
|
443
|
+
*/
|
|
444
|
+
crawlParamsPreview(url: string, prompt: string): Promise<Record<string, unknown>>;
|
|
445
|
+
/**
|
|
446
|
+
* Start a batch scrape job for multiple URLs (async).
|
|
447
|
+
* @param urls URLs to scrape.
|
|
448
|
+
* @param opts Batch options (scrape options, webhook, concurrency, idempotency key, etc.).
|
|
449
|
+
* @returns Job id and url.
|
|
450
|
+
*/
|
|
451
|
+
startBatchScrape(urls: string[], opts?: Parameters<typeof startBatchScrape>[2]): Promise<BatchScrapeResponse$1>;
|
|
452
|
+
/**
|
|
453
|
+
* Get the status and partial data of a batch scrape job.
|
|
454
|
+
* @param jobId Batch job id.
|
|
455
|
+
*/
|
|
456
|
+
getBatchScrapeStatus(jobId: string): Promise<BatchScrapeJob>;
|
|
457
|
+
/**
|
|
458
|
+
* Retrieve batch scrape errors and robots.txt blocks.
|
|
459
|
+
* @param jobId Batch job id.
|
|
460
|
+
*/
|
|
461
|
+
getBatchScrapeErrors(jobId: string): Promise<CrawlErrorsResponse$1>;
|
|
462
|
+
/**
|
|
463
|
+
* Cancel a batch scrape job.
|
|
464
|
+
* @param jobId Batch job id.
|
|
465
|
+
* @returns True if cancelled.
|
|
466
|
+
*/
|
|
467
|
+
cancelBatchScrape(jobId: string): Promise<boolean>;
|
|
468
|
+
/**
|
|
469
|
+
* Convenience waiter: start a batch scrape and poll until it finishes.
|
|
470
|
+
* @param urls URLs to scrape.
|
|
471
|
+
* @param opts Batch options plus waiter controls (pollInterval, timeout seconds).
|
|
472
|
+
* @returns Final job snapshot.
|
|
473
|
+
*/
|
|
474
|
+
batchScrape(urls: string[], opts?: Parameters<typeof startBatchScrape>[2] & {
|
|
475
|
+
pollInterval?: number;
|
|
476
|
+
timeout?: number;
|
|
477
|
+
}): Promise<BatchScrapeJob>;
|
|
478
|
+
/**
|
|
479
|
+
* Start an extract job (async).
|
|
480
|
+
* @param args Extraction request (urls, schema or prompt, flags).
|
|
481
|
+
* @returns Job id or processing state.
|
|
482
|
+
*/
|
|
483
|
+
startExtract(args: Parameters<typeof startExtract>[1]): Promise<ExtractResponse$1>;
|
|
484
|
+
/**
|
|
485
|
+
* Get extract job status/data.
|
|
486
|
+
* @param jobId Extract job id.
|
|
487
|
+
*/
|
|
488
|
+
getExtractStatus(jobId: string): Promise<ExtractResponse$1>;
|
|
489
|
+
/**
|
|
490
|
+
* Convenience waiter: start an extract and poll until it finishes.
|
|
491
|
+
* @param args Extraction request plus waiter controls (pollInterval, timeout seconds).
|
|
492
|
+
* @returns Final extract response.
|
|
493
|
+
*/
|
|
494
|
+
extract(args: Parameters<typeof startExtract>[1] & {
|
|
495
|
+
pollInterval?: number;
|
|
496
|
+
timeout?: number;
|
|
497
|
+
}): Promise<ExtractResponse$1>;
|
|
498
|
+
/** Current concurrency usage. */
|
|
499
|
+
getConcurrency(): Promise<ConcurrencyCheck>;
|
|
500
|
+
/** Current credit usage. */
|
|
501
|
+
getCreditUsage(): Promise<CreditUsage>;
|
|
502
|
+
/** Recent token usage. */
|
|
503
|
+
getTokenUsage(): Promise<TokenUsage>;
|
|
504
|
+
/**
|
|
505
|
+
* Create a watcher for a crawl or batch job. Emits: `document`, `snapshot`, `done`, `error`.
|
|
506
|
+
* @param jobId Job id.
|
|
507
|
+
* @param opts Watcher options (kind, pollInterval, timeout seconds).
|
|
508
|
+
*/
|
|
509
|
+
watcher(jobId: string, opts?: WatcherOptions): Watcher;
|
|
510
|
+
}
|
|
511
|
+
|
|
5
512
|
/**
|
|
6
513
|
* Configuration interface for FirecrawlApp.
|
|
7
514
|
* @param apiKey - Optional API key for authentication.
|
|
@@ -343,15 +850,6 @@ interface ErrorResponse {
|
|
|
343
850
|
success: false;
|
|
344
851
|
error: string;
|
|
345
852
|
}
|
|
346
|
-
/**
|
|
347
|
-
* Custom error class for Firecrawl.
|
|
348
|
-
* Extends the built-in Error class to include a status code.
|
|
349
|
-
*/
|
|
350
|
-
declare class FirecrawlError extends Error {
|
|
351
|
-
statusCode: number;
|
|
352
|
-
details?: any;
|
|
353
|
-
constructor(message: string, statusCode: number, details?: any);
|
|
354
|
-
}
|
|
355
853
|
/**
|
|
356
854
|
* Parameters for search operations.
|
|
357
855
|
* Defines options for searching and scraping search results.
|
|
@@ -388,6 +886,7 @@ interface CrawlErrorsResponse {
|
|
|
388
886
|
id: string;
|
|
389
887
|
timestamp?: string;
|
|
390
888
|
url: string;
|
|
889
|
+
code?: string;
|
|
391
890
|
error: string;
|
|
392
891
|
}[];
|
|
393
892
|
/**
|
|
@@ -813,4 +1312,23 @@ declare class CrawlWatcher extends TypedEventTarget<CrawlWatcherEvents> {
|
|
|
813
1312
|
close(): void;
|
|
814
1313
|
}
|
|
815
1314
|
|
|
816
|
-
|
|
1315
|
+
/**
|
|
1316
|
+
* Firecrawl JS/TS SDK — unified entrypoint.
|
|
1317
|
+
* - v2 by default on the top‑level client
|
|
1318
|
+
* - v1 available under `.v1` (feature‑frozen)
|
|
1319
|
+
* - Exports: `Firecrawl` (default), `FirecrawlClient` (v2), `FirecrawlAppV1` (v1), and v2 types
|
|
1320
|
+
*/
|
|
1321
|
+
/** Direct v2 client. */
|
|
1322
|
+
|
|
1323
|
+
/** Unified client: extends v2 and adds `.v1` for backward compatibility. */
|
|
1324
|
+
declare class Firecrawl extends FirecrawlClient {
|
|
1325
|
+
/** Feature‑frozen v1 client (lazy). */
|
|
1326
|
+
private _v1?;
|
|
1327
|
+
private _v1Opts;
|
|
1328
|
+
/** @param opts API credentials and base URL. */
|
|
1329
|
+
constructor(opts?: FirecrawlAppConfig);
|
|
1330
|
+
/** Access the legacy v1 client (instantiated on first access). */
|
|
1331
|
+
get v1(): FirecrawlApp;
|
|
1332
|
+
}
|
|
1333
|
+
|
|
1334
|
+
export { type ActionOption, type ActiveCrawl, type ActiveCrawlsResponse, type BatchScrapeJob, type BatchScrapeResponse$1 as BatchScrapeResponse, type ChangeTrackingFormat, type ClickAction, type ConcurrencyCheck, type CrawlErrorsResponse$1 as CrawlErrorsResponse, type CrawlJob, type CrawlResponse$1 as CrawlResponse, type CreditUsage, type Document, type DocumentMetadata, type ErrorDetails, type ExecuteJavascriptAction, type ExtractResponse$1 as ExtractResponse, Firecrawl, FirecrawlApp as FirecrawlAppV1, FirecrawlClient, type Format, type FormatOption, type FormatString, type JsonFormat, type LocationConfig, type MapData, type MapOptions, type PDFAction, type PressAction, type ScrapeAction, type ScrapeOptions, type ScreenshotAction, type ScreenshotFormat, type ScrollAction, SdkError, type SearchData, type SearchRequest, type SearchResult, type TokenUsage, type Viewport, type WaitAction, type WebhookConfig, type WriteAction, Firecrawl as default };
|