@mendable/firecrawl 4.12.1 → 4.13.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/{chunk-GAAHPN3I.js → chunk-37UG5UXZ.js} +3 -2
- package/dist/index.cjs +106 -3
- package/dist/index.d.cts +92 -2
- package/dist/index.d.ts +92 -2
- package/dist/index.js +105 -3
- package/dist/{package-CMQJ5STA.js → package-JD6PB5ZT.js} +1 -1
- package/package.json +1 -1
- package/src/v1/index.ts +6 -1
- package/src/v2/client.ts +57 -0
- package/src/v2/methods/browser.ts +94 -0
- package/src/v2/methods/extract.ts +16 -0
- package/src/v2/types.ts +43 -0
|
@@ -8,7 +8,7 @@ var require_package = __commonJS({
|
|
|
8
8
|
"package.json"(exports, module) {
|
|
9
9
|
module.exports = {
|
|
10
10
|
name: "@mendable/firecrawl-js",
|
|
11
|
-
version: "4.
|
|
11
|
+
version: "4.13.1",
|
|
12
12
|
description: "JavaScript SDK for Firecrawl API",
|
|
13
13
|
main: "dist/index.js",
|
|
14
14
|
types: "dist/index.d.ts",
|
|
@@ -71,7 +71,8 @@ var require_package = __commonJS({
|
|
|
71
71
|
},
|
|
72
72
|
pnpm: {
|
|
73
73
|
overrides: {
|
|
74
|
-
"@isaacs/brace-expansion@<=5.0.0": ">=5.0.1"
|
|
74
|
+
"@isaacs/brace-expansion@<=5.0.0": ">=5.0.1",
|
|
75
|
+
"minimatch@<10.2.1": ">=10.2.1"
|
|
75
76
|
}
|
|
76
77
|
}
|
|
77
78
|
};
|
package/dist/index.cjs
CHANGED
|
@@ -35,7 +35,7 @@ var require_package = __commonJS({
|
|
|
35
35
|
"package.json"(exports2, module2) {
|
|
36
36
|
module2.exports = {
|
|
37
37
|
name: "@mendable/firecrawl-js",
|
|
38
|
-
version: "4.
|
|
38
|
+
version: "4.13.1",
|
|
39
39
|
description: "JavaScript SDK for Firecrawl API",
|
|
40
40
|
main: "dist/index.js",
|
|
41
41
|
types: "dist/index.d.ts",
|
|
@@ -98,7 +98,8 @@ var require_package = __commonJS({
|
|
|
98
98
|
},
|
|
99
99
|
pnpm: {
|
|
100
100
|
overrides: {
|
|
101
|
-
"@isaacs/brace-expansion@<=5.0.0": ">=5.0.1"
|
|
101
|
+
"@isaacs/brace-expansion@<=5.0.0": ">=5.0.1",
|
|
102
|
+
"minimatch@<10.2.1": ">=10.2.1"
|
|
102
103
|
}
|
|
103
104
|
}
|
|
104
105
|
};
|
|
@@ -928,6 +929,64 @@ async function cancelAgent(http, jobId) {
|
|
|
928
929
|
}
|
|
929
930
|
}
|
|
930
931
|
|
|
932
|
+
// src/v2/methods/browser.ts
|
|
933
|
+
async function browser(http, args = {}) {
|
|
934
|
+
const body = {};
|
|
935
|
+
if (args.ttl != null) body.ttl = args.ttl;
|
|
936
|
+
if (args.activityTtl != null) body.activityTtl = args.activityTtl;
|
|
937
|
+
if (args.streamWebView != null) body.streamWebView = args.streamWebView;
|
|
938
|
+
try {
|
|
939
|
+
const res = await http.post("/v2/browser", body);
|
|
940
|
+
if (res.status !== 200) throwForBadResponse(res, "create browser session");
|
|
941
|
+
return res.data;
|
|
942
|
+
} catch (err) {
|
|
943
|
+
if (err?.isAxiosError) return normalizeAxiosError(err, "create browser session");
|
|
944
|
+
throw err;
|
|
945
|
+
}
|
|
946
|
+
}
|
|
947
|
+
async function browserExecute(http, sessionId, args) {
|
|
948
|
+
const body = {
|
|
949
|
+
code: args.code,
|
|
950
|
+
language: args.language ?? "bash"
|
|
951
|
+
};
|
|
952
|
+
if (args.timeout != null) body.timeout = args.timeout;
|
|
953
|
+
try {
|
|
954
|
+
const res = await http.post(
|
|
955
|
+
`/v2/browser/${sessionId}/execute`,
|
|
956
|
+
body
|
|
957
|
+
);
|
|
958
|
+
if (res.status !== 200) throwForBadResponse(res, "execute browser code");
|
|
959
|
+
return res.data;
|
|
960
|
+
} catch (err) {
|
|
961
|
+
if (err?.isAxiosError) return normalizeAxiosError(err, "execute browser code");
|
|
962
|
+
throw err;
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
async function deleteBrowser(http, sessionId) {
|
|
966
|
+
try {
|
|
967
|
+
const res = await http.delete(
|
|
968
|
+
`/v2/browser/${sessionId}`
|
|
969
|
+
);
|
|
970
|
+
if (res.status !== 200) throwForBadResponse(res, "delete browser session");
|
|
971
|
+
return res.data;
|
|
972
|
+
} catch (err) {
|
|
973
|
+
if (err?.isAxiosError) return normalizeAxiosError(err, "delete browser session");
|
|
974
|
+
throw err;
|
|
975
|
+
}
|
|
976
|
+
}
|
|
977
|
+
async function listBrowsers(http, args = {}) {
|
|
978
|
+
let endpoint = "/v2/browser";
|
|
979
|
+
if (args.status) endpoint += `?status=${args.status}`;
|
|
980
|
+
try {
|
|
981
|
+
const res = await http.get(endpoint);
|
|
982
|
+
if (res.status !== 200) throwForBadResponse(res, "list browser sessions");
|
|
983
|
+
return res.data;
|
|
984
|
+
} catch (err) {
|
|
985
|
+
if (err?.isAxiosError) return normalizeAxiosError(err, "list browser sessions");
|
|
986
|
+
throw err;
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
|
|
931
990
|
// src/v2/methods/usage.ts
|
|
932
991
|
async function getConcurrency(http) {
|
|
933
992
|
try {
|
|
@@ -1370,6 +1429,8 @@ var FirecrawlClient = class {
|
|
|
1370
1429
|
* Start an extract job (async).
|
|
1371
1430
|
* @param args Extraction request (urls, schema or prompt, flags).
|
|
1372
1431
|
* @returns Job id or processing state.
|
|
1432
|
+
* @deprecated The extract endpoint is in maintenance mode and its use is discouraged.
|
|
1433
|
+
* Review https://docs.firecrawl.dev/developer-guides/usage-guides/choosing-the-data-extractor to find a replacement.
|
|
1373
1434
|
*/
|
|
1374
1435
|
async startExtract(args) {
|
|
1375
1436
|
return startExtract(this.http, args);
|
|
@@ -1377,6 +1438,8 @@ var FirecrawlClient = class {
|
|
|
1377
1438
|
/**
|
|
1378
1439
|
* Get extract job status/data.
|
|
1379
1440
|
* @param jobId Extract job id.
|
|
1441
|
+
* @deprecated The extract endpoint is in maintenance mode and its use is discouraged.
|
|
1442
|
+
* Review https://docs.firecrawl.dev/developer-guides/usage-guides/choosing-the-data-extractor to find a replacement.
|
|
1380
1443
|
*/
|
|
1381
1444
|
async getExtractStatus(jobId) {
|
|
1382
1445
|
return getExtractStatus(this.http, jobId);
|
|
@@ -1385,6 +1448,8 @@ var FirecrawlClient = class {
|
|
|
1385
1448
|
* Convenience waiter: start an extract and poll until it finishes.
|
|
1386
1449
|
* @param args Extraction request plus waiter controls (pollInterval, timeout seconds).
|
|
1387
1450
|
* @returns Final extract response.
|
|
1451
|
+
* @deprecated The extract endpoint is in maintenance mode and its use is discouraged.
|
|
1452
|
+
* Review https://docs.firecrawl.dev/developer-guides/usage-guides/choosing-the-data-extractor to find a replacement.
|
|
1388
1453
|
*/
|
|
1389
1454
|
async extract(args) {
|
|
1390
1455
|
return extract(this.http, args);
|
|
@@ -1421,6 +1486,39 @@ var FirecrawlClient = class {
|
|
|
1421
1486
|
async cancelAgent(jobId) {
|
|
1422
1487
|
return cancelAgent(this.http, jobId);
|
|
1423
1488
|
}
|
|
1489
|
+
// Browser
|
|
1490
|
+
/**
|
|
1491
|
+
* Create a new browser session.
|
|
1492
|
+
* @param args Session options (ttl, activityTtl, streamWebView).
|
|
1493
|
+
* @returns Session id, CDP URL, live view URL, and expiration time.
|
|
1494
|
+
*/
|
|
1495
|
+
async browser(args = {}) {
|
|
1496
|
+
return browser(this.http, args);
|
|
1497
|
+
}
|
|
1498
|
+
/**
|
|
1499
|
+
* Execute code in a browser session.
|
|
1500
|
+
* @param sessionId Browser session id.
|
|
1501
|
+
* @param args Code, language ("python" | "node" | "bash"), and optional timeout.
|
|
1502
|
+
* @returns Execution result including stdout, stderr, exitCode, and killed status.
|
|
1503
|
+
*/
|
|
1504
|
+
async browserExecute(sessionId, args) {
|
|
1505
|
+
return browserExecute(this.http, sessionId, args);
|
|
1506
|
+
}
|
|
1507
|
+
/**
|
|
1508
|
+
* Delete a browser session.
|
|
1509
|
+
* @param sessionId Browser session id.
|
|
1510
|
+
*/
|
|
1511
|
+
async deleteBrowser(sessionId) {
|
|
1512
|
+
return deleteBrowser(this.http, sessionId);
|
|
1513
|
+
}
|
|
1514
|
+
/**
|
|
1515
|
+
* List browser sessions.
|
|
1516
|
+
* @param args Optional filter (status: "active" | "destroyed").
|
|
1517
|
+
* @returns List of browser sessions.
|
|
1518
|
+
*/
|
|
1519
|
+
async listBrowsers(args = {}) {
|
|
1520
|
+
return listBrowsers(this.http, args);
|
|
1521
|
+
}
|
|
1424
1522
|
// Usage
|
|
1425
1523
|
/** Current concurrency usage. */
|
|
1426
1524
|
async getConcurrency() {
|
|
@@ -2031,10 +2129,11 @@ var FirecrawlApp = class {
|
|
|
2031
2129
|
}
|
|
2032
2130
|
/**
|
|
2033
2131
|
* Extracts information from URLs using the Firecrawl API.
|
|
2034
|
-
* Currently in Beta. Expect breaking changes on future minor versions.
|
|
2035
2132
|
* @param urls - The URLs to extract information from. Optional if using other methods for data extraction.
|
|
2036
2133
|
* @param params - Additional parameters for the extract request.
|
|
2037
2134
|
* @returns The response from the extract operation.
|
|
2135
|
+
* @deprecated The extract endpoint is in maintenance mode and its use is discouraged.
|
|
2136
|
+
* Review https://docs.firecrawl.dev/developer-guides/usage-guides/choosing-the-data-extractor to find a replacement.
|
|
2038
2137
|
*/
|
|
2039
2138
|
async extract(urls, params) {
|
|
2040
2139
|
const headers = this.prepareHeaders();
|
|
@@ -2086,6 +2185,8 @@ var FirecrawlApp = class {
|
|
|
2086
2185
|
* @param params - Additional parameters for the extract request.
|
|
2087
2186
|
* @param idempotencyKey - Optional idempotency key for the request.
|
|
2088
2187
|
* @returns The response from the extract operation.
|
|
2188
|
+
* @deprecated The extract endpoint is in maintenance mode and its use is discouraged.
|
|
2189
|
+
* Review https://docs.firecrawl.dev/developer-guides/usage-guides/choosing-the-data-extractor to find a replacement.
|
|
2089
2190
|
*/
|
|
2090
2191
|
async asyncExtract(urls, params, idempotencyKey) {
|
|
2091
2192
|
const headers = this.prepareHeaders(idempotencyKey);
|
|
@@ -2111,6 +2212,8 @@ var FirecrawlApp = class {
|
|
|
2111
2212
|
* Retrieves the status of an extract job.
|
|
2112
2213
|
* @param jobId - The ID of the extract job.
|
|
2113
2214
|
* @returns The status of the extract job.
|
|
2215
|
+
* @deprecated The extract endpoint is in maintenance mode and its use is discouraged.
|
|
2216
|
+
* Review https://docs.firecrawl.dev/developer-guides/usage-guides/choosing-the-data-extractor to find a replacement.
|
|
2114
2217
|
*/
|
|
2115
2218
|
async getExtractStatus(jobId) {
|
|
2116
2219
|
try {
|
package/dist/index.d.cts
CHANGED
|
@@ -554,6 +554,43 @@ interface QueueStatusResponse$1 {
|
|
|
554
554
|
maxConcurrency: number;
|
|
555
555
|
mostRecentSuccess: string | null;
|
|
556
556
|
}
|
|
557
|
+
interface BrowserCreateResponse {
|
|
558
|
+
success: boolean;
|
|
559
|
+
id?: string;
|
|
560
|
+
cdpUrl?: string;
|
|
561
|
+
liveViewUrl?: string;
|
|
562
|
+
expiresAt?: string;
|
|
563
|
+
error?: string;
|
|
564
|
+
}
|
|
565
|
+
interface BrowserExecuteResponse {
|
|
566
|
+
success: boolean;
|
|
567
|
+
stdout?: string;
|
|
568
|
+
result?: string;
|
|
569
|
+
stderr?: string;
|
|
570
|
+
exitCode?: number;
|
|
571
|
+
killed?: boolean;
|
|
572
|
+
error?: string;
|
|
573
|
+
}
|
|
574
|
+
interface BrowserDeleteResponse {
|
|
575
|
+
success: boolean;
|
|
576
|
+
sessionDurationMs?: number;
|
|
577
|
+
creditsBilled?: number;
|
|
578
|
+
error?: string;
|
|
579
|
+
}
|
|
580
|
+
interface BrowserSession {
|
|
581
|
+
id: string;
|
|
582
|
+
status: string;
|
|
583
|
+
cdpUrl: string;
|
|
584
|
+
liveViewUrl: string;
|
|
585
|
+
streamWebView: boolean;
|
|
586
|
+
createdAt: string;
|
|
587
|
+
lastActivity: string;
|
|
588
|
+
}
|
|
589
|
+
interface BrowserListResponse {
|
|
590
|
+
success: boolean;
|
|
591
|
+
sessions?: BrowserSession[];
|
|
592
|
+
error?: string;
|
|
593
|
+
}
|
|
557
594
|
|
|
558
595
|
interface HttpClientOptions {
|
|
559
596
|
apiKey: string;
|
|
@@ -592,6 +629,10 @@ declare function prepareExtractPayload(args: {
|
|
|
592
629
|
integration?: string;
|
|
593
630
|
agent?: AgentOptions$1;
|
|
594
631
|
}): Record<string, unknown>;
|
|
632
|
+
/**
|
|
633
|
+
* @deprecated The extract endpoint is in maintenance mode and its use is discouraged.
|
|
634
|
+
* Review https://docs.firecrawl.dev/developer-guides/usage-guides/choosing-the-data-extractor to find a replacement.
|
|
635
|
+
*/
|
|
595
636
|
declare function startExtract(http: HttpClient, args: Parameters<typeof prepareExtractPayload>[0]): Promise<ExtractResponse$1>;
|
|
596
637
|
|
|
597
638
|
declare function prepareAgentPayload(args: {
|
|
@@ -606,6 +647,20 @@ declare function prepareAgentPayload(args: {
|
|
|
606
647
|
}): Record<string, unknown>;
|
|
607
648
|
declare function startAgent(http: HttpClient, args: Parameters<typeof prepareAgentPayload>[0]): Promise<AgentResponse>;
|
|
608
649
|
|
|
650
|
+
declare function browser(http: HttpClient, args?: {
|
|
651
|
+
ttl?: number;
|
|
652
|
+
activityTtl?: number;
|
|
653
|
+
streamWebView?: boolean;
|
|
654
|
+
}): Promise<BrowserCreateResponse>;
|
|
655
|
+
declare function browserExecute(http: HttpClient, sessionId: string, args: {
|
|
656
|
+
code: string;
|
|
657
|
+
language?: "python" | "node" | "bash";
|
|
658
|
+
timeout?: number;
|
|
659
|
+
}): Promise<BrowserExecuteResponse>;
|
|
660
|
+
declare function listBrowsers(http: HttpClient, args?: {
|
|
661
|
+
status?: "active" | "destroyed";
|
|
662
|
+
}): Promise<BrowserListResponse>;
|
|
663
|
+
|
|
609
664
|
type JobKind = "crawl" | "batch";
|
|
610
665
|
interface WatcherOptions {
|
|
611
666
|
kind?: JobKind;
|
|
@@ -769,17 +824,23 @@ declare class FirecrawlClient {
|
|
|
769
824
|
* Start an extract job (async).
|
|
770
825
|
* @param args Extraction request (urls, schema or prompt, flags).
|
|
771
826
|
* @returns Job id or processing state.
|
|
827
|
+
* @deprecated The extract endpoint is in maintenance mode and its use is discouraged.
|
|
828
|
+
* Review https://docs.firecrawl.dev/developer-guides/usage-guides/choosing-the-data-extractor to find a replacement.
|
|
772
829
|
*/
|
|
773
830
|
startExtract(args: Parameters<typeof startExtract>[1]): Promise<ExtractResponse$1>;
|
|
774
831
|
/**
|
|
775
832
|
* Get extract job status/data.
|
|
776
833
|
* @param jobId Extract job id.
|
|
834
|
+
* @deprecated The extract endpoint is in maintenance mode and its use is discouraged.
|
|
835
|
+
* Review https://docs.firecrawl.dev/developer-guides/usage-guides/choosing-the-data-extractor to find a replacement.
|
|
777
836
|
*/
|
|
778
837
|
getExtractStatus(jobId: string): Promise<ExtractResponse$1>;
|
|
779
838
|
/**
|
|
780
839
|
* Convenience waiter: start an extract and poll until it finishes.
|
|
781
840
|
* @param args Extraction request plus waiter controls (pollInterval, timeout seconds).
|
|
782
841
|
* @returns Final extract response.
|
|
842
|
+
* @deprecated The extract endpoint is in maintenance mode and its use is discouraged.
|
|
843
|
+
* Review https://docs.firecrawl.dev/developer-guides/usage-guides/choosing-the-data-extractor to find a replacement.
|
|
783
844
|
*/
|
|
784
845
|
extract(args: Parameters<typeof startExtract>[1] & {
|
|
785
846
|
pollInterval?: number;
|
|
@@ -811,6 +872,30 @@ declare class FirecrawlClient {
|
|
|
811
872
|
* @returns True if cancelled.
|
|
812
873
|
*/
|
|
813
874
|
cancelAgent(jobId: string): Promise<boolean>;
|
|
875
|
+
/**
|
|
876
|
+
* Create a new browser session.
|
|
877
|
+
* @param args Session options (ttl, activityTtl, streamWebView).
|
|
878
|
+
* @returns Session id, CDP URL, live view URL, and expiration time.
|
|
879
|
+
*/
|
|
880
|
+
browser(args?: Parameters<typeof browser>[1]): Promise<BrowserCreateResponse>;
|
|
881
|
+
/**
|
|
882
|
+
* Execute code in a browser session.
|
|
883
|
+
* @param sessionId Browser session id.
|
|
884
|
+
* @param args Code, language ("python" | "node" | "bash"), and optional timeout.
|
|
885
|
+
* @returns Execution result including stdout, stderr, exitCode, and killed status.
|
|
886
|
+
*/
|
|
887
|
+
browserExecute(sessionId: string, args: Parameters<typeof browserExecute>[2]): Promise<BrowserExecuteResponse>;
|
|
888
|
+
/**
|
|
889
|
+
* Delete a browser session.
|
|
890
|
+
* @param sessionId Browser session id.
|
|
891
|
+
*/
|
|
892
|
+
deleteBrowser(sessionId: string): Promise<BrowserDeleteResponse>;
|
|
893
|
+
/**
|
|
894
|
+
* List browser sessions.
|
|
895
|
+
* @param args Optional filter (status: "active" | "destroyed").
|
|
896
|
+
* @returns List of browser sessions.
|
|
897
|
+
*/
|
|
898
|
+
listBrowsers(args?: Parameters<typeof listBrowsers>[1]): Promise<BrowserListResponse>;
|
|
814
899
|
/** Current concurrency usage. */
|
|
815
900
|
getConcurrency(): Promise<ConcurrencyCheck>;
|
|
816
901
|
/** Current credit usage. */
|
|
@@ -1524,10 +1609,11 @@ declare class FirecrawlApp {
|
|
|
1524
1609
|
checkBatchScrapeErrors(id: string): Promise<CrawlErrorsResponse | ErrorResponse>;
|
|
1525
1610
|
/**
|
|
1526
1611
|
* Extracts information from URLs using the Firecrawl API.
|
|
1527
|
-
* Currently in Beta. Expect breaking changes on future minor versions.
|
|
1528
1612
|
* @param urls - The URLs to extract information from. Optional if using other methods for data extraction.
|
|
1529
1613
|
* @param params - Additional parameters for the extract request.
|
|
1530
1614
|
* @returns The response from the extract operation.
|
|
1615
|
+
* @deprecated The extract endpoint is in maintenance mode and its use is discouraged.
|
|
1616
|
+
* Review https://docs.firecrawl.dev/developer-guides/usage-guides/choosing-the-data-extractor to find a replacement.
|
|
1531
1617
|
*/
|
|
1532
1618
|
extract<T extends zt.ZodSchema = any>(urls?: string[], params?: ExtractParams<T>): Promise<ExtractResponse<zt.infer<T>> | ErrorResponse>;
|
|
1533
1619
|
/**
|
|
@@ -1536,12 +1622,16 @@ declare class FirecrawlApp {
|
|
|
1536
1622
|
* @param params - Additional parameters for the extract request.
|
|
1537
1623
|
* @param idempotencyKey - Optional idempotency key for the request.
|
|
1538
1624
|
* @returns The response from the extract operation.
|
|
1625
|
+
* @deprecated The extract endpoint is in maintenance mode and its use is discouraged.
|
|
1626
|
+
* Review https://docs.firecrawl.dev/developer-guides/usage-guides/choosing-the-data-extractor to find a replacement.
|
|
1539
1627
|
*/
|
|
1540
1628
|
asyncExtract(urls: string[], params?: ExtractParams, idempotencyKey?: string): Promise<ExtractResponse | ErrorResponse>;
|
|
1541
1629
|
/**
|
|
1542
1630
|
* Retrieves the status of an extract job.
|
|
1543
1631
|
* @param jobId - The ID of the extract job.
|
|
1544
1632
|
* @returns The status of the extract job.
|
|
1633
|
+
* @deprecated The extract endpoint is in maintenance mode and its use is discouraged.
|
|
1634
|
+
* Review https://docs.firecrawl.dev/developer-guides/usage-guides/choosing-the-data-extractor to find a replacement.
|
|
1545
1635
|
*/
|
|
1546
1636
|
getExtractStatus(jobId: string): Promise<any>;
|
|
1547
1637
|
/**
|
|
@@ -1736,4 +1826,4 @@ declare class Firecrawl extends FirecrawlClient {
|
|
|
1736
1826
|
get v1(): FirecrawlApp;
|
|
1737
1827
|
}
|
|
1738
1828
|
|
|
1739
|
-
export { type ActionOption, type ActiveCrawl, type ActiveCrawlsResponse, type AgentOptions$1 as AgentOptions, type AgentResponse, type AgentStatusResponse, type AgentWebhookConfig, type AgentWebhookEvent, type AttributesFormat, type BatchScrapeJob, type BatchScrapeOptions, type BatchScrapeResponse$1 as BatchScrapeResponse, type BrandingProfile, type CategoryOption, type ChangeTrackingFormat, type ClickAction, type ConcurrencyCheck, type CrawlErrorsResponse$1 as CrawlErrorsResponse, type CrawlJob, type CrawlOptions, type CrawlResponse$1 as CrawlResponse, type CreditUsage, type CreditUsageHistoricalPeriod, type CreditUsageHistoricalResponse, type Document, type DocumentMetadata, type ErrorDetails, type ExecuteJavascriptAction, type ExtractResponse$1 as ExtractResponse, Firecrawl, FirecrawlApp as FirecrawlAppV1, FirecrawlClient, type FirecrawlClientOptions, type Format, type FormatOption, type FormatString, JobTimeoutError, type JsonFormat, type LocationConfig$1 as LocationConfig, type MapData, type MapOptions, type PDFAction, type PaginationConfig, type PressAction, type QueueStatusResponse$1 as QueueStatusResponse, type ScrapeAction, type ScrapeOptions, type ScreenshotAction, type ScreenshotFormat, type ScrollAction, SdkError, type SearchData, type SearchRequest, type SearchResultImages, type SearchResultNews, type SearchResultWeb, type TokenUsage, type TokenUsageHistoricalPeriod, type TokenUsageHistoricalResponse, type Viewport, type WaitAction, Watcher, type WatcherOptions, type WebhookConfig, type WriteAction, Firecrawl as default };
|
|
1829
|
+
export { type ActionOption, type ActiveCrawl, type ActiveCrawlsResponse, type AgentOptions$1 as AgentOptions, type AgentResponse, type AgentStatusResponse, type AgentWebhookConfig, type AgentWebhookEvent, type AttributesFormat, type BatchScrapeJob, type BatchScrapeOptions, type BatchScrapeResponse$1 as BatchScrapeResponse, type BrandingProfile, type BrowserCreateResponse, type BrowserDeleteResponse, type BrowserExecuteResponse, type BrowserListResponse, type BrowserSession, type CategoryOption, type ChangeTrackingFormat, type ClickAction, type ConcurrencyCheck, type CrawlErrorsResponse$1 as CrawlErrorsResponse, type CrawlJob, type CrawlOptions, type CrawlResponse$1 as CrawlResponse, type CreditUsage, type CreditUsageHistoricalPeriod, type CreditUsageHistoricalResponse, type Document, type DocumentMetadata, type ErrorDetails, type ExecuteJavascriptAction, type ExtractResponse$1 as ExtractResponse, Firecrawl, FirecrawlApp as FirecrawlAppV1, FirecrawlClient, type FirecrawlClientOptions, type Format, type FormatOption, type FormatString, JobTimeoutError, type JsonFormat, type LocationConfig$1 as LocationConfig, type MapData, type MapOptions, type PDFAction, type PaginationConfig, type PressAction, type QueueStatusResponse$1 as QueueStatusResponse, type ScrapeAction, type ScrapeOptions, type ScreenshotAction, type ScreenshotFormat, type ScrollAction, SdkError, type SearchData, type SearchRequest, type SearchResultImages, type SearchResultNews, type SearchResultWeb, type TokenUsage, type TokenUsageHistoricalPeriod, type TokenUsageHistoricalResponse, type Viewport, type WaitAction, Watcher, type WatcherOptions, type WebhookConfig, type WriteAction, Firecrawl as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -554,6 +554,43 @@ interface QueueStatusResponse$1 {
|
|
|
554
554
|
maxConcurrency: number;
|
|
555
555
|
mostRecentSuccess: string | null;
|
|
556
556
|
}
|
|
557
|
+
interface BrowserCreateResponse {
|
|
558
|
+
success: boolean;
|
|
559
|
+
id?: string;
|
|
560
|
+
cdpUrl?: string;
|
|
561
|
+
liveViewUrl?: string;
|
|
562
|
+
expiresAt?: string;
|
|
563
|
+
error?: string;
|
|
564
|
+
}
|
|
565
|
+
interface BrowserExecuteResponse {
|
|
566
|
+
success: boolean;
|
|
567
|
+
stdout?: string;
|
|
568
|
+
result?: string;
|
|
569
|
+
stderr?: string;
|
|
570
|
+
exitCode?: number;
|
|
571
|
+
killed?: boolean;
|
|
572
|
+
error?: string;
|
|
573
|
+
}
|
|
574
|
+
interface BrowserDeleteResponse {
|
|
575
|
+
success: boolean;
|
|
576
|
+
sessionDurationMs?: number;
|
|
577
|
+
creditsBilled?: number;
|
|
578
|
+
error?: string;
|
|
579
|
+
}
|
|
580
|
+
interface BrowserSession {
|
|
581
|
+
id: string;
|
|
582
|
+
status: string;
|
|
583
|
+
cdpUrl: string;
|
|
584
|
+
liveViewUrl: string;
|
|
585
|
+
streamWebView: boolean;
|
|
586
|
+
createdAt: string;
|
|
587
|
+
lastActivity: string;
|
|
588
|
+
}
|
|
589
|
+
interface BrowserListResponse {
|
|
590
|
+
success: boolean;
|
|
591
|
+
sessions?: BrowserSession[];
|
|
592
|
+
error?: string;
|
|
593
|
+
}
|
|
557
594
|
|
|
558
595
|
interface HttpClientOptions {
|
|
559
596
|
apiKey: string;
|
|
@@ -592,6 +629,10 @@ declare function prepareExtractPayload(args: {
|
|
|
592
629
|
integration?: string;
|
|
593
630
|
agent?: AgentOptions$1;
|
|
594
631
|
}): Record<string, unknown>;
|
|
632
|
+
/**
|
|
633
|
+
* @deprecated The extract endpoint is in maintenance mode and its use is discouraged.
|
|
634
|
+
* Review https://docs.firecrawl.dev/developer-guides/usage-guides/choosing-the-data-extractor to find a replacement.
|
|
635
|
+
*/
|
|
595
636
|
declare function startExtract(http: HttpClient, args: Parameters<typeof prepareExtractPayload>[0]): Promise<ExtractResponse$1>;
|
|
596
637
|
|
|
597
638
|
declare function prepareAgentPayload(args: {
|
|
@@ -606,6 +647,20 @@ declare function prepareAgentPayload(args: {
|
|
|
606
647
|
}): Record<string, unknown>;
|
|
607
648
|
declare function startAgent(http: HttpClient, args: Parameters<typeof prepareAgentPayload>[0]): Promise<AgentResponse>;
|
|
608
649
|
|
|
650
|
+
declare function browser(http: HttpClient, args?: {
|
|
651
|
+
ttl?: number;
|
|
652
|
+
activityTtl?: number;
|
|
653
|
+
streamWebView?: boolean;
|
|
654
|
+
}): Promise<BrowserCreateResponse>;
|
|
655
|
+
declare function browserExecute(http: HttpClient, sessionId: string, args: {
|
|
656
|
+
code: string;
|
|
657
|
+
language?: "python" | "node" | "bash";
|
|
658
|
+
timeout?: number;
|
|
659
|
+
}): Promise<BrowserExecuteResponse>;
|
|
660
|
+
declare function listBrowsers(http: HttpClient, args?: {
|
|
661
|
+
status?: "active" | "destroyed";
|
|
662
|
+
}): Promise<BrowserListResponse>;
|
|
663
|
+
|
|
609
664
|
type JobKind = "crawl" | "batch";
|
|
610
665
|
interface WatcherOptions {
|
|
611
666
|
kind?: JobKind;
|
|
@@ -769,17 +824,23 @@ declare class FirecrawlClient {
|
|
|
769
824
|
* Start an extract job (async).
|
|
770
825
|
* @param args Extraction request (urls, schema or prompt, flags).
|
|
771
826
|
* @returns Job id or processing state.
|
|
827
|
+
* @deprecated The extract endpoint is in maintenance mode and its use is discouraged.
|
|
828
|
+
* Review https://docs.firecrawl.dev/developer-guides/usage-guides/choosing-the-data-extractor to find a replacement.
|
|
772
829
|
*/
|
|
773
830
|
startExtract(args: Parameters<typeof startExtract>[1]): Promise<ExtractResponse$1>;
|
|
774
831
|
/**
|
|
775
832
|
* Get extract job status/data.
|
|
776
833
|
* @param jobId Extract job id.
|
|
834
|
+
* @deprecated The extract endpoint is in maintenance mode and its use is discouraged.
|
|
835
|
+
* Review https://docs.firecrawl.dev/developer-guides/usage-guides/choosing-the-data-extractor to find a replacement.
|
|
777
836
|
*/
|
|
778
837
|
getExtractStatus(jobId: string): Promise<ExtractResponse$1>;
|
|
779
838
|
/**
|
|
780
839
|
* Convenience waiter: start an extract and poll until it finishes.
|
|
781
840
|
* @param args Extraction request plus waiter controls (pollInterval, timeout seconds).
|
|
782
841
|
* @returns Final extract response.
|
|
842
|
+
* @deprecated The extract endpoint is in maintenance mode and its use is discouraged.
|
|
843
|
+
* Review https://docs.firecrawl.dev/developer-guides/usage-guides/choosing-the-data-extractor to find a replacement.
|
|
783
844
|
*/
|
|
784
845
|
extract(args: Parameters<typeof startExtract>[1] & {
|
|
785
846
|
pollInterval?: number;
|
|
@@ -811,6 +872,30 @@ declare class FirecrawlClient {
|
|
|
811
872
|
* @returns True if cancelled.
|
|
812
873
|
*/
|
|
813
874
|
cancelAgent(jobId: string): Promise<boolean>;
|
|
875
|
+
/**
|
|
876
|
+
* Create a new browser session.
|
|
877
|
+
* @param args Session options (ttl, activityTtl, streamWebView).
|
|
878
|
+
* @returns Session id, CDP URL, live view URL, and expiration time.
|
|
879
|
+
*/
|
|
880
|
+
browser(args?: Parameters<typeof browser>[1]): Promise<BrowserCreateResponse>;
|
|
881
|
+
/**
|
|
882
|
+
* Execute code in a browser session.
|
|
883
|
+
* @param sessionId Browser session id.
|
|
884
|
+
* @param args Code, language ("python" | "node" | "bash"), and optional timeout.
|
|
885
|
+
* @returns Execution result including stdout, stderr, exitCode, and killed status.
|
|
886
|
+
*/
|
|
887
|
+
browserExecute(sessionId: string, args: Parameters<typeof browserExecute>[2]): Promise<BrowserExecuteResponse>;
|
|
888
|
+
/**
|
|
889
|
+
* Delete a browser session.
|
|
890
|
+
* @param sessionId Browser session id.
|
|
891
|
+
*/
|
|
892
|
+
deleteBrowser(sessionId: string): Promise<BrowserDeleteResponse>;
|
|
893
|
+
/**
|
|
894
|
+
* List browser sessions.
|
|
895
|
+
* @param args Optional filter (status: "active" | "destroyed").
|
|
896
|
+
* @returns List of browser sessions.
|
|
897
|
+
*/
|
|
898
|
+
listBrowsers(args?: Parameters<typeof listBrowsers>[1]): Promise<BrowserListResponse>;
|
|
814
899
|
/** Current concurrency usage. */
|
|
815
900
|
getConcurrency(): Promise<ConcurrencyCheck>;
|
|
816
901
|
/** Current credit usage. */
|
|
@@ -1524,10 +1609,11 @@ declare class FirecrawlApp {
|
|
|
1524
1609
|
checkBatchScrapeErrors(id: string): Promise<CrawlErrorsResponse | ErrorResponse>;
|
|
1525
1610
|
/**
|
|
1526
1611
|
* Extracts information from URLs using the Firecrawl API.
|
|
1527
|
-
* Currently in Beta. Expect breaking changes on future minor versions.
|
|
1528
1612
|
* @param urls - The URLs to extract information from. Optional if using other methods for data extraction.
|
|
1529
1613
|
* @param params - Additional parameters for the extract request.
|
|
1530
1614
|
* @returns The response from the extract operation.
|
|
1615
|
+
* @deprecated The extract endpoint is in maintenance mode and its use is discouraged.
|
|
1616
|
+
* Review https://docs.firecrawl.dev/developer-guides/usage-guides/choosing-the-data-extractor to find a replacement.
|
|
1531
1617
|
*/
|
|
1532
1618
|
extract<T extends zt.ZodSchema = any>(urls?: string[], params?: ExtractParams<T>): Promise<ExtractResponse<zt.infer<T>> | ErrorResponse>;
|
|
1533
1619
|
/**
|
|
@@ -1536,12 +1622,16 @@ declare class FirecrawlApp {
|
|
|
1536
1622
|
* @param params - Additional parameters for the extract request.
|
|
1537
1623
|
* @param idempotencyKey - Optional idempotency key for the request.
|
|
1538
1624
|
* @returns The response from the extract operation.
|
|
1625
|
+
* @deprecated The extract endpoint is in maintenance mode and its use is discouraged.
|
|
1626
|
+
* Review https://docs.firecrawl.dev/developer-guides/usage-guides/choosing-the-data-extractor to find a replacement.
|
|
1539
1627
|
*/
|
|
1540
1628
|
asyncExtract(urls: string[], params?: ExtractParams, idempotencyKey?: string): Promise<ExtractResponse | ErrorResponse>;
|
|
1541
1629
|
/**
|
|
1542
1630
|
* Retrieves the status of an extract job.
|
|
1543
1631
|
* @param jobId - The ID of the extract job.
|
|
1544
1632
|
* @returns The status of the extract job.
|
|
1633
|
+
* @deprecated The extract endpoint is in maintenance mode and its use is discouraged.
|
|
1634
|
+
* Review https://docs.firecrawl.dev/developer-guides/usage-guides/choosing-the-data-extractor to find a replacement.
|
|
1545
1635
|
*/
|
|
1546
1636
|
getExtractStatus(jobId: string): Promise<any>;
|
|
1547
1637
|
/**
|
|
@@ -1736,4 +1826,4 @@ declare class Firecrawl extends FirecrawlClient {
|
|
|
1736
1826
|
get v1(): FirecrawlApp;
|
|
1737
1827
|
}
|
|
1738
1828
|
|
|
1739
|
-
export { type ActionOption, type ActiveCrawl, type ActiveCrawlsResponse, type AgentOptions$1 as AgentOptions, type AgentResponse, type AgentStatusResponse, type AgentWebhookConfig, type AgentWebhookEvent, type AttributesFormat, type BatchScrapeJob, type BatchScrapeOptions, type BatchScrapeResponse$1 as BatchScrapeResponse, type BrandingProfile, type CategoryOption, type ChangeTrackingFormat, type ClickAction, type ConcurrencyCheck, type CrawlErrorsResponse$1 as CrawlErrorsResponse, type CrawlJob, type CrawlOptions, type CrawlResponse$1 as CrawlResponse, type CreditUsage, type CreditUsageHistoricalPeriod, type CreditUsageHistoricalResponse, type Document, type DocumentMetadata, type ErrorDetails, type ExecuteJavascriptAction, type ExtractResponse$1 as ExtractResponse, Firecrawl, FirecrawlApp as FirecrawlAppV1, FirecrawlClient, type FirecrawlClientOptions, type Format, type FormatOption, type FormatString, JobTimeoutError, type JsonFormat, type LocationConfig$1 as LocationConfig, type MapData, type MapOptions, type PDFAction, type PaginationConfig, type PressAction, type QueueStatusResponse$1 as QueueStatusResponse, type ScrapeAction, type ScrapeOptions, type ScreenshotAction, type ScreenshotFormat, type ScrollAction, SdkError, type SearchData, type SearchRequest, type SearchResultImages, type SearchResultNews, type SearchResultWeb, type TokenUsage, type TokenUsageHistoricalPeriod, type TokenUsageHistoricalResponse, type Viewport, type WaitAction, Watcher, type WatcherOptions, type WebhookConfig, type WriteAction, Firecrawl as default };
|
|
1829
|
+
export { type ActionOption, type ActiveCrawl, type ActiveCrawlsResponse, type AgentOptions$1 as AgentOptions, type AgentResponse, type AgentStatusResponse, type AgentWebhookConfig, type AgentWebhookEvent, type AttributesFormat, type BatchScrapeJob, type BatchScrapeOptions, type BatchScrapeResponse$1 as BatchScrapeResponse, type BrandingProfile, type BrowserCreateResponse, type BrowserDeleteResponse, type BrowserExecuteResponse, type BrowserListResponse, type BrowserSession, type CategoryOption, type ChangeTrackingFormat, type ClickAction, type ConcurrencyCheck, type CrawlErrorsResponse$1 as CrawlErrorsResponse, type CrawlJob, type CrawlOptions, type CrawlResponse$1 as CrawlResponse, type CreditUsage, type CreditUsageHistoricalPeriod, type CreditUsageHistoricalResponse, type Document, type DocumentMetadata, type ErrorDetails, type ExecuteJavascriptAction, type ExtractResponse$1 as ExtractResponse, Firecrawl, FirecrawlApp as FirecrawlAppV1, FirecrawlClient, type FirecrawlClientOptions, type Format, type FormatOption, type FormatString, JobTimeoutError, type JsonFormat, type LocationConfig$1 as LocationConfig, type MapData, type MapOptions, type PDFAction, type PaginationConfig, type PressAction, type QueueStatusResponse$1 as QueueStatusResponse, type ScrapeAction, type ScrapeOptions, type ScreenshotAction, type ScreenshotFormat, type ScrollAction, SdkError, type SearchData, type SearchRequest, type SearchResultImages, type SearchResultNews, type SearchResultWeb, type TokenUsage, type TokenUsageHistoricalPeriod, type TokenUsageHistoricalResponse, type Viewport, type WaitAction, Watcher, type WatcherOptions, type WebhookConfig, type WriteAction, Firecrawl as default };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
require_package
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-37UG5UXZ.js";
|
|
4
4
|
|
|
5
5
|
// src/v2/utils/httpClient.ts
|
|
6
6
|
import axios from "axios";
|
|
@@ -812,6 +812,64 @@ async function cancelAgent(http, jobId) {
|
|
|
812
812
|
}
|
|
813
813
|
}
|
|
814
814
|
|
|
815
|
+
// src/v2/methods/browser.ts
|
|
816
|
+
async function browser(http, args = {}) {
|
|
817
|
+
const body = {};
|
|
818
|
+
if (args.ttl != null) body.ttl = args.ttl;
|
|
819
|
+
if (args.activityTtl != null) body.activityTtl = args.activityTtl;
|
|
820
|
+
if (args.streamWebView != null) body.streamWebView = args.streamWebView;
|
|
821
|
+
try {
|
|
822
|
+
const res = await http.post("/v2/browser", body);
|
|
823
|
+
if (res.status !== 200) throwForBadResponse(res, "create browser session");
|
|
824
|
+
return res.data;
|
|
825
|
+
} catch (err) {
|
|
826
|
+
if (err?.isAxiosError) return normalizeAxiosError(err, "create browser session");
|
|
827
|
+
throw err;
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
async function browserExecute(http, sessionId, args) {
|
|
831
|
+
const body = {
|
|
832
|
+
code: args.code,
|
|
833
|
+
language: args.language ?? "bash"
|
|
834
|
+
};
|
|
835
|
+
if (args.timeout != null) body.timeout = args.timeout;
|
|
836
|
+
try {
|
|
837
|
+
const res = await http.post(
|
|
838
|
+
`/v2/browser/${sessionId}/execute`,
|
|
839
|
+
body
|
|
840
|
+
);
|
|
841
|
+
if (res.status !== 200) throwForBadResponse(res, "execute browser code");
|
|
842
|
+
return res.data;
|
|
843
|
+
} catch (err) {
|
|
844
|
+
if (err?.isAxiosError) return normalizeAxiosError(err, "execute browser code");
|
|
845
|
+
throw err;
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
async function deleteBrowser(http, sessionId) {
|
|
849
|
+
try {
|
|
850
|
+
const res = await http.delete(
|
|
851
|
+
`/v2/browser/${sessionId}`
|
|
852
|
+
);
|
|
853
|
+
if (res.status !== 200) throwForBadResponse(res, "delete browser session");
|
|
854
|
+
return res.data;
|
|
855
|
+
} catch (err) {
|
|
856
|
+
if (err?.isAxiosError) return normalizeAxiosError(err, "delete browser session");
|
|
857
|
+
throw err;
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
async function listBrowsers(http, args = {}) {
|
|
861
|
+
let endpoint = "/v2/browser";
|
|
862
|
+
if (args.status) endpoint += `?status=${args.status}`;
|
|
863
|
+
try {
|
|
864
|
+
const res = await http.get(endpoint);
|
|
865
|
+
if (res.status !== 200) throwForBadResponse(res, "list browser sessions");
|
|
866
|
+
return res.data;
|
|
867
|
+
} catch (err) {
|
|
868
|
+
if (err?.isAxiosError) return normalizeAxiosError(err, "list browser sessions");
|
|
869
|
+
throw err;
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
|
|
815
873
|
// src/v2/methods/usage.ts
|
|
816
874
|
async function getConcurrency(http) {
|
|
817
875
|
try {
|
|
@@ -1254,6 +1312,8 @@ var FirecrawlClient = class {
|
|
|
1254
1312
|
* Start an extract job (async).
|
|
1255
1313
|
* @param args Extraction request (urls, schema or prompt, flags).
|
|
1256
1314
|
* @returns Job id or processing state.
|
|
1315
|
+
* @deprecated The extract endpoint is in maintenance mode and its use is discouraged.
|
|
1316
|
+
* Review https://docs.firecrawl.dev/developer-guides/usage-guides/choosing-the-data-extractor to find a replacement.
|
|
1257
1317
|
*/
|
|
1258
1318
|
async startExtract(args) {
|
|
1259
1319
|
return startExtract(this.http, args);
|
|
@@ -1261,6 +1321,8 @@ var FirecrawlClient = class {
|
|
|
1261
1321
|
/**
|
|
1262
1322
|
* Get extract job status/data.
|
|
1263
1323
|
* @param jobId Extract job id.
|
|
1324
|
+
* @deprecated The extract endpoint is in maintenance mode and its use is discouraged.
|
|
1325
|
+
* Review https://docs.firecrawl.dev/developer-guides/usage-guides/choosing-the-data-extractor to find a replacement.
|
|
1264
1326
|
*/
|
|
1265
1327
|
async getExtractStatus(jobId) {
|
|
1266
1328
|
return getExtractStatus(this.http, jobId);
|
|
@@ -1269,6 +1331,8 @@ var FirecrawlClient = class {
|
|
|
1269
1331
|
* Convenience waiter: start an extract and poll until it finishes.
|
|
1270
1332
|
* @param args Extraction request plus waiter controls (pollInterval, timeout seconds).
|
|
1271
1333
|
* @returns Final extract response.
|
|
1334
|
+
* @deprecated The extract endpoint is in maintenance mode and its use is discouraged.
|
|
1335
|
+
* Review https://docs.firecrawl.dev/developer-guides/usage-guides/choosing-the-data-extractor to find a replacement.
|
|
1272
1336
|
*/
|
|
1273
1337
|
async extract(args) {
|
|
1274
1338
|
return extract(this.http, args);
|
|
@@ -1305,6 +1369,39 @@ var FirecrawlClient = class {
|
|
|
1305
1369
|
async cancelAgent(jobId) {
|
|
1306
1370
|
return cancelAgent(this.http, jobId);
|
|
1307
1371
|
}
|
|
1372
|
+
// Browser
|
|
1373
|
+
/**
|
|
1374
|
+
* Create a new browser session.
|
|
1375
|
+
* @param args Session options (ttl, activityTtl, streamWebView).
|
|
1376
|
+
* @returns Session id, CDP URL, live view URL, and expiration time.
|
|
1377
|
+
*/
|
|
1378
|
+
async browser(args = {}) {
|
|
1379
|
+
return browser(this.http, args);
|
|
1380
|
+
}
|
|
1381
|
+
/**
|
|
1382
|
+
* Execute code in a browser session.
|
|
1383
|
+
* @param sessionId Browser session id.
|
|
1384
|
+
* @param args Code, language ("python" | "node" | "bash"), and optional timeout.
|
|
1385
|
+
* @returns Execution result including stdout, stderr, exitCode, and killed status.
|
|
1386
|
+
*/
|
|
1387
|
+
async browserExecute(sessionId, args) {
|
|
1388
|
+
return browserExecute(this.http, sessionId, args);
|
|
1389
|
+
}
|
|
1390
|
+
/**
|
|
1391
|
+
* Delete a browser session.
|
|
1392
|
+
* @param sessionId Browser session id.
|
|
1393
|
+
*/
|
|
1394
|
+
async deleteBrowser(sessionId) {
|
|
1395
|
+
return deleteBrowser(this.http, sessionId);
|
|
1396
|
+
}
|
|
1397
|
+
/**
|
|
1398
|
+
* List browser sessions.
|
|
1399
|
+
* @param args Optional filter (status: "active" | "destroyed").
|
|
1400
|
+
* @returns List of browser sessions.
|
|
1401
|
+
*/
|
|
1402
|
+
async listBrowsers(args = {}) {
|
|
1403
|
+
return listBrowsers(this.http, args);
|
|
1404
|
+
}
|
|
1308
1405
|
// Usage
|
|
1309
1406
|
/** Current concurrency usage. */
|
|
1310
1407
|
async getConcurrency() {
|
|
@@ -1374,7 +1471,7 @@ var FirecrawlApp = class {
|
|
|
1374
1471
|
if (typeof process !== "undefined" && process.env && process.env.npm_package_version) {
|
|
1375
1472
|
return process.env.npm_package_version;
|
|
1376
1473
|
}
|
|
1377
|
-
const packageJson = await import("./package-
|
|
1474
|
+
const packageJson = await import("./package-JD6PB5ZT.js");
|
|
1378
1475
|
return packageJson.default.version;
|
|
1379
1476
|
} catch (error) {
|
|
1380
1477
|
const isTest = typeof process !== "undefined" && (process.env.JEST_WORKER_ID != null || false);
|
|
@@ -1915,10 +2012,11 @@ var FirecrawlApp = class {
|
|
|
1915
2012
|
}
|
|
1916
2013
|
/**
|
|
1917
2014
|
* Extracts information from URLs using the Firecrawl API.
|
|
1918
|
-
* Currently in Beta. Expect breaking changes on future minor versions.
|
|
1919
2015
|
* @param urls - The URLs to extract information from. Optional if using other methods for data extraction.
|
|
1920
2016
|
* @param params - Additional parameters for the extract request.
|
|
1921
2017
|
* @returns The response from the extract operation.
|
|
2018
|
+
* @deprecated The extract endpoint is in maintenance mode and its use is discouraged.
|
|
2019
|
+
* Review https://docs.firecrawl.dev/developer-guides/usage-guides/choosing-the-data-extractor to find a replacement.
|
|
1922
2020
|
*/
|
|
1923
2021
|
async extract(urls, params) {
|
|
1924
2022
|
const headers = this.prepareHeaders();
|
|
@@ -1970,6 +2068,8 @@ var FirecrawlApp = class {
|
|
|
1970
2068
|
* @param params - Additional parameters for the extract request.
|
|
1971
2069
|
* @param idempotencyKey - Optional idempotency key for the request.
|
|
1972
2070
|
* @returns The response from the extract operation.
|
|
2071
|
+
* @deprecated The extract endpoint is in maintenance mode and its use is discouraged.
|
|
2072
|
+
* Review https://docs.firecrawl.dev/developer-guides/usage-guides/choosing-the-data-extractor to find a replacement.
|
|
1973
2073
|
*/
|
|
1974
2074
|
async asyncExtract(urls, params, idempotencyKey) {
|
|
1975
2075
|
const headers = this.prepareHeaders(idempotencyKey);
|
|
@@ -1995,6 +2095,8 @@ var FirecrawlApp = class {
|
|
|
1995
2095
|
* Retrieves the status of an extract job.
|
|
1996
2096
|
* @param jobId - The ID of the extract job.
|
|
1997
2097
|
* @returns The status of the extract job.
|
|
2098
|
+
* @deprecated The extract endpoint is in maintenance mode and its use is discouraged.
|
|
2099
|
+
* Review https://docs.firecrawl.dev/developer-guides/usage-guides/choosing-the-data-extractor to find a replacement.
|
|
1998
2100
|
*/
|
|
1999
2101
|
async getExtractStatus(jobId) {
|
|
2000
2102
|
try {
|
package/package.json
CHANGED
package/src/v1/index.ts
CHANGED
|
@@ -1278,10 +1278,11 @@ export default class FirecrawlApp {
|
|
|
1278
1278
|
|
|
1279
1279
|
/**
|
|
1280
1280
|
* Extracts information from URLs using the Firecrawl API.
|
|
1281
|
-
* Currently in Beta. Expect breaking changes on future minor versions.
|
|
1282
1281
|
* @param urls - The URLs to extract information from. Optional if using other methods for data extraction.
|
|
1283
1282
|
* @param params - Additional parameters for the extract request.
|
|
1284
1283
|
* @returns The response from the extract operation.
|
|
1284
|
+
* @deprecated The extract endpoint is in maintenance mode and its use is discouraged.
|
|
1285
|
+
* Review https://docs.firecrawl.dev/developer-guides/usage-guides/choosing-the-data-extractor to find a replacement.
|
|
1285
1286
|
*/
|
|
1286
1287
|
async extract<T extends zt.ZodSchema = any>(urls?: string[], params?: ExtractParams<T>): Promise<ExtractResponse<zt.infer<T>> | ErrorResponse> {
|
|
1287
1288
|
const headers = this.prepareHeaders();
|
|
@@ -1337,6 +1338,8 @@ export default class FirecrawlApp {
|
|
|
1337
1338
|
* @param params - Additional parameters for the extract request.
|
|
1338
1339
|
* @param idempotencyKey - Optional idempotency key for the request.
|
|
1339
1340
|
* @returns The response from the extract operation.
|
|
1341
|
+
* @deprecated The extract endpoint is in maintenance mode and its use is discouraged.
|
|
1342
|
+
* Review https://docs.firecrawl.dev/developer-guides/usage-guides/choosing-the-data-extractor to find a replacement.
|
|
1340
1343
|
*/
|
|
1341
1344
|
async asyncExtract(
|
|
1342
1345
|
urls: string[],
|
|
@@ -1369,6 +1372,8 @@ export default class FirecrawlApp {
|
|
|
1369
1372
|
* Retrieves the status of an extract job.
|
|
1370
1373
|
* @param jobId - The ID of the extract job.
|
|
1371
1374
|
* @returns The status of the extract job.
|
|
1375
|
+
* @deprecated The extract endpoint is in maintenance mode and its use is discouraged.
|
|
1376
|
+
* Review https://docs.firecrawl.dev/developer-guides/usage-guides/choosing-the-data-extractor to find a replacement.
|
|
1372
1377
|
*/
|
|
1373
1378
|
async getExtractStatus(jobId: string): Promise<any> {
|
|
1374
1379
|
try {
|
package/src/v2/client.ts
CHANGED
|
@@ -20,6 +20,12 @@ import {
|
|
|
20
20
|
} from "./methods/batch";
|
|
21
21
|
import { startExtract, getExtractStatus, extract as extractWaiter } from "./methods/extract";
|
|
22
22
|
import { startAgent, getAgentStatus, cancelAgent, agent as agentWaiter } from "./methods/agent";
|
|
23
|
+
import {
|
|
24
|
+
browser as browserMethod,
|
|
25
|
+
browserExecute,
|
|
26
|
+
deleteBrowser,
|
|
27
|
+
listBrowsers,
|
|
28
|
+
} from "./methods/browser";
|
|
23
29
|
import { getConcurrency, getCreditUsage, getQueueStatus, getTokenUsage, getCreditUsageHistorical, getTokenUsageHistorical } from "./methods/usage";
|
|
24
30
|
import type {
|
|
25
31
|
Document,
|
|
@@ -40,6 +46,10 @@ import type {
|
|
|
40
46
|
CrawlOptions,
|
|
41
47
|
BatchScrapeOptions,
|
|
42
48
|
PaginationConfig,
|
|
49
|
+
BrowserCreateResponse,
|
|
50
|
+
BrowserExecuteResponse,
|
|
51
|
+
BrowserDeleteResponse,
|
|
52
|
+
BrowserListResponse,
|
|
43
53
|
} from "./types";
|
|
44
54
|
import { Watcher } from "./watcher";
|
|
45
55
|
import type { WatcherOptions } from "./watcher";
|
|
@@ -245,6 +255,8 @@ export class FirecrawlClient {
|
|
|
245
255
|
* Start an extract job (async).
|
|
246
256
|
* @param args Extraction request (urls, schema or prompt, flags).
|
|
247
257
|
* @returns Job id or processing state.
|
|
258
|
+
* @deprecated The extract endpoint is in maintenance mode and its use is discouraged.
|
|
259
|
+
* Review https://docs.firecrawl.dev/developer-guides/usage-guides/choosing-the-data-extractor to find a replacement.
|
|
248
260
|
*/
|
|
249
261
|
async startExtract(args: Parameters<typeof startExtract>[1]): Promise<ExtractResponse> {
|
|
250
262
|
return startExtract(this.http, args);
|
|
@@ -252,6 +264,8 @@ export class FirecrawlClient {
|
|
|
252
264
|
/**
|
|
253
265
|
* Get extract job status/data.
|
|
254
266
|
* @param jobId Extract job id.
|
|
267
|
+
* @deprecated The extract endpoint is in maintenance mode and its use is discouraged.
|
|
268
|
+
* Review https://docs.firecrawl.dev/developer-guides/usage-guides/choosing-the-data-extractor to find a replacement.
|
|
255
269
|
*/
|
|
256
270
|
async getExtractStatus(jobId: string): Promise<ExtractResponse> {
|
|
257
271
|
return getExtractStatus(this.http, jobId);
|
|
@@ -260,6 +274,8 @@ export class FirecrawlClient {
|
|
|
260
274
|
* Convenience waiter: start an extract and poll until it finishes.
|
|
261
275
|
* @param args Extraction request plus waiter controls (pollInterval, timeout seconds).
|
|
262
276
|
* @returns Final extract response.
|
|
277
|
+
* @deprecated The extract endpoint is in maintenance mode and its use is discouraged.
|
|
278
|
+
* Review https://docs.firecrawl.dev/developer-guides/usage-guides/choosing-the-data-extractor to find a replacement.
|
|
263
279
|
*/
|
|
264
280
|
async extract(args: Parameters<typeof startExtract>[1] & { pollInterval?: number; timeout?: number }): Promise<ExtractResponse> {
|
|
265
281
|
return extractWaiter(this.http, args);
|
|
@@ -298,6 +314,47 @@ export class FirecrawlClient {
|
|
|
298
314
|
return cancelAgent(this.http, jobId);
|
|
299
315
|
}
|
|
300
316
|
|
|
317
|
+
// Browser
|
|
318
|
+
/**
|
|
319
|
+
* Create a new browser session.
|
|
320
|
+
* @param args Session options (ttl, activityTtl, streamWebView).
|
|
321
|
+
* @returns Session id, CDP URL, live view URL, and expiration time.
|
|
322
|
+
*/
|
|
323
|
+
async browser(
|
|
324
|
+
args: Parameters<typeof browserMethod>[1] = {}
|
|
325
|
+
): Promise<BrowserCreateResponse> {
|
|
326
|
+
return browserMethod(this.http, args);
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Execute code in a browser session.
|
|
330
|
+
* @param sessionId Browser session id.
|
|
331
|
+
* @param args Code, language ("python" | "node" | "bash"), and optional timeout.
|
|
332
|
+
* @returns Execution result including stdout, stderr, exitCode, and killed status.
|
|
333
|
+
*/
|
|
334
|
+
async browserExecute(
|
|
335
|
+
sessionId: string,
|
|
336
|
+
args: Parameters<typeof browserExecute>[2]
|
|
337
|
+
): Promise<BrowserExecuteResponse> {
|
|
338
|
+
return browserExecute(this.http, sessionId, args);
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Delete a browser session.
|
|
342
|
+
* @param sessionId Browser session id.
|
|
343
|
+
*/
|
|
344
|
+
async deleteBrowser(sessionId: string): Promise<BrowserDeleteResponse> {
|
|
345
|
+
return deleteBrowser(this.http, sessionId);
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* List browser sessions.
|
|
349
|
+
* @param args Optional filter (status: "active" | "destroyed").
|
|
350
|
+
* @returns List of browser sessions.
|
|
351
|
+
*/
|
|
352
|
+
async listBrowsers(
|
|
353
|
+
args: Parameters<typeof listBrowsers>[1] = {}
|
|
354
|
+
): Promise<BrowserListResponse> {
|
|
355
|
+
return listBrowsers(this.http, args);
|
|
356
|
+
}
|
|
357
|
+
|
|
301
358
|
// Usage
|
|
302
359
|
/** Current concurrency usage. */
|
|
303
360
|
async getConcurrency() {
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
BrowserCreateResponse,
|
|
3
|
+
BrowserExecuteResponse,
|
|
4
|
+
BrowserDeleteResponse,
|
|
5
|
+
BrowserListResponse,
|
|
6
|
+
} from "../types";
|
|
7
|
+
import { HttpClient } from "../utils/httpClient";
|
|
8
|
+
import { normalizeAxiosError, throwForBadResponse } from "../utils/errorHandler";
|
|
9
|
+
|
|
10
|
+
export async function browser(
|
|
11
|
+
http: HttpClient,
|
|
12
|
+
args: {
|
|
13
|
+
ttl?: number;
|
|
14
|
+
activityTtl?: number;
|
|
15
|
+
streamWebView?: boolean;
|
|
16
|
+
} = {}
|
|
17
|
+
): Promise<BrowserCreateResponse> {
|
|
18
|
+
const body: Record<string, unknown> = {};
|
|
19
|
+
if (args.ttl != null) body.ttl = args.ttl;
|
|
20
|
+
if (args.activityTtl != null) body.activityTtl = args.activityTtl;
|
|
21
|
+
if (args.streamWebView != null) body.streamWebView = args.streamWebView;
|
|
22
|
+
|
|
23
|
+
try {
|
|
24
|
+
const res = await http.post<BrowserCreateResponse>("/v2/browser", body);
|
|
25
|
+
if (res.status !== 200) throwForBadResponse(res, "create browser session");
|
|
26
|
+
return res.data;
|
|
27
|
+
} catch (err: any) {
|
|
28
|
+
if (err?.isAxiosError) return normalizeAxiosError(err, "create browser session");
|
|
29
|
+
throw err;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export async function browserExecute(
|
|
34
|
+
http: HttpClient,
|
|
35
|
+
sessionId: string,
|
|
36
|
+
args: {
|
|
37
|
+
code: string;
|
|
38
|
+
language?: "python" | "node" | "bash";
|
|
39
|
+
timeout?: number;
|
|
40
|
+
}
|
|
41
|
+
): Promise<BrowserExecuteResponse> {
|
|
42
|
+
const body: Record<string, unknown> = {
|
|
43
|
+
code: args.code,
|
|
44
|
+
language: args.language ?? "bash",
|
|
45
|
+
};
|
|
46
|
+
if (args.timeout != null) body.timeout = args.timeout;
|
|
47
|
+
|
|
48
|
+
try {
|
|
49
|
+
const res = await http.post<BrowserExecuteResponse>(
|
|
50
|
+
`/v2/browser/${sessionId}/execute`,
|
|
51
|
+
body
|
|
52
|
+
);
|
|
53
|
+
if (res.status !== 200) throwForBadResponse(res, "execute browser code");
|
|
54
|
+
return res.data;
|
|
55
|
+
} catch (err: any) {
|
|
56
|
+
if (err?.isAxiosError) return normalizeAxiosError(err, "execute browser code");
|
|
57
|
+
throw err;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export async function deleteBrowser(
|
|
62
|
+
http: HttpClient,
|
|
63
|
+
sessionId: string
|
|
64
|
+
): Promise<BrowserDeleteResponse> {
|
|
65
|
+
try {
|
|
66
|
+
const res = await http.delete<BrowserDeleteResponse>(
|
|
67
|
+
`/v2/browser/${sessionId}`
|
|
68
|
+
);
|
|
69
|
+
if (res.status !== 200) throwForBadResponse(res, "delete browser session");
|
|
70
|
+
return res.data;
|
|
71
|
+
} catch (err: any) {
|
|
72
|
+
if (err?.isAxiosError) return normalizeAxiosError(err, "delete browser session");
|
|
73
|
+
throw err;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export async function listBrowsers(
|
|
78
|
+
http: HttpClient,
|
|
79
|
+
args: {
|
|
80
|
+
status?: "active" | "destroyed";
|
|
81
|
+
} = {}
|
|
82
|
+
): Promise<BrowserListResponse> {
|
|
83
|
+
let endpoint = "/v2/browser";
|
|
84
|
+
if (args.status) endpoint += `?status=${args.status}`;
|
|
85
|
+
|
|
86
|
+
try {
|
|
87
|
+
const res = await http.get<BrowserListResponse>(endpoint);
|
|
88
|
+
if (res.status !== 200) throwForBadResponse(res, "list browser sessions");
|
|
89
|
+
return res.data;
|
|
90
|
+
} catch (err: any) {
|
|
91
|
+
if (err?.isAxiosError) return normalizeAxiosError(err, "list browser sessions");
|
|
92
|
+
throw err;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -38,6 +38,10 @@ function prepareExtractPayload(args: {
|
|
|
38
38
|
return body;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
/**
|
|
42
|
+
* @deprecated The extract endpoint is in maintenance mode and its use is discouraged.
|
|
43
|
+
* Review https://docs.firecrawl.dev/developer-guides/usage-guides/choosing-the-data-extractor to find a replacement.
|
|
44
|
+
*/
|
|
41
45
|
export async function startExtract(http: HttpClient, args: Parameters<typeof prepareExtractPayload>[0]): Promise<ExtractResponse> {
|
|
42
46
|
const payload = prepareExtractPayload(args);
|
|
43
47
|
try {
|
|
@@ -50,6 +54,10 @@ export async function startExtract(http: HttpClient, args: Parameters<typeof pre
|
|
|
50
54
|
}
|
|
51
55
|
}
|
|
52
56
|
|
|
57
|
+
/**
|
|
58
|
+
* @deprecated The extract endpoint is in maintenance mode and its use is discouraged.
|
|
59
|
+
* Review https://docs.firecrawl.dev/developer-guides/usage-guides/choosing-the-data-extractor to find a replacement.
|
|
60
|
+
*/
|
|
53
61
|
export async function getExtractStatus(http: HttpClient, jobId: string): Promise<ExtractResponse> {
|
|
54
62
|
try {
|
|
55
63
|
const res = await http.get<ExtractResponse>(`/v2/extract/${jobId}`);
|
|
@@ -61,6 +69,10 @@ export async function getExtractStatus(http: HttpClient, jobId: string): Promise
|
|
|
61
69
|
}
|
|
62
70
|
}
|
|
63
71
|
|
|
72
|
+
/**
|
|
73
|
+
* @deprecated The extract endpoint is in maintenance mode and its use is discouraged.
|
|
74
|
+
* Review https://docs.firecrawl.dev/developer-guides/usage-guides/choosing-the-data-extractor to find a replacement.
|
|
75
|
+
*/
|
|
64
76
|
export async function waitExtract(
|
|
65
77
|
http: HttpClient,
|
|
66
78
|
jobId: string,
|
|
@@ -76,6 +88,10 @@ export async function waitExtract(
|
|
|
76
88
|
}
|
|
77
89
|
}
|
|
78
90
|
|
|
91
|
+
/**
|
|
92
|
+
* @deprecated The extract endpoint is in maintenance mode and its use is discouraged.
|
|
93
|
+
* Review https://docs.firecrawl.dev/developer-guides/usage-guides/choosing-the-data-extractor to find a replacement.
|
|
94
|
+
*/
|
|
79
95
|
export async function extract(
|
|
80
96
|
http: HttpClient,
|
|
81
97
|
args: Parameters<typeof prepareExtractPayload>[0] & { pollInterval?: number; timeout?: number }
|
package/src/v2/types.ts
CHANGED
|
@@ -683,3 +683,46 @@ export interface QueueStatusResponse {
|
|
|
683
683
|
maxConcurrency: number;
|
|
684
684
|
mostRecentSuccess: string | null;
|
|
685
685
|
}
|
|
686
|
+
|
|
687
|
+
// Browser types
|
|
688
|
+
export interface BrowserCreateResponse {
|
|
689
|
+
success: boolean;
|
|
690
|
+
id?: string;
|
|
691
|
+
cdpUrl?: string;
|
|
692
|
+
liveViewUrl?: string;
|
|
693
|
+
expiresAt?: string;
|
|
694
|
+
error?: string;
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
export interface BrowserExecuteResponse {
|
|
698
|
+
success: boolean;
|
|
699
|
+
stdout?: string;
|
|
700
|
+
result?: string;
|
|
701
|
+
stderr?: string;
|
|
702
|
+
exitCode?: number;
|
|
703
|
+
killed?: boolean;
|
|
704
|
+
error?: string;
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
export interface BrowserDeleteResponse {
|
|
708
|
+
success: boolean;
|
|
709
|
+
sessionDurationMs?: number;
|
|
710
|
+
creditsBilled?: number;
|
|
711
|
+
error?: string;
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
export interface BrowserSession {
|
|
715
|
+
id: string;
|
|
716
|
+
status: string;
|
|
717
|
+
cdpUrl: string;
|
|
718
|
+
liveViewUrl: string;
|
|
719
|
+
streamWebView: boolean;
|
|
720
|
+
createdAt: string;
|
|
721
|
+
lastActivity: string;
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
export interface BrowserListResponse {
|
|
725
|
+
success: boolean;
|
|
726
|
+
sessions?: BrowserSession[];
|
|
727
|
+
error?: string;
|
|
728
|
+
}
|