@mendable/firecrawl-js 4.12.0 → 4.13.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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.12.0",
11
+ version: "4.13.0-beta.1",
12
12
  description: "JavaScript SDK for Firecrawl API",
13
13
  main: "dist/index.js",
14
14
  types: "dist/index.d.ts",
@@ -34,7 +34,7 @@ var require_package = __commonJS({
34
34
  author: "Mendable.ai",
35
35
  license: "MIT",
36
36
  dependencies: {
37
- axios: "^1.12.2",
37
+ axios: "^1.13.5",
38
38
  "typescript-event-target": "^1.1.1",
39
39
  zod: "^3.23.8",
40
40
  "zod-to-json-schema": "^3.23.0"
@@ -71,11 +71,7 @@ var require_package = __commonJS({
71
71
  },
72
72
  pnpm: {
73
73
  overrides: {
74
- "@babel/helpers@<7.26.10": ">=7.26.10",
75
- "brace-expansion@>=1.0.0 <=1.1.11": ">=1.1.12",
76
- "brace-expansion@>=2.0.0 <=2.0.1": ">=2.0.2",
77
- "js-yaml@<3.14.2": ">=3.14.2",
78
- "glob@>=10.2.0 <10.5.0": ">=10.5.0"
74
+ "@isaacs/brace-expansion@<=5.0.0": ">=5.0.1"
79
75
  }
80
76
  }
81
77
  };
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.12.0",
38
+ version: "4.13.0-beta.1",
39
39
  description: "JavaScript SDK for Firecrawl API",
40
40
  main: "dist/index.js",
41
41
  types: "dist/index.d.ts",
@@ -61,7 +61,7 @@ var require_package = __commonJS({
61
61
  author: "Mendable.ai",
62
62
  license: "MIT",
63
63
  dependencies: {
64
- axios: "^1.12.2",
64
+ axios: "^1.13.5",
65
65
  "typescript-event-target": "^1.1.1",
66
66
  zod: "^3.23.8",
67
67
  "zod-to-json-schema": "^3.23.0"
@@ -98,11 +98,7 @@ var require_package = __commonJS({
98
98
  },
99
99
  pnpm: {
100
100
  overrides: {
101
- "@babel/helpers@<7.26.10": ">=7.26.10",
102
- "brace-expansion@>=1.0.0 <=1.1.11": ">=1.1.12",
103
- "brace-expansion@>=2.0.0 <=2.0.1": ">=2.0.2",
104
- "js-yaml@<3.14.2": ">=3.14.2",
105
- "glob@>=10.2.0 <10.5.0": ">=10.5.0"
101
+ "@isaacs/brace-expansion@<=5.0.0": ">=5.0.1"
106
102
  }
107
103
  }
108
104
  };
@@ -110,17 +106,17 @@ var require_package = __commonJS({
110
106
  });
111
107
 
112
108
  // src/index.ts
113
- var index_exports = {};
114
- __export(index_exports, {
109
+ var src_exports = {};
110
+ __export(src_exports, {
115
111
  Firecrawl: () => Firecrawl,
116
112
  FirecrawlAppV1: () => FirecrawlApp,
117
113
  FirecrawlClient: () => FirecrawlClient,
118
114
  JobTimeoutError: () => JobTimeoutError,
119
115
  SdkError: () => SdkError,
120
116
  Watcher: () => Watcher,
121
- default: () => index_default
117
+ default: () => src_default
122
118
  });
123
- module.exports = __toCommonJS(index_exports);
119
+ module.exports = __toCommonJS(src_exports);
124
120
 
125
121
  // src/v2/utils/httpClient.ts
126
122
  var import_axios = __toESM(require("axios"), 1);
@@ -932,6 +928,63 @@ async function cancelAgent(http, jobId) {
932
928
  }
933
929
  }
934
930
 
931
+ // src/v2/methods/browser.ts
932
+ async function browser(http, args = {}) {
933
+ const body = {};
934
+ if (args.ttlTotal != null) body.ttlTotal = args.ttlTotal;
935
+ if (args.ttlWithoutActivity != null) body.ttlWithoutActivity = args.ttlWithoutActivity;
936
+ if (args.streamWebView != null) body.streamWebView = args.streamWebView;
937
+ try {
938
+ const res = await http.post("/v2/browser", body);
939
+ if (res.status !== 200) throwForBadResponse(res, "create browser session");
940
+ return res.data;
941
+ } catch (err) {
942
+ if (err?.isAxiosError) return normalizeAxiosError(err, "create browser session");
943
+ throw err;
944
+ }
945
+ }
946
+ async function browserExecute(http, sessionId, args) {
947
+ const body = {
948
+ code: args.code,
949
+ language: args.language ?? "python"
950
+ };
951
+ try {
952
+ const res = await http.post(
953
+ `/v2/browser/${sessionId}/execute`,
954
+ body
955
+ );
956
+ if (res.status !== 200) throwForBadResponse(res, "execute browser code");
957
+ return res.data;
958
+ } catch (err) {
959
+ if (err?.isAxiosError) return normalizeAxiosError(err, "execute browser code");
960
+ throw err;
961
+ }
962
+ }
963
+ async function deleteBrowser(http, sessionId) {
964
+ try {
965
+ const res = await http.delete(
966
+ `/v2/browser/${sessionId}`
967
+ );
968
+ if (res.status !== 200) throwForBadResponse(res, "delete browser session");
969
+ return res.data;
970
+ } catch (err) {
971
+ if (err?.isAxiosError) return normalizeAxiosError(err, "delete browser session");
972
+ throw err;
973
+ }
974
+ }
975
+ async function listBrowsers(http, args = {}) {
976
+ let endpoint = "/v2/browser";
977
+ if (args.status) endpoint += `?status=${args.status}`;
978
+ try {
979
+ const res = await http.get(endpoint);
980
+ if (res.status !== 200) throwForBadResponse(res, "list browser sessions");
981
+ return res.data;
982
+ } catch (err) {
983
+ if (err?.isAxiosError) return normalizeAxiosError(err, "list browser sessions");
984
+ throw err;
985
+ }
986
+ }
987
+
935
988
  // src/v2/methods/usage.ts
936
989
  async function getConcurrency(http) {
937
990
  try {
@@ -1425,6 +1478,39 @@ var FirecrawlClient = class {
1425
1478
  async cancelAgent(jobId) {
1426
1479
  return cancelAgent(this.http, jobId);
1427
1480
  }
1481
+ // Browser
1482
+ /**
1483
+ * Create a new browser session.
1484
+ * @param args Session options (ttlTotal, ttlWithoutActivity, streamWebView).
1485
+ * @returns Session id and CDP URL.
1486
+ */
1487
+ async browser(args = {}) {
1488
+ return browser(this.http, args);
1489
+ }
1490
+ /**
1491
+ * Execute code in a browser session.
1492
+ * @param sessionId Browser session id.
1493
+ * @param args Code and language to execute.
1494
+ * @returns Execution result.
1495
+ */
1496
+ async browserExecute(sessionId, args) {
1497
+ return browserExecute(this.http, sessionId, args);
1498
+ }
1499
+ /**
1500
+ * Delete a browser session.
1501
+ * @param sessionId Browser session id.
1502
+ */
1503
+ async deleteBrowser(sessionId) {
1504
+ return deleteBrowser(this.http, sessionId);
1505
+ }
1506
+ /**
1507
+ * List browser sessions.
1508
+ * @param args Optional filter (status: "active" | "destroyed").
1509
+ * @returns List of browser sessions.
1510
+ */
1511
+ async listBrowsers(args = {}) {
1512
+ return listBrowsers(this.http, args);
1513
+ }
1428
1514
  // Usage
1429
1515
  /** Current concurrency usage. */
1430
1516
  async getConcurrency() {
@@ -1465,7 +1551,7 @@ var FirecrawlClient = class {
1465
1551
  var import_axios3 = __toESM(require("axios"), 1);
1466
1552
  var zt2 = require("zod");
1467
1553
 
1468
- // node_modules/.pnpm/typescript-event-target@1.1.1/node_modules/typescript-event-target/dist/index.mjs
1554
+ // node_modules/typescript-event-target/dist/index.mjs
1469
1555
  var e = class extends EventTarget {
1470
1556
  dispatchTypedEvent(s, t) {
1471
1557
  return super.dispatchEvent(t);
@@ -2865,7 +2951,7 @@ var Firecrawl = class extends FirecrawlClient {
2865
2951
  return this._v1;
2866
2952
  }
2867
2953
  };
2868
- var index_default = Firecrawl;
2954
+ var src_default = Firecrawl;
2869
2955
  // Annotate the CommonJS export names for ESM import in node:
2870
2956
  0 && (module.exports = {
2871
2957
  Firecrawl,
package/dist/index.d.cts CHANGED
@@ -554,6 +554,34 @@ 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
+ error?: string;
562
+ }
563
+ interface BrowserExecuteResponse {
564
+ success: boolean;
565
+ result?: string;
566
+ error?: string;
567
+ }
568
+ interface BrowserDeleteResponse {
569
+ success: boolean;
570
+ error?: string;
571
+ }
572
+ interface BrowserSession {
573
+ id: string;
574
+ status: string;
575
+ cdpUrl: string;
576
+ streamWebView: boolean;
577
+ createdAt: string;
578
+ lastActivity: string;
579
+ }
580
+ interface BrowserListResponse {
581
+ success: boolean;
582
+ sessions?: BrowserSession[];
583
+ error?: string;
584
+ }
557
585
 
558
586
  interface HttpClientOptions {
559
587
  apiKey: string;
@@ -573,9 +601,9 @@ declare class HttpClient {
573
601
  getApiKey(): string;
574
602
  private request;
575
603
  private sleep;
576
- post<T = any>(endpoint: string, body: Record<string, unknown>, headers?: Record<string, string>): Promise<AxiosResponse<T, any, {}>>;
577
- get<T = any>(endpoint: string, headers?: Record<string, string>): Promise<AxiosResponse<T, any, {}>>;
578
- delete<T = any>(endpoint: string, headers?: Record<string, string>): Promise<AxiosResponse<T, any, {}>>;
604
+ post<T = any>(endpoint: string, body: Record<string, unknown>, headers?: Record<string, string>): Promise<AxiosResponse<T, any>>;
605
+ get<T = any>(endpoint: string, headers?: Record<string, string>): Promise<AxiosResponse<T, any>>;
606
+ delete<T = any>(endpoint: string, headers?: Record<string, string>): Promise<AxiosResponse<T, any>>;
579
607
  prepareHeaders(idempotencyKey?: string): Record<string, string>;
580
608
  }
581
609
 
@@ -606,6 +634,19 @@ declare function prepareAgentPayload(args: {
606
634
  }): Record<string, unknown>;
607
635
  declare function startAgent(http: HttpClient, args: Parameters<typeof prepareAgentPayload>[0]): Promise<AgentResponse>;
608
636
 
637
+ declare function browser(http: HttpClient, args?: {
638
+ ttlTotal?: number;
639
+ ttlWithoutActivity?: number;
640
+ streamWebView?: boolean;
641
+ }): Promise<BrowserCreateResponse>;
642
+ declare function browserExecute(http: HttpClient, sessionId: string, args: {
643
+ code: string;
644
+ language?: "python" | "js";
645
+ }): Promise<BrowserExecuteResponse>;
646
+ declare function listBrowsers(http: HttpClient, args?: {
647
+ status?: "active" | "destroyed";
648
+ }): Promise<BrowserListResponse>;
649
+
609
650
  type JobKind = "crawl" | "batch";
610
651
  interface WatcherOptions {
611
652
  kind?: JobKind;
@@ -811,6 +852,30 @@ declare class FirecrawlClient {
811
852
  * @returns True if cancelled.
812
853
  */
813
854
  cancelAgent(jobId: string): Promise<boolean>;
855
+ /**
856
+ * Create a new browser session.
857
+ * @param args Session options (ttlTotal, ttlWithoutActivity, streamWebView).
858
+ * @returns Session id and CDP URL.
859
+ */
860
+ browser(args?: Parameters<typeof browser>[1]): Promise<BrowserCreateResponse>;
861
+ /**
862
+ * Execute code in a browser session.
863
+ * @param sessionId Browser session id.
864
+ * @param args Code and language to execute.
865
+ * @returns Execution result.
866
+ */
867
+ browserExecute(sessionId: string, args: Parameters<typeof browserExecute>[2]): Promise<BrowserExecuteResponse>;
868
+ /**
869
+ * Delete a browser session.
870
+ * @param sessionId Browser session id.
871
+ */
872
+ deleteBrowser(sessionId: string): Promise<BrowserDeleteResponse>;
873
+ /**
874
+ * List browser sessions.
875
+ * @param args Optional filter (status: "active" | "destroyed").
876
+ * @returns List of browser sessions.
877
+ */
878
+ listBrowsers(args?: Parameters<typeof listBrowsers>[1]): Promise<BrowserListResponse>;
814
879
  /** Current concurrency usage. */
815
880
  getConcurrency(): Promise<ConcurrencyCheck>;
816
881
  /** Current credit usage. */
@@ -1736,4 +1801,4 @@ declare class Firecrawl extends FirecrawlClient {
1736
1801
  get v1(): FirecrawlApp;
1737
1802
  }
1738
1803
 
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 };
1804
+ 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,34 @@ 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
+ error?: string;
562
+ }
563
+ interface BrowserExecuteResponse {
564
+ success: boolean;
565
+ result?: string;
566
+ error?: string;
567
+ }
568
+ interface BrowserDeleteResponse {
569
+ success: boolean;
570
+ error?: string;
571
+ }
572
+ interface BrowserSession {
573
+ id: string;
574
+ status: string;
575
+ cdpUrl: string;
576
+ streamWebView: boolean;
577
+ createdAt: string;
578
+ lastActivity: string;
579
+ }
580
+ interface BrowserListResponse {
581
+ success: boolean;
582
+ sessions?: BrowserSession[];
583
+ error?: string;
584
+ }
557
585
 
558
586
  interface HttpClientOptions {
559
587
  apiKey: string;
@@ -573,9 +601,9 @@ declare class HttpClient {
573
601
  getApiKey(): string;
574
602
  private request;
575
603
  private sleep;
576
- post<T = any>(endpoint: string, body: Record<string, unknown>, headers?: Record<string, string>): Promise<AxiosResponse<T, any, {}>>;
577
- get<T = any>(endpoint: string, headers?: Record<string, string>): Promise<AxiosResponse<T, any, {}>>;
578
- delete<T = any>(endpoint: string, headers?: Record<string, string>): Promise<AxiosResponse<T, any, {}>>;
604
+ post<T = any>(endpoint: string, body: Record<string, unknown>, headers?: Record<string, string>): Promise<AxiosResponse<T, any>>;
605
+ get<T = any>(endpoint: string, headers?: Record<string, string>): Promise<AxiosResponse<T, any>>;
606
+ delete<T = any>(endpoint: string, headers?: Record<string, string>): Promise<AxiosResponse<T, any>>;
579
607
  prepareHeaders(idempotencyKey?: string): Record<string, string>;
580
608
  }
581
609
 
@@ -606,6 +634,19 @@ declare function prepareAgentPayload(args: {
606
634
  }): Record<string, unknown>;
607
635
  declare function startAgent(http: HttpClient, args: Parameters<typeof prepareAgentPayload>[0]): Promise<AgentResponse>;
608
636
 
637
+ declare function browser(http: HttpClient, args?: {
638
+ ttlTotal?: number;
639
+ ttlWithoutActivity?: number;
640
+ streamWebView?: boolean;
641
+ }): Promise<BrowserCreateResponse>;
642
+ declare function browserExecute(http: HttpClient, sessionId: string, args: {
643
+ code: string;
644
+ language?: "python" | "js";
645
+ }): Promise<BrowserExecuteResponse>;
646
+ declare function listBrowsers(http: HttpClient, args?: {
647
+ status?: "active" | "destroyed";
648
+ }): Promise<BrowserListResponse>;
649
+
609
650
  type JobKind = "crawl" | "batch";
610
651
  interface WatcherOptions {
611
652
  kind?: JobKind;
@@ -811,6 +852,30 @@ declare class FirecrawlClient {
811
852
  * @returns True if cancelled.
812
853
  */
813
854
  cancelAgent(jobId: string): Promise<boolean>;
855
+ /**
856
+ * Create a new browser session.
857
+ * @param args Session options (ttlTotal, ttlWithoutActivity, streamWebView).
858
+ * @returns Session id and CDP URL.
859
+ */
860
+ browser(args?: Parameters<typeof browser>[1]): Promise<BrowserCreateResponse>;
861
+ /**
862
+ * Execute code in a browser session.
863
+ * @param sessionId Browser session id.
864
+ * @param args Code and language to execute.
865
+ * @returns Execution result.
866
+ */
867
+ browserExecute(sessionId: string, args: Parameters<typeof browserExecute>[2]): Promise<BrowserExecuteResponse>;
868
+ /**
869
+ * Delete a browser session.
870
+ * @param sessionId Browser session id.
871
+ */
872
+ deleteBrowser(sessionId: string): Promise<BrowserDeleteResponse>;
873
+ /**
874
+ * List browser sessions.
875
+ * @param args Optional filter (status: "active" | "destroyed").
876
+ * @returns List of browser sessions.
877
+ */
878
+ listBrowsers(args?: Parameters<typeof listBrowsers>[1]): Promise<BrowserListResponse>;
814
879
  /** Current concurrency usage. */
815
880
  getConcurrency(): Promise<ConcurrencyCheck>;
816
881
  /** Current credit usage. */
@@ -1736,4 +1801,4 @@ declare class Firecrawl extends FirecrawlClient {
1736
1801
  get v1(): FirecrawlApp;
1737
1802
  }
1738
1803
 
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 };
1804
+ 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-G5AJUV7O.js";
3
+ } from "./chunk-XXDTBMNV.js";
4
4
 
5
5
  // src/v2/utils/httpClient.ts
6
6
  import axios from "axios";
@@ -812,6 +812,63 @@ 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.ttlTotal != null) body.ttlTotal = args.ttlTotal;
819
+ if (args.ttlWithoutActivity != null) body.ttlWithoutActivity = args.ttlWithoutActivity;
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 ?? "python"
834
+ };
835
+ try {
836
+ const res = await http.post(
837
+ `/v2/browser/${sessionId}/execute`,
838
+ body
839
+ );
840
+ if (res.status !== 200) throwForBadResponse(res, "execute browser code");
841
+ return res.data;
842
+ } catch (err) {
843
+ if (err?.isAxiosError) return normalizeAxiosError(err, "execute browser code");
844
+ throw err;
845
+ }
846
+ }
847
+ async function deleteBrowser(http, sessionId) {
848
+ try {
849
+ const res = await http.delete(
850
+ `/v2/browser/${sessionId}`
851
+ );
852
+ if (res.status !== 200) throwForBadResponse(res, "delete browser session");
853
+ return res.data;
854
+ } catch (err) {
855
+ if (err?.isAxiosError) return normalizeAxiosError(err, "delete browser session");
856
+ throw err;
857
+ }
858
+ }
859
+ async function listBrowsers(http, args = {}) {
860
+ let endpoint = "/v2/browser";
861
+ if (args.status) endpoint += `?status=${args.status}`;
862
+ try {
863
+ const res = await http.get(endpoint);
864
+ if (res.status !== 200) throwForBadResponse(res, "list browser sessions");
865
+ return res.data;
866
+ } catch (err) {
867
+ if (err?.isAxiosError) return normalizeAxiosError(err, "list browser sessions");
868
+ throw err;
869
+ }
870
+ }
871
+
815
872
  // src/v2/methods/usage.ts
816
873
  async function getConcurrency(http) {
817
874
  try {
@@ -902,7 +959,7 @@ var loadPromise;
902
959
  var loadNodeWebSocket = async () => {
903
960
  if (!isNodeRuntime()) return void 0;
904
961
  try {
905
- const undici = await import("undici");
962
+ const undici = await import("node:undici");
906
963
  const ctor = undici.WebSocket ?? undici.default?.WebSocket;
907
964
  return typeof ctor === "function" ? ctor : void 0;
908
965
  } catch {
@@ -1305,6 +1362,39 @@ var FirecrawlClient = class {
1305
1362
  async cancelAgent(jobId) {
1306
1363
  return cancelAgent(this.http, jobId);
1307
1364
  }
1365
+ // Browser
1366
+ /**
1367
+ * Create a new browser session.
1368
+ * @param args Session options (ttlTotal, ttlWithoutActivity, streamWebView).
1369
+ * @returns Session id and CDP URL.
1370
+ */
1371
+ async browser(args = {}) {
1372
+ return browser(this.http, args);
1373
+ }
1374
+ /**
1375
+ * Execute code in a browser session.
1376
+ * @param sessionId Browser session id.
1377
+ * @param args Code and language to execute.
1378
+ * @returns Execution result.
1379
+ */
1380
+ async browserExecute(sessionId, args) {
1381
+ return browserExecute(this.http, sessionId, args);
1382
+ }
1383
+ /**
1384
+ * Delete a browser session.
1385
+ * @param sessionId Browser session id.
1386
+ */
1387
+ async deleteBrowser(sessionId) {
1388
+ return deleteBrowser(this.http, sessionId);
1389
+ }
1390
+ /**
1391
+ * List browser sessions.
1392
+ * @param args Optional filter (status: "active" | "destroyed").
1393
+ * @returns List of browser sessions.
1394
+ */
1395
+ async listBrowsers(args = {}) {
1396
+ return listBrowsers(this.http, args);
1397
+ }
1308
1398
  // Usage
1309
1399
  /** Current concurrency usage. */
1310
1400
  async getConcurrency() {
@@ -1345,7 +1435,7 @@ var FirecrawlClient = class {
1345
1435
  import axios2, { AxiosError } from "axios";
1346
1436
  import "zod";
1347
1437
 
1348
- // node_modules/.pnpm/typescript-event-target@1.1.1/node_modules/typescript-event-target/dist/index.mjs
1438
+ // node_modules/typescript-event-target/dist/index.mjs
1349
1439
  var e = class extends EventTarget {
1350
1440
  dispatchTypedEvent(s, t) {
1351
1441
  return super.dispatchEvent(t);
@@ -1374,7 +1464,7 @@ var FirecrawlApp = class {
1374
1464
  if (typeof process !== "undefined" && process.env && process.env.npm_package_version) {
1375
1465
  return process.env.npm_package_version;
1376
1466
  }
1377
- const packageJson = await import("./package-T35BK7SG.js");
1467
+ const packageJson = await import("./package-WXWM2ZOD.js");
1378
1468
  return packageJson.default.version;
1379
1469
  } catch (error) {
1380
1470
  const isTest = typeof process !== "undefined" && (process.env.JEST_WORKER_ID != null || false);
@@ -2745,7 +2835,7 @@ var Firecrawl = class extends FirecrawlClient {
2745
2835
  return this._v1;
2746
2836
  }
2747
2837
  };
2748
- var index_default = Firecrawl;
2838
+ var src_default = Firecrawl;
2749
2839
  export {
2750
2840
  Firecrawl,
2751
2841
  FirecrawlApp as FirecrawlAppV1,
@@ -2753,5 +2843,5 @@ export {
2753
2843
  JobTimeoutError,
2754
2844
  SdkError,
2755
2845
  Watcher,
2756
- index_default as default
2846
+ src_default as default
2757
2847
  };
@@ -1,4 +1,4 @@
1
1
  import {
2
2
  require_package
3
- } from "./chunk-G5AJUV7O.js";
3
+ } from "./chunk-XXDTBMNV.js";
4
4
  export default require_package();
package/dump.rdb ADDED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mendable/firecrawl-js",
3
- "version": "4.12.0",
3
+ "version": "4.13.0-beta.1",
4
4
  "description": "JavaScript SDK for Firecrawl API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -19,7 +19,7 @@
19
19
  "author": "Mendable.ai",
20
20
  "license": "MIT",
21
21
  "dependencies": {
22
- "axios": "^1.12.2",
22
+ "axios": "^1.13.5",
23
23
  "typescript-event-target": "^1.1.1",
24
24
  "zod": "^3.23.8",
25
25
  "zod-to-json-schema": "^3.23.0"
@@ -33,10 +33,10 @@ describe('FirecrawlApp E2E Tests', () => {
33
33
  }
34
34
  });
35
35
 
36
- test.concurrent('should throw error for blocklisted URL on scrape', async () => {
36
+ test.concurrent('should throw error for unsupported URL on scrape', async () => {
37
37
  const app = new FirecrawlApp({ apiKey: TEST_API_KEY, apiUrl: API_URL });
38
- const blocklistedUrl = "https://facebook.com/fake-test";
39
- await expect(app.scrapeUrl(blocklistedUrl)).rejects.toThrow("This website is not currently supported");
38
+ const unsupportedUrl = "https://facebook.com/fake-test";
39
+ await expect(app.scrapeUrl(unsupportedUrl)).rejects.toThrow("do not support this site");
40
40
  });
41
41
 
42
42
  test.concurrent('should return successful response for valid scrape', async () => {
@@ -243,10 +243,10 @@ describe('FirecrawlApp E2E Tests', () => {
243
243
  }
244
244
  });
245
245
 
246
- test.concurrent('should throw error for blocklisted URL on map', async () => {
246
+ test.concurrent('should throw error for unsupported URL on map', async () => {
247
247
  const app = new FirecrawlApp({ apiKey: TEST_API_KEY, apiUrl: API_URL });
248
- const blocklistedUrl = "https://facebook.com/fake-test";
249
- await expect(app.mapUrl(blocklistedUrl)).rejects.toThrow("403");
248
+ const unsupportedUrl = "https://facebook.com/fake-test";
249
+ await expect(app.mapUrl(unsupportedUrl)).rejects.toThrow("403");
250
250
  });
251
251
 
252
252
  test.concurrent('should return successful response for valid map', async () => {
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";
@@ -298,6 +308,47 @@ export class FirecrawlClient {
298
308
  return cancelAgent(this.http, jobId);
299
309
  }
300
310
 
311
+ // Browser
312
+ /**
313
+ * Create a new browser session.
314
+ * @param args Session options (ttlTotal, ttlWithoutActivity, streamWebView).
315
+ * @returns Session id and CDP URL.
316
+ */
317
+ async browser(
318
+ args: Parameters<typeof browserMethod>[1] = {}
319
+ ): Promise<BrowserCreateResponse> {
320
+ return browserMethod(this.http, args);
321
+ }
322
+ /**
323
+ * Execute code in a browser session.
324
+ * @param sessionId Browser session id.
325
+ * @param args Code and language to execute.
326
+ * @returns Execution result.
327
+ */
328
+ async browserExecute(
329
+ sessionId: string,
330
+ args: Parameters<typeof browserExecute>[2]
331
+ ): Promise<BrowserExecuteResponse> {
332
+ return browserExecute(this.http, sessionId, args);
333
+ }
334
+ /**
335
+ * Delete a browser session.
336
+ * @param sessionId Browser session id.
337
+ */
338
+ async deleteBrowser(sessionId: string): Promise<BrowserDeleteResponse> {
339
+ return deleteBrowser(this.http, sessionId);
340
+ }
341
+ /**
342
+ * List browser sessions.
343
+ * @param args Optional filter (status: "active" | "destroyed").
344
+ * @returns List of browser sessions.
345
+ */
346
+ async listBrowsers(
347
+ args: Parameters<typeof listBrowsers>[1] = {}
348
+ ): Promise<BrowserListResponse> {
349
+ return listBrowsers(this.http, args);
350
+ }
351
+
301
352
  // Usage
302
353
  /** Current concurrency usage. */
303
354
  async getConcurrency() {
@@ -0,0 +1,92 @@
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
+ ttlTotal?: number;
14
+ ttlWithoutActivity?: number;
15
+ streamWebView?: boolean;
16
+ } = {}
17
+ ): Promise<BrowserCreateResponse> {
18
+ const body: Record<string, unknown> = {};
19
+ if (args.ttlTotal != null) body.ttlTotal = args.ttlTotal;
20
+ if (args.ttlWithoutActivity != null) body.ttlWithoutActivity = args.ttlWithoutActivity;
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" | "js";
39
+ }
40
+ ): Promise<BrowserExecuteResponse> {
41
+ const body: Record<string, unknown> = {
42
+ code: args.code,
43
+ language: args.language ?? "python",
44
+ };
45
+
46
+ try {
47
+ const res = await http.post<BrowserExecuteResponse>(
48
+ `/v2/browser/${sessionId}/execute`,
49
+ body
50
+ );
51
+ if (res.status !== 200) throwForBadResponse(res, "execute browser code");
52
+ return res.data;
53
+ } catch (err: any) {
54
+ if (err?.isAxiosError) return normalizeAxiosError(err, "execute browser code");
55
+ throw err;
56
+ }
57
+ }
58
+
59
+ export async function deleteBrowser(
60
+ http: HttpClient,
61
+ sessionId: string
62
+ ): Promise<BrowserDeleteResponse> {
63
+ try {
64
+ const res = await http.delete<BrowserDeleteResponse>(
65
+ `/v2/browser/${sessionId}`
66
+ );
67
+ if (res.status !== 200) throwForBadResponse(res, "delete browser session");
68
+ return res.data;
69
+ } catch (err: any) {
70
+ if (err?.isAxiosError) return normalizeAxiosError(err, "delete browser session");
71
+ throw err;
72
+ }
73
+ }
74
+
75
+ export async function listBrowsers(
76
+ http: HttpClient,
77
+ args: {
78
+ status?: "active" | "destroyed";
79
+ } = {}
80
+ ): Promise<BrowserListResponse> {
81
+ let endpoint = "/v2/browser";
82
+ if (args.status) endpoint += `?status=${args.status}`;
83
+
84
+ try {
85
+ const res = await http.get<BrowserListResponse>(endpoint);
86
+ if (res.status !== 200) throwForBadResponse(res, "list browser sessions");
87
+ return res.data;
88
+ } catch (err: any) {
89
+ if (err?.isAxiosError) return normalizeAxiosError(err, "list browser sessions");
90
+ throw err;
91
+ }
92
+ }
package/src/v2/types.ts CHANGED
@@ -683,3 +683,37 @@ 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
+ error?: string;
693
+ }
694
+
695
+ export interface BrowserExecuteResponse {
696
+ success: boolean;
697
+ result?: string;
698
+ error?: string;
699
+ }
700
+
701
+ export interface BrowserDeleteResponse {
702
+ success: boolean;
703
+ error?: string;
704
+ }
705
+
706
+ export interface BrowserSession {
707
+ id: string;
708
+ status: string;
709
+ cdpUrl: string;
710
+ streamWebView: boolean;
711
+ createdAt: string;
712
+ lastActivity: string;
713
+ }
714
+
715
+ export interface BrowserListResponse {
716
+ success: boolean;
717
+ sessions?: BrowserSession[];
718
+ error?: string;
719
+ }