firecrawl 4.4.0 → 4.5.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.4.0",
11
+ version: "4.5.0",
12
12
  description: "JavaScript SDK for Firecrawl API",
13
13
  main: "dist/index.js",
14
14
  types: "dist/index.d.ts",
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.4.0",
38
+ version: "4.5.0",
39
39
  description: "JavaScript SDK for Firecrawl API",
40
40
  main: "dist/index.js",
41
41
  types: "dist/index.d.ts",
@@ -953,6 +953,9 @@ var Watcher = class extends import_events.EventEmitter {
953
953
  var zt = require("zod");
954
954
  var FirecrawlClient = class {
955
955
  http;
956
+ isCloudService(url) {
957
+ return url.includes("api.firecrawl.dev");
958
+ }
956
959
  /**
957
960
  * Create a v2 client.
958
961
  * @param options Transport configuration (API key, base URL, timeouts, retries).
@@ -960,8 +963,8 @@ var FirecrawlClient = class {
960
963
  constructor(options = {}) {
961
964
  const apiKey = options.apiKey ?? process.env.FIRECRAWL_API_KEY ?? "";
962
965
  const apiUrl = (options.apiUrl ?? process.env.FIRECRAWL_API_URL ?? "https://api.firecrawl.dev").replace(/\/$/, "");
963
- if (!apiKey) {
964
- throw new Error("API key is required. Set FIRECRAWL_API_KEY env or pass apiKey.");
966
+ if (this.isCloudService(apiUrl) && !apiKey) {
967
+ throw new Error("API key is required for the cloud API. Set FIRECRAWL_API_KEY env or pass apiKey.");
965
968
  }
966
969
  this.http = new HttpClient({
967
970
  apiKey,
package/dist/index.d.cts CHANGED
@@ -4,7 +4,7 @@ import { AxiosResponse, AxiosRequestHeaders } from 'axios';
4
4
  import { EventEmitter } from 'events';
5
5
  import { TypedEventTarget } from 'typescript-event-target';
6
6
 
7
- type FormatString = 'markdown' | 'html' | 'rawHtml' | 'links' | 'images' | 'screenshot' | 'summary' | 'changeTracking' | 'json' | 'attributes';
7
+ type FormatString = 'markdown' | 'html' | 'rawHtml' | 'links' | 'images' | 'screenshot' | 'summary' | 'changeTracking' | 'json' | 'attributes' | 'branding';
8
8
  interface Viewport {
9
9
  width: number;
10
10
  height: number;
@@ -121,6 +121,130 @@ interface WebhookConfig {
121
121
  metadata?: Record<string, string>;
122
122
  events?: Array<'completed' | 'failed' | 'page' | 'started'>;
123
123
  }
124
+ interface BrandingProfile {
125
+ colorScheme?: 'light' | 'dark';
126
+ logo?: string | null;
127
+ fonts?: Array<{
128
+ family: string;
129
+ [key: string]: unknown;
130
+ }>;
131
+ colors?: {
132
+ primary?: string;
133
+ secondary?: string;
134
+ accent?: string;
135
+ background?: string;
136
+ textPrimary?: string;
137
+ textSecondary?: string;
138
+ link?: string;
139
+ success?: string;
140
+ warning?: string;
141
+ error?: string;
142
+ [key: string]: string | undefined;
143
+ };
144
+ typography?: {
145
+ fontFamilies?: {
146
+ primary?: string;
147
+ heading?: string;
148
+ code?: string;
149
+ [key: string]: string | undefined;
150
+ };
151
+ fontStacks?: {
152
+ primary?: string[];
153
+ heading?: string[];
154
+ body?: string[];
155
+ paragraph?: string[];
156
+ [key: string]: string[] | undefined;
157
+ };
158
+ fontSizes?: {
159
+ h1?: string;
160
+ h2?: string;
161
+ h3?: string;
162
+ body?: string;
163
+ small?: string;
164
+ [key: string]: string | undefined;
165
+ };
166
+ lineHeights?: {
167
+ heading?: number;
168
+ body?: number;
169
+ [key: string]: number | undefined;
170
+ };
171
+ fontWeights?: {
172
+ light?: number;
173
+ regular?: number;
174
+ medium?: number;
175
+ bold?: number;
176
+ [key: string]: number | undefined;
177
+ };
178
+ };
179
+ spacing?: {
180
+ baseUnit?: number;
181
+ padding?: Record<string, number>;
182
+ margins?: Record<string, number>;
183
+ gridGutter?: number;
184
+ borderRadius?: string;
185
+ [key: string]: number | string | Record<string, number> | undefined;
186
+ };
187
+ components?: {
188
+ buttonPrimary?: {
189
+ background?: string;
190
+ textColor?: string;
191
+ borderColor?: string;
192
+ borderRadius?: string;
193
+ [key: string]: string | undefined;
194
+ };
195
+ buttonSecondary?: {
196
+ background?: string;
197
+ textColor?: string;
198
+ borderColor?: string;
199
+ borderRadius?: string;
200
+ [key: string]: string | undefined;
201
+ };
202
+ input?: {
203
+ borderColor?: string;
204
+ focusBorderColor?: string;
205
+ borderRadius?: string;
206
+ [key: string]: string | undefined;
207
+ };
208
+ [key: string]: unknown;
209
+ };
210
+ icons?: {
211
+ style?: string;
212
+ primaryColor?: string;
213
+ [key: string]: string | undefined;
214
+ };
215
+ images?: {
216
+ logo?: string | null;
217
+ favicon?: string | null;
218
+ ogImage?: string | null;
219
+ [key: string]: string | null | undefined;
220
+ };
221
+ animations?: {
222
+ transitionDuration?: string;
223
+ easing?: string;
224
+ [key: string]: string | undefined;
225
+ };
226
+ layout?: {
227
+ grid?: {
228
+ columns?: number;
229
+ maxWidth?: string;
230
+ [key: string]: number | string | undefined;
231
+ };
232
+ headerHeight?: string;
233
+ footerHeight?: string;
234
+ [key: string]: number | string | Record<string, number | string | undefined> | undefined;
235
+ };
236
+ tone?: {
237
+ voice?: string;
238
+ emojiUsage?: string;
239
+ [key: string]: string | undefined;
240
+ };
241
+ personality?: {
242
+ tone: 'professional' | 'playful' | 'modern' | 'traditional' | 'minimalist' | 'bold';
243
+ energy: 'low' | 'medium' | 'high';
244
+ targetAudience: string;
245
+ };
246
+ [key: string]: unknown;
247
+ }
124
248
  interface DocumentMetadata {
125
249
  title?: string;
126
250
  description?: string;
@@ -183,6 +307,7 @@ interface Document {
183
307
  actions?: Record<string, unknown>;
184
308
  warning?: string;
185
309
  changeTracking?: Record<string, unknown>;
310
+ branding?: BrandingProfile;
186
311
  }
187
312
  interface PaginationConfig {
188
313
  /** When true (default), automatically follow `next` links and aggregate all documents. */
@@ -486,6 +611,7 @@ interface FirecrawlClientOptions {
486
611
  */
487
612
  declare class FirecrawlClient {
488
613
  private readonly http;
614
+ private isCloudService;
489
615
  /**
490
616
  * Create a v2 client.
491
617
  * @param options Transport configuration (API key, base URL, timeouts, retries).
@@ -1531,4 +1657,4 @@ declare class Firecrawl extends FirecrawlClient {
1531
1657
  get v1(): FirecrawlApp;
1532
1658
  }
1533
1659
 
1534
- export { type ActionOption, type ActiveCrawl, type ActiveCrawlsResponse, type AgentOptions$1 as AgentOptions, type AttributesFormat, type BatchScrapeJob, type BatchScrapeOptions, type BatchScrapeResponse$1 as BatchScrapeResponse, 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, 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, type WebhookConfig, type WriteAction, Firecrawl as default };
1660
+ export { type ActionOption, type ActiveCrawl, type ActiveCrawlsResponse, type AgentOptions$1 as AgentOptions, 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, 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, type WebhookConfig, type WriteAction, Firecrawl as default };
package/dist/index.d.ts CHANGED
@@ -4,7 +4,7 @@ import { AxiosResponse, AxiosRequestHeaders } from 'axios';
4
4
  import { EventEmitter } from 'events';
5
5
  import { TypedEventTarget } from 'typescript-event-target';
6
6
 
7
- type FormatString = 'markdown' | 'html' | 'rawHtml' | 'links' | 'images' | 'screenshot' | 'summary' | 'changeTracking' | 'json' | 'attributes';
7
+ type FormatString = 'markdown' | 'html' | 'rawHtml' | 'links' | 'images' | 'screenshot' | 'summary' | 'changeTracking' | 'json' | 'attributes' | 'branding';
8
8
  interface Viewport {
9
9
  width: number;
10
10
  height: number;
@@ -121,6 +121,130 @@ interface WebhookConfig {
121
121
  metadata?: Record<string, string>;
122
122
  events?: Array<'completed' | 'failed' | 'page' | 'started'>;
123
123
  }
124
+ interface BrandingProfile {
125
+ colorScheme?: 'light' | 'dark';
126
+ logo?: string | null;
127
+ fonts?: Array<{
128
+ family: string;
129
+ [key: string]: unknown;
130
+ }>;
131
+ colors?: {
132
+ primary?: string;
133
+ secondary?: string;
134
+ accent?: string;
135
+ background?: string;
136
+ textPrimary?: string;
137
+ textSecondary?: string;
138
+ link?: string;
139
+ success?: string;
140
+ warning?: string;
141
+ error?: string;
142
+ [key: string]: string | undefined;
143
+ };
144
+ typography?: {
145
+ fontFamilies?: {
146
+ primary?: string;
147
+ heading?: string;
148
+ code?: string;
149
+ [key: string]: string | undefined;
150
+ };
151
+ fontStacks?: {
152
+ primary?: string[];
153
+ heading?: string[];
154
+ body?: string[];
155
+ paragraph?: string[];
156
+ [key: string]: string[] | undefined;
157
+ };
158
+ fontSizes?: {
159
+ h1?: string;
160
+ h2?: string;
161
+ h3?: string;
162
+ body?: string;
163
+ small?: string;
164
+ [key: string]: string | undefined;
165
+ };
166
+ lineHeights?: {
167
+ heading?: number;
168
+ body?: number;
169
+ [key: string]: number | undefined;
170
+ };
171
+ fontWeights?: {
172
+ light?: number;
173
+ regular?: number;
174
+ medium?: number;
175
+ bold?: number;
176
+ [key: string]: number | undefined;
177
+ };
178
+ };
179
+ spacing?: {
180
+ baseUnit?: number;
181
+ padding?: Record<string, number>;
182
+ margins?: Record<string, number>;
183
+ gridGutter?: number;
184
+ borderRadius?: string;
185
+ [key: string]: number | string | Record<string, number> | undefined;
186
+ };
187
+ components?: {
188
+ buttonPrimary?: {
189
+ background?: string;
190
+ textColor?: string;
191
+ borderColor?: string;
192
+ borderRadius?: string;
193
+ [key: string]: string | undefined;
194
+ };
195
+ buttonSecondary?: {
196
+ background?: string;
197
+ textColor?: string;
198
+ borderColor?: string;
199
+ borderRadius?: string;
200
+ [key: string]: string | undefined;
201
+ };
202
+ input?: {
203
+ borderColor?: string;
204
+ focusBorderColor?: string;
205
+ borderRadius?: string;
206
+ [key: string]: string | undefined;
207
+ };
208
+ [key: string]: unknown;
209
+ };
210
+ icons?: {
211
+ style?: string;
212
+ primaryColor?: string;
213
+ [key: string]: string | undefined;
214
+ };
215
+ images?: {
216
+ logo?: string | null;
217
+ favicon?: string | null;
218
+ ogImage?: string | null;
219
+ [key: string]: string | null | undefined;
220
+ };
221
+ animations?: {
222
+ transitionDuration?: string;
223
+ easing?: string;
224
+ [key: string]: string | undefined;
225
+ };
226
+ layout?: {
227
+ grid?: {
228
+ columns?: number;
229
+ maxWidth?: string;
230
+ [key: string]: number | string | undefined;
231
+ };
232
+ headerHeight?: string;
233
+ footerHeight?: string;
234
+ [key: string]: number | string | Record<string, number | string | undefined> | undefined;
235
+ };
236
+ tone?: {
237
+ voice?: string;
238
+ emojiUsage?: string;
239
+ [key: string]: string | undefined;
240
+ };
241
+ personality?: {
242
+ tone: 'professional' | 'playful' | 'modern' | 'traditional' | 'minimalist' | 'bold';
243
+ energy: 'low' | 'medium' | 'high';
244
+ targetAudience: string;
245
+ };
246
+ [key: string]: unknown;
247
+ }
124
248
  interface DocumentMetadata {
125
249
  title?: string;
126
250
  description?: string;
@@ -183,6 +307,7 @@ interface Document {
183
307
  actions?: Record<string, unknown>;
184
308
  warning?: string;
185
309
  changeTracking?: Record<string, unknown>;
310
+ branding?: BrandingProfile;
186
311
  }
187
312
  interface PaginationConfig {
188
313
  /** When true (default), automatically follow `next` links and aggregate all documents. */
@@ -486,6 +611,7 @@ interface FirecrawlClientOptions {
486
611
  */
487
612
  declare class FirecrawlClient {
488
613
  private readonly http;
614
+ private isCloudService;
489
615
  /**
490
616
  * Create a v2 client.
491
617
  * @param options Transport configuration (API key, base URL, timeouts, retries).
@@ -1531,4 +1657,4 @@ declare class Firecrawl extends FirecrawlClient {
1531
1657
  get v1(): FirecrawlApp;
1532
1658
  }
1533
1659
 
1534
- export { type ActionOption, type ActiveCrawl, type ActiveCrawlsResponse, type AgentOptions$1 as AgentOptions, type AttributesFormat, type BatchScrapeJob, type BatchScrapeOptions, type BatchScrapeResponse$1 as BatchScrapeResponse, 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, 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, type WebhookConfig, type WriteAction, Firecrawl as default };
1660
+ export { type ActionOption, type ActiveCrawl, type ActiveCrawlsResponse, type AgentOptions$1 as AgentOptions, 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, 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, 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-GWA53VW4.js";
3
+ } from "./chunk-MVAMVUST.js";
4
4
 
5
5
  // src/v2/utils/httpClient.ts
6
6
  import axios from "axios";
@@ -837,6 +837,9 @@ var Watcher = class extends EventEmitter {
837
837
  import "zod";
838
838
  var FirecrawlClient = class {
839
839
  http;
840
+ isCloudService(url) {
841
+ return url.includes("api.firecrawl.dev");
842
+ }
840
843
  /**
841
844
  * Create a v2 client.
842
845
  * @param options Transport configuration (API key, base URL, timeouts, retries).
@@ -844,8 +847,8 @@ var FirecrawlClient = class {
844
847
  constructor(options = {}) {
845
848
  const apiKey = options.apiKey ?? process.env.FIRECRAWL_API_KEY ?? "";
846
849
  const apiUrl = (options.apiUrl ?? process.env.FIRECRAWL_API_URL ?? "https://api.firecrawl.dev").replace(/\/$/, "");
847
- if (!apiKey) {
848
- throw new Error("API key is required. Set FIRECRAWL_API_KEY env or pass apiKey.");
850
+ if (this.isCloudService(apiUrl) && !apiKey) {
851
+ throw new Error("API key is required for the cloud API. Set FIRECRAWL_API_KEY env or pass apiKey.");
849
852
  }
850
853
  this.http = new HttpClient({
851
854
  apiKey,
@@ -1068,7 +1071,7 @@ var FirecrawlApp = class {
1068
1071
  if (typeof process !== "undefined" && process.env && process.env.npm_package_version) {
1069
1072
  return process.env.npm_package_version;
1070
1073
  }
1071
- const packageJson = await import("./package-G6W4FIEC.js");
1074
+ const packageJson = await import("./package-O4UQBIGU.js");
1072
1075
  return packageJson.default.version;
1073
1076
  } catch (error) {
1074
1077
  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-GWA53VW4.js";
3
+ } from "./chunk-MVAMVUST.js";
4
4
  export default require_package();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "firecrawl",
3
- "version": "4.4.0",
3
+ "version": "4.5.0",
4
4
  "description": "JavaScript SDK for Firecrawl API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -36,7 +36,7 @@ describe('FirecrawlApp E2E Tests', () => {
36
36
  test.concurrent('should throw error for blocklisted URL on scrape', async () => {
37
37
  const app = new FirecrawlApp({ apiKey: TEST_API_KEY, apiUrl: API_URL });
38
38
  const blocklistedUrl = "https://facebook.com/fake-test";
39
- await expect(app.scrapeUrl(blocklistedUrl)).rejects.toThrow("This website is no longer supported");
39
+ await expect(app.scrapeUrl(blocklistedUrl)).rejects.toThrow("This website is not currently supported");
40
40
  });
41
41
 
42
42
  test.concurrent('should return successful response for valid scrape', async () => {
@@ -52,13 +52,13 @@ describe('FirecrawlApp E2E Tests', () => {
52
52
  const app = new FirecrawlApp({ apiKey: TEST_API_KEY, apiUrl: API_URL });
53
53
  const response = await app.scrapeUrl(
54
54
  'https://roastmywebsite.ai', {
55
- formats: ['markdown', 'html', 'rawHtml', 'screenshot', 'links'],
56
- headers: { "x-key": "test" },
57
- includeTags: ['h1'],
58
- excludeTags: ['h2'],
59
- onlyMainContent: true,
60
- timeout: 30000,
61
- waitFor: 1000
55
+ formats: ['markdown', 'html', 'rawHtml', 'screenshot', 'links'],
56
+ headers: { "x-key": "test" },
57
+ includeTags: ['h1'],
58
+ excludeTags: ['h2'],
59
+ onlyMainContent: true,
60
+ timeout: 30000,
61
+ waitFor: 1000
62
62
  });
63
63
 
64
64
  if (!response.success) {
@@ -70,7 +70,7 @@ describe('FirecrawlApp E2E Tests', () => {
70
70
  const app = new FirecrawlApp({ apiKey: TEST_API_KEY, apiUrl: API_URL });
71
71
  const response = await app.scrapeUrl(
72
72
  'https://roastmywebsite.ai', {
73
- formats: ['screenshot@fullPage'],
73
+ formats: ['screenshot@fullPage'],
74
74
  });
75
75
  if (!response.success) {
76
76
  throw new Error(response.error);
@@ -149,7 +149,7 @@ describe('FirecrawlApp E2E Tests', () => {
149
149
  }
150
150
  }, 60000); // 60 seconds timeout
151
151
 
152
- test.concurrent('should return successful response for crawl with options and wait for completion', async () => {
152
+ test.concurrent('should return successful response for crawl with options and wait for completion', async () => {
153
153
  const app = new FirecrawlApp({ apiKey: TEST_API_KEY, apiUrl: API_URL });
154
154
  const response = await app.crawlUrl('https://roastmywebsite.ai', {
155
155
  excludePaths: ['blog/*'],
@@ -192,7 +192,7 @@ describe('FirecrawlApp E2E Tests', () => {
192
192
 
193
193
  test.concurrent('should check crawl status', async () => {
194
194
  const app = new FirecrawlApp({ apiKey: TEST_API_KEY, apiUrl: API_URL });
195
- const response = await app.asyncCrawlUrl('https://firecrawl.dev', { limit: 20, scrapeOptions: { formats: ['markdown', 'html', 'rawHtml', 'screenshot', 'links']}} as CrawlParams) as CrawlResponse;
195
+ const response = await app.asyncCrawlUrl('https://firecrawl.dev', { limit: 20, scrapeOptions: { formats: ['markdown', 'html', 'rawHtml', 'screenshot', 'links'] } } as CrawlParams) as CrawlResponse;
196
196
  expect(response).not.toBeNull();
197
197
  expect(response.id).toBeDefined();
198
198
 
@@ -250,16 +250,16 @@ describe('FirecrawlApp E2E Tests', () => {
250
250
  });
251
251
 
252
252
  test.concurrent('should return successful response for valid map', async () => {
253
- const app = new FirecrawlApp({ apiKey: TEST_API_KEY, apiUrl: API_URL }); const response = await app.mapUrl('https://roastmywebsite.ai') as MapResponse;
253
+ const app = new FirecrawlApp({ apiKey: TEST_API_KEY, apiUrl: API_URL }); const response = await app.mapUrl('https://roastmywebsite.ai') as MapResponse;
254
254
  expect(response).not.toBeNull();
255
-
255
+
256
256
  expect(response.links?.length).toBeGreaterThan(0);
257
257
  expect(response.links?.[0]).toContain("https://");
258
258
  const filteredLinks = response.links?.filter((link: string) => link.includes("roastmywebsite.ai"));
259
259
  expect(filteredLinks?.length).toBeGreaterThan(0);
260
260
  }, 30000); // 30 seconds timeout
261
261
 
262
-
262
+
263
263
 
264
264
  test('should search with string query', async () => {
265
265
  const app = new FirecrawlApp({ apiUrl: API_URL, apiKey: TEST_API_KEY });
@@ -0,0 +1,186 @@
1
+ import { describe, test, expect, jest } from "@jest/globals";
2
+ import { scrape } from "../../../v2/methods/scrape";
3
+
4
+ describe("JS SDK v2 branding format", () => {
5
+ function makeHttp(postImpl: (url: string, data: any) => any) {
6
+ return { post: jest.fn(async (u: string, d: any) => postImpl(u, d)) } as any;
7
+ }
8
+
9
+ test("scrape with branding format returns branding data", async () => {
10
+ const mockResponse = {
11
+ status: 200,
12
+ data: {
13
+ success: true,
14
+ data: {
15
+ markdown: "# Example",
16
+ branding: {
17
+ colorScheme: "light",
18
+ colors: {
19
+ primary: "#E11D48",
20
+ secondary: "#3B82F6",
21
+ accent: "#F59E0B"
22
+ },
23
+ typography: {
24
+ fontFamilies: {
25
+ primary: "Inter",
26
+ heading: "Poppins"
27
+ },
28
+ fontSizes: {
29
+ h1: "2.5rem",
30
+ body: "1rem"
31
+ }
32
+ },
33
+ spacing: {
34
+ baseUnit: 8
35
+ },
36
+ components: {
37
+ buttonPrimary: {
38
+ background: "#E11D48",
39
+ textColor: "#FFFFFF",
40
+ borderRadius: "0.5rem"
41
+ }
42
+ }
43
+ }
44
+ }
45
+ }
46
+ };
47
+
48
+ const http = makeHttp(() => mockResponse);
49
+ const result = await scrape(http, "https://example.com", { formats: ["branding"] });
50
+
51
+ expect(result.branding).toBeDefined();
52
+ expect(result.branding?.colorScheme).toBe("light");
53
+ expect(result.branding?.colors?.primary).toBe("#E11D48");
54
+ expect(result.branding?.typography?.fontFamilies?.primary).toBe("Inter");
55
+ expect(result.branding?.spacing?.baseUnit).toBe(8);
56
+ expect(result.branding?.components?.buttonPrimary?.background).toBe("#E11D48");
57
+ });
58
+
59
+ test("scrape with branding and markdown formats returns both", async () => {
60
+ const mockResponse = {
61
+ status: 200,
62
+ data: {
63
+ success: true,
64
+ data: {
65
+ markdown: "# Example Content",
66
+ branding: {
67
+ colorScheme: "dark",
68
+ colors: {
69
+ primary: "#10B981"
70
+ },
71
+ typography: {
72
+ fontFamilies: {
73
+ primary: "Roboto"
74
+ }
75
+ }
76
+ }
77
+ }
78
+ }
79
+ };
80
+
81
+ const http = makeHttp(() => mockResponse);
82
+ const result = await scrape(http, "https://example.com", { formats: ["markdown", "branding"] });
83
+
84
+ expect(result.markdown).toBe("# Example Content");
85
+ expect(result.branding).toBeDefined();
86
+ expect(result.branding?.colorScheme).toBe("dark");
87
+ expect(result.branding?.colors?.primary).toBe("#10B981");
88
+ });
89
+
90
+ test("scrape without branding format does not return branding", async () => {
91
+ const mockResponse = {
92
+ status: 200,
93
+ data: {
94
+ success: true,
95
+ data: {
96
+ markdown: "# Example"
97
+ }
98
+ }
99
+ };
100
+
101
+ const http = makeHttp(() => mockResponse);
102
+ const result = await scrape(http, "https://example.com", { formats: ["markdown"] });
103
+
104
+ expect(result.markdown).toBe("# Example");
105
+ expect(result.branding).toBeUndefined();
106
+ });
107
+
108
+ test("branding format with all nested fields", async () => {
109
+ const mockResponse = {
110
+ status: 200,
111
+ data: {
112
+ success: true,
113
+ data: {
114
+ branding: {
115
+ colorScheme: "light",
116
+ logo: "https://example.com/logo.png",
117
+ fonts: [
118
+ { family: "Inter", weight: 400 },
119
+ { family: "Poppins", weight: 700 }
120
+ ],
121
+ colors: {
122
+ primary: "#E11D48",
123
+ background: "#FFFFFF"
124
+ },
125
+ typography: {
126
+ fontFamilies: { primary: "Inter" },
127
+ fontStacks: { body: ["Inter", "sans-serif"] },
128
+ fontSizes: { h1: "2.5rem" },
129
+ lineHeights: { body: 1.5 },
130
+ fontWeights: { regular: 400 }
131
+ },
132
+ spacing: {
133
+ baseUnit: 8,
134
+ padding: { sm: 8, md: 16 }
135
+ },
136
+ components: {
137
+ buttonPrimary: {
138
+ background: "#E11D48",
139
+ textColor: "#FFFFFF"
140
+ }
141
+ },
142
+ icons: {
143
+ style: "outline",
144
+ primaryColor: "#E11D48"
145
+ },
146
+ images: {
147
+ logo: "https://example.com/logo.png",
148
+ favicon: "https://example.com/favicon.ico"
149
+ },
150
+ animations: {
151
+ transitionDuration: "200ms",
152
+ easing: "ease-in-out"
153
+ },
154
+ layout: {
155
+ grid: { columns: 12, maxWidth: "1200px" },
156
+ headerHeight: "64px"
157
+ },
158
+ tone: {
159
+ voice: "professional",
160
+ emojiUsage: "minimal"
161
+ },
162
+ personality: {
163
+ tone: "professional",
164
+ energy: "medium",
165
+ targetAudience: "developers"
166
+ }
167
+ }
168
+ }
169
+ }
170
+ };
171
+
172
+ const http = makeHttp(() => mockResponse);
173
+ const result = await scrape(http, "https://example.com", { formats: ["branding"] });
174
+
175
+ expect(result.branding).toBeDefined();
176
+ expect(result.branding?.logo).toBe("https://example.com/logo.png");
177
+ expect(result.branding?.fonts).toHaveLength(2);
178
+ expect(result.branding?.typography?.fontStacks?.body).toEqual(["Inter", "sans-serif"]);
179
+ expect(result.branding?.spacing?.padding).toEqual({ sm: 8, md: 16 });
180
+ expect(result.branding?.icons?.style).toBe("outline");
181
+ expect(result.branding?.images?.favicon).toBe("https://example.com/favicon.ico");
182
+ expect(result.branding?.animations?.easing).toBe("ease-in-out");
183
+ expect(result.branding?.layout?.grid?.columns).toBe(12);
184
+ expect(result.branding?.personality?.tone).toBe("professional");
185
+ });
186
+ });
package/src/v2/client.ts CHANGED
@@ -72,9 +72,14 @@ export interface FirecrawlClientOptions {
72
72
  /**
73
73
  * Firecrawl v2 client. Provides typed access to all v2 endpoints and utilities.
74
74
  */
75
+
75
76
  export class FirecrawlClient {
76
77
  private readonly http: HttpClient;
77
78
 
79
+ private isCloudService(url: string): boolean {
80
+ return url.includes('api.firecrawl.dev');
81
+ }
82
+
78
83
  /**
79
84
  * Create a v2 client.
80
85
  * @param options Transport configuration (API key, base URL, timeouts, retries).
@@ -82,9 +87,11 @@ export class FirecrawlClient {
82
87
  constructor(options: FirecrawlClientOptions = {}) {
83
88
  const apiKey = options.apiKey ?? process.env.FIRECRAWL_API_KEY ?? "";
84
89
  const apiUrl = (options.apiUrl ?? process.env.FIRECRAWL_API_URL ?? "https://api.firecrawl.dev").replace(/\/$/, "");
85
- if (!apiKey) {
86
- throw new Error("API key is required. Set FIRECRAWL_API_KEY env or pass apiKey.");
90
+
91
+ if (this.isCloudService(apiUrl) && !apiKey) {
92
+ throw new Error("API key is required for the cloud API. Set FIRECRAWL_API_KEY env or pass apiKey.");
87
93
  }
94
+
88
95
  this.http = new HttpClient({
89
96
  apiKey,
90
97
  apiUrl,
package/src/v2/types.ts CHANGED
@@ -11,7 +11,8 @@ export type FormatString =
11
11
  | 'summary'
12
12
  | 'changeTracking'
13
13
  | 'json'
14
- | 'attributes';
14
+ | 'attributes'
15
+ | 'branding';
15
16
 
16
17
  export interface Viewport {
17
18
  width: number;
@@ -165,6 +166,141 @@ export interface WebhookConfig {
165
166
  events?: Array<'completed' | 'failed' | 'page' | 'started'>;
166
167
  }
167
168
 
169
+ export interface BrandingProfile {
170
+ colorScheme?: 'light' | 'dark';
171
+ logo?: string | null;
172
+ fonts?: Array<{
173
+ family: string;
174
+ [key: string]: unknown;
175
+ }>;
176
+ colors?: {
177
+ primary?: string;
178
+ secondary?: string;
179
+ accent?: string;
180
+ background?: string;
181
+ textPrimary?: string;
182
+ textSecondary?: string;
183
+ link?: string;
184
+ success?: string;
185
+ warning?: string;
186
+ error?: string;
187
+ [key: string]: string | undefined;
188
+ };
189
+ typography?: {
190
+ fontFamilies?: {
191
+ primary?: string;
192
+ heading?: string;
193
+ code?: string;
194
+ [key: string]: string | undefined;
195
+ };
196
+ fontStacks?: {
197
+ primary?: string[];
198
+ heading?: string[];
199
+ body?: string[];
200
+ paragraph?: string[];
201
+ [key: string]: string[] | undefined;
202
+ };
203
+ fontSizes?: {
204
+ h1?: string;
205
+ h2?: string;
206
+ h3?: string;
207
+ body?: string;
208
+ small?: string;
209
+ [key: string]: string | undefined;
210
+ };
211
+ lineHeights?: {
212
+ heading?: number;
213
+ body?: number;
214
+ [key: string]: number | undefined;
215
+ };
216
+ fontWeights?: {
217
+ light?: number;
218
+ regular?: number;
219
+ medium?: number;
220
+ bold?: number;
221
+ [key: string]: number | undefined;
222
+ };
223
+ };
224
+ spacing?: {
225
+ baseUnit?: number;
226
+ padding?: Record<string, number>;
227
+ margins?: Record<string, number>;
228
+ gridGutter?: number;
229
+ borderRadius?: string;
230
+ [key: string]: number | string | Record<string, number> | undefined;
231
+ };
232
+ components?: {
233
+ buttonPrimary?: {
234
+ background?: string;
235
+ textColor?: string;
236
+ borderColor?: string;
237
+ borderRadius?: string;
238
+ [key: string]: string | undefined;
239
+ };
240
+ buttonSecondary?: {
241
+ background?: string;
242
+ textColor?: string;
243
+ borderColor?: string;
244
+ borderRadius?: string;
245
+ [key: string]: string | undefined;
246
+ };
247
+ input?: {
248
+ borderColor?: string;
249
+ focusBorderColor?: string;
250
+ borderRadius?: string;
251
+ [key: string]: string | undefined;
252
+ };
253
+ [key: string]: unknown;
254
+ };
255
+ icons?: {
256
+ style?: string;
257
+ primaryColor?: string;
258
+ [key: string]: string | undefined;
259
+ };
260
+ images?: {
261
+ logo?: string | null;
262
+ favicon?: string | null;
263
+ ogImage?: string | null;
264
+ [key: string]: string | null | undefined;
265
+ };
266
+ animations?: {
267
+ transitionDuration?: string;
268
+ easing?: string;
269
+ [key: string]: string | undefined;
270
+ };
271
+ layout?: {
272
+ grid?: {
273
+ columns?: number;
274
+ maxWidth?: string;
275
+ [key: string]: number | string | undefined;
276
+ };
277
+ headerHeight?: string;
278
+ footerHeight?: string;
279
+ [key: string]:
280
+ | number
281
+ | string
282
+ | Record<string, number | string | undefined>
283
+ | undefined;
284
+ };
285
+ tone?: {
286
+ voice?: string;
287
+ emojiUsage?: string;
288
+ [key: string]: string | undefined;
289
+ };
290
+ personality?: {
291
+ tone:
292
+ | 'professional'
293
+ | 'playful'
294
+ | 'modern'
295
+ | 'traditional'
296
+ | 'minimalist'
297
+ | 'bold';
298
+ energy: 'low' | 'medium' | 'high';
299
+ targetAudience: string;
300
+ };
301
+ [key: string]: unknown;
302
+ }
303
+
168
304
  export interface DocumentMetadata {
169
305
  // Common metadata fields
170
306
  title?: string;
@@ -239,6 +375,7 @@ export interface Document {
239
375
  actions?: Record<string, unknown>;
240
376
  warning?: string;
241
377
  changeTracking?: Record<string, unknown>;
378
+ branding?: BrandingProfile;
242
379
  }
243
380
 
244
381
  // Pagination configuration for auto-fetching pages from v2 endpoints that return a `next` URL