@mendable/firecrawl 4.12.0 → 4.13.0

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",
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",
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
  };
@@ -932,6 +928,64 @@ 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.ttl != null) body.ttl = args.ttl;
935
+ if (args.activityTtl != null) body.activityTtl = args.activityTtl;
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 ?? "bash"
950
+ };
951
+ if (args.timeout != null) body.timeout = args.timeout;
952
+ try {
953
+ const res = await http.post(
954
+ `/v2/browser/${sessionId}/execute`,
955
+ body
956
+ );
957
+ if (res.status !== 200) throwForBadResponse(res, "execute browser code");
958
+ return res.data;
959
+ } catch (err) {
960
+ if (err?.isAxiosError) return normalizeAxiosError(err, "execute browser code");
961
+ throw err;
962
+ }
963
+ }
964
+ async function deleteBrowser(http, sessionId) {
965
+ try {
966
+ const res = await http.delete(
967
+ `/v2/browser/${sessionId}`
968
+ );
969
+ if (res.status !== 200) throwForBadResponse(res, "delete browser session");
970
+ return res.data;
971
+ } catch (err) {
972
+ if (err?.isAxiosError) return normalizeAxiosError(err, "delete browser session");
973
+ throw err;
974
+ }
975
+ }
976
+ async function listBrowsers(http, args = {}) {
977
+ let endpoint = "/v2/browser";
978
+ if (args.status) endpoint += `?status=${args.status}`;
979
+ try {
980
+ const res = await http.get(endpoint);
981
+ if (res.status !== 200) throwForBadResponse(res, "list browser sessions");
982
+ return res.data;
983
+ } catch (err) {
984
+ if (err?.isAxiosError) return normalizeAxiosError(err, "list browser sessions");
985
+ throw err;
986
+ }
987
+ }
988
+
935
989
  // src/v2/methods/usage.ts
936
990
  async function getConcurrency(http) {
937
991
  try {
@@ -1425,6 +1479,39 @@ var FirecrawlClient = class {
1425
1479
  async cancelAgent(jobId) {
1426
1480
  return cancelAgent(this.http, jobId);
1427
1481
  }
1482
+ // Browser
1483
+ /**
1484
+ * Create a new browser session.
1485
+ * @param args Session options (ttl, activityTtl, streamWebView).
1486
+ * @returns Session id, CDP URL, live view URL, and expiration time.
1487
+ */
1488
+ async browser(args = {}) {
1489
+ return browser(this.http, args);
1490
+ }
1491
+ /**
1492
+ * Execute code in a browser session.
1493
+ * @param sessionId Browser session id.
1494
+ * @param args Code, language ("python" | "node" | "bash"), and optional timeout.
1495
+ * @returns Execution result including stdout, stderr, exitCode, and killed status.
1496
+ */
1497
+ async browserExecute(sessionId, args) {
1498
+ return browserExecute(this.http, sessionId, args);
1499
+ }
1500
+ /**
1501
+ * Delete a browser session.
1502
+ * @param sessionId Browser session id.
1503
+ */
1504
+ async deleteBrowser(sessionId) {
1505
+ return deleteBrowser(this.http, sessionId);
1506
+ }
1507
+ /**
1508
+ * List browser sessions.
1509
+ * @param args Optional filter (status: "active" | "destroyed").
1510
+ * @returns List of browser sessions.
1511
+ */
1512
+ async listBrowsers(args = {}) {
1513
+ return listBrowsers(this.http, args);
1514
+ }
1428
1515
  // Usage
1429
1516
  /** Current concurrency usage. */
1430
1517
  async getConcurrency() {
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;
@@ -606,6 +643,20 @@ declare function prepareAgentPayload(args: {
606
643
  }): Record<string, unknown>;
607
644
  declare function startAgent(http: HttpClient, args: Parameters<typeof prepareAgentPayload>[0]): Promise<AgentResponse>;
608
645
 
646
+ declare function browser(http: HttpClient, args?: {
647
+ ttl?: number;
648
+ activityTtl?: number;
649
+ streamWebView?: boolean;
650
+ }): Promise<BrowserCreateResponse>;
651
+ declare function browserExecute(http: HttpClient, sessionId: string, args: {
652
+ code: string;
653
+ language?: "python" | "node" | "bash";
654
+ timeout?: number;
655
+ }): Promise<BrowserExecuteResponse>;
656
+ declare function listBrowsers(http: HttpClient, args?: {
657
+ status?: "active" | "destroyed";
658
+ }): Promise<BrowserListResponse>;
659
+
609
660
  type JobKind = "crawl" | "batch";
610
661
  interface WatcherOptions {
611
662
  kind?: JobKind;
@@ -811,6 +862,30 @@ declare class FirecrawlClient {
811
862
  * @returns True if cancelled.
812
863
  */
813
864
  cancelAgent(jobId: string): Promise<boolean>;
865
+ /**
866
+ * Create a new browser session.
867
+ * @param args Session options (ttl, activityTtl, streamWebView).
868
+ * @returns Session id, CDP URL, live view URL, and expiration time.
869
+ */
870
+ browser(args?: Parameters<typeof browser>[1]): Promise<BrowserCreateResponse>;
871
+ /**
872
+ * Execute code in a browser session.
873
+ * @param sessionId Browser session id.
874
+ * @param args Code, language ("python" | "node" | "bash"), and optional timeout.
875
+ * @returns Execution result including stdout, stderr, exitCode, and killed status.
876
+ */
877
+ browserExecute(sessionId: string, args: Parameters<typeof browserExecute>[2]): Promise<BrowserExecuteResponse>;
878
+ /**
879
+ * Delete a browser session.
880
+ * @param sessionId Browser session id.
881
+ */
882
+ deleteBrowser(sessionId: string): Promise<BrowserDeleteResponse>;
883
+ /**
884
+ * List browser sessions.
885
+ * @param args Optional filter (status: "active" | "destroyed").
886
+ * @returns List of browser sessions.
887
+ */
888
+ listBrowsers(args?: Parameters<typeof listBrowsers>[1]): Promise<BrowserListResponse>;
814
889
  /** Current concurrency usage. */
815
890
  getConcurrency(): Promise<ConcurrencyCheck>;
816
891
  /** Current credit usage. */
@@ -1736,4 +1811,4 @@ declare class Firecrawl extends FirecrawlClient {
1736
1811
  get v1(): FirecrawlApp;
1737
1812
  }
1738
1813
 
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 };
1814
+ 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;
@@ -606,6 +643,20 @@ declare function prepareAgentPayload(args: {
606
643
  }): Record<string, unknown>;
607
644
  declare function startAgent(http: HttpClient, args: Parameters<typeof prepareAgentPayload>[0]): Promise<AgentResponse>;
608
645
 
646
+ declare function browser(http: HttpClient, args?: {
647
+ ttl?: number;
648
+ activityTtl?: number;
649
+ streamWebView?: boolean;
650
+ }): Promise<BrowserCreateResponse>;
651
+ declare function browserExecute(http: HttpClient, sessionId: string, args: {
652
+ code: string;
653
+ language?: "python" | "node" | "bash";
654
+ timeout?: number;
655
+ }): Promise<BrowserExecuteResponse>;
656
+ declare function listBrowsers(http: HttpClient, args?: {
657
+ status?: "active" | "destroyed";
658
+ }): Promise<BrowserListResponse>;
659
+
609
660
  type JobKind = "crawl" | "batch";
610
661
  interface WatcherOptions {
611
662
  kind?: JobKind;
@@ -811,6 +862,30 @@ declare class FirecrawlClient {
811
862
  * @returns True if cancelled.
812
863
  */
813
864
  cancelAgent(jobId: string): Promise<boolean>;
865
+ /**
866
+ * Create a new browser session.
867
+ * @param args Session options (ttl, activityTtl, streamWebView).
868
+ * @returns Session id, CDP URL, live view URL, and expiration time.
869
+ */
870
+ browser(args?: Parameters<typeof browser>[1]): Promise<BrowserCreateResponse>;
871
+ /**
872
+ * Execute code in a browser session.
873
+ * @param sessionId Browser session id.
874
+ * @param args Code, language ("python" | "node" | "bash"), and optional timeout.
875
+ * @returns Execution result including stdout, stderr, exitCode, and killed status.
876
+ */
877
+ browserExecute(sessionId: string, args: Parameters<typeof browserExecute>[2]): Promise<BrowserExecuteResponse>;
878
+ /**
879
+ * Delete a browser session.
880
+ * @param sessionId Browser session id.
881
+ */
882
+ deleteBrowser(sessionId: string): Promise<BrowserDeleteResponse>;
883
+ /**
884
+ * List browser sessions.
885
+ * @param args Optional filter (status: "active" | "destroyed").
886
+ * @returns List of browser sessions.
887
+ */
888
+ listBrowsers(args?: Parameters<typeof listBrowsers>[1]): Promise<BrowserListResponse>;
814
889
  /** Current concurrency usage. */
815
890
  getConcurrency(): Promise<ConcurrencyCheck>;
816
891
  /** Current credit usage. */
@@ -1736,4 +1811,4 @@ declare class Firecrawl extends FirecrawlClient {
1736
1811
  get v1(): FirecrawlApp;
1737
1812
  }
1738
1813
 
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 };
1814
+ 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-22A4MB4F.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 {
@@ -1305,6 +1363,39 @@ var FirecrawlClient = class {
1305
1363
  async cancelAgent(jobId) {
1306
1364
  return cancelAgent(this.http, jobId);
1307
1365
  }
1366
+ // Browser
1367
+ /**
1368
+ * Create a new browser session.
1369
+ * @param args Session options (ttl, activityTtl, streamWebView).
1370
+ * @returns Session id, CDP URL, live view URL, and expiration time.
1371
+ */
1372
+ async browser(args = {}) {
1373
+ return browser(this.http, args);
1374
+ }
1375
+ /**
1376
+ * Execute code in a browser session.
1377
+ * @param sessionId Browser session id.
1378
+ * @param args Code, language ("python" | "node" | "bash"), and optional timeout.
1379
+ * @returns Execution result including stdout, stderr, exitCode, and killed status.
1380
+ */
1381
+ async browserExecute(sessionId, args) {
1382
+ return browserExecute(this.http, sessionId, args);
1383
+ }
1384
+ /**
1385
+ * Delete a browser session.
1386
+ * @param sessionId Browser session id.
1387
+ */
1388
+ async deleteBrowser(sessionId) {
1389
+ return deleteBrowser(this.http, sessionId);
1390
+ }
1391
+ /**
1392
+ * List browser sessions.
1393
+ * @param args Optional filter (status: "active" | "destroyed").
1394
+ * @returns List of browser sessions.
1395
+ */
1396
+ async listBrowsers(args = {}) {
1397
+ return listBrowsers(this.http, args);
1398
+ }
1308
1399
  // Usage
1309
1400
  /** Current concurrency usage. */
1310
1401
  async getConcurrency() {
@@ -1374,7 +1465,7 @@ var FirecrawlApp = class {
1374
1465
  if (typeof process !== "undefined" && process.env && process.env.npm_package_version) {
1375
1466
  return process.env.npm_package_version;
1376
1467
  }
1377
- const packageJson = await import("./package-T35BK7SG.js");
1468
+ const packageJson = await import("./package-5SIMNZMX.js");
1378
1469
  return packageJson.default.version;
1379
1470
  } catch (error) {
1380
1471
  const isTest = typeof process !== "undefined" && (process.env.JEST_WORKER_ID != null || false);
@@ -1,4 +1,4 @@
1
1
  import {
2
2
  require_package
3
- } from "./chunk-G5AJUV7O.js";
3
+ } from "./chunk-22A4MB4F.js";
4
4
  export default require_package();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mendable/firecrawl",
3
- "version": "4.12.0",
3
+ "version": "4.13.0",
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 (ttl, activityTtl, streamWebView).
315
+ * @returns Session id, CDP URL, live view URL, and expiration time.
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, language ("python" | "node" | "bash"), and optional timeout.
326
+ * @returns Execution result including stdout, stderr, exitCode, and killed status.
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,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
+ }
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
+ }