firecrawl 4.47.0 → 4.48.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.
- package/README.md +10 -0
- package/dist/{chunk-H75FJ6LW.js → chunk-GD463K4D.js} +1 -1
- package/dist/index.cjs +112 -26
- package/dist/index.d.cts +17 -2
- package/dist/index.d.ts +17 -2
- package/dist/index.js +113 -27
- package/dist/{package-NZI5TDUV.js → package-WONXBIJS.js} +1 -1
- package/package.json +1 -1
- package/src/__tests__/unit/v2/agent-hints.test.ts +1 -0
- package/src/__tests__/unit/v2/origin.test.ts +132 -0
- package/src/__tests__/unit/v2/research.test.ts +1 -0
- package/src/index.ts +1 -0
- package/src/utils/callerOrigin.ts +74 -0
- package/src/v1/index.ts +28 -13
- package/src/v2/client.ts +10 -1
- package/src/v2/methods/parse.ts +1 -6
- package/src/v2/methods/research.ts +20 -7
- package/src/v2/utils/httpClient.ts +10 -3
package/README.md
CHANGED
|
@@ -37,6 +37,16 @@ const crawlResponse = await app.crawl('https://firecrawl.dev', {
|
|
|
37
37
|
console.log(crawlResponse);
|
|
38
38
|
```
|
|
39
39
|
|
|
40
|
+
### Request origin
|
|
41
|
+
|
|
42
|
+
Requests carry an `origin` tag that identifies the client. Pass the `origin` option to set it. Set `origin` on a single call to override it for that call, except for `app.research` methods, which always use the client origin.
|
|
43
|
+
|
|
44
|
+
```js
|
|
45
|
+
const app = new Firecrawl({ apiKey: 'fc-YOUR_API_KEY', origin: 'js-sdk.my-wrapper@1.0.0' });
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
By default the tag is `js-sdk@<version>`. When the client is created by code inside an installed package (a wrapper library), the default is `js-sdk.<package>@<version>` instead, for example `js-sdk.scope-name@<version>`. Application code, REPLs and bundled files without `node_modules` in their path keep the plain default. Detection runs once when the client is created and sends only the package name, lowercased and sanitized into a slug. Set `FIRECRAWL_DISABLE_CALLER_ORIGIN=1` to always use the plain default.
|
|
49
|
+
|
|
40
50
|
### Scraping a URL
|
|
41
51
|
|
|
42
52
|
To scrape a single URL with error handling, use the `scrape` method. It takes the URL as a parameter and returns the scraped data.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// package.json
|
|
2
2
|
var name = "@mendable/firecrawl-js";
|
|
3
|
-
var version = "4.
|
|
3
|
+
var version = "4.48.0";
|
|
4
4
|
var description = "JavaScript SDK for the Firecrawl API: web scraping, crawling, web search, and scientific literature search over a research paper index of PubMed, bioRxiv, medRxiv and arXiv abstracts";
|
|
5
5
|
var main = "dist/index.js";
|
|
6
6
|
var types = "dist/index.d.ts";
|
package/dist/index.cjs
CHANGED
|
@@ -39,7 +39,7 @@ var require_package = __commonJS({
|
|
|
39
39
|
"package.json"(exports2, module2) {
|
|
40
40
|
module2.exports = {
|
|
41
41
|
name: "@mendable/firecrawl-js",
|
|
42
|
-
version: "4.
|
|
42
|
+
version: "4.48.0",
|
|
43
43
|
description: "JavaScript SDK for the Firecrawl API: web scraping, crawling, web search, and scientific literature search over a research paper index of PubMed, bioRxiv, medRxiv and arXiv abstracts",
|
|
44
44
|
main: "dist/index.js",
|
|
45
45
|
types: "dist/index.d.ts",
|
|
@@ -161,11 +161,13 @@ var HttpClient = class {
|
|
|
161
161
|
apiUrl;
|
|
162
162
|
maxRetries;
|
|
163
163
|
backoffFactor;
|
|
164
|
+
origin;
|
|
164
165
|
constructor(options) {
|
|
165
166
|
this.apiKey = options.apiKey;
|
|
166
167
|
this.apiUrl = options.apiUrl.replace(/\/$/, "");
|
|
167
168
|
this.maxRetries = options.maxRetries ?? 3;
|
|
168
169
|
this.backoffFactor = options.backoffFactor ?? 0.5;
|
|
170
|
+
this.origin = options.origin || `js-sdk@${getVersion()}`;
|
|
169
171
|
this.instance = import_axios.default.create({
|
|
170
172
|
baseURL: this.apiUrl,
|
|
171
173
|
timeout: options.timeoutMs ?? 3e5,
|
|
@@ -184,13 +186,16 @@ var HttpClient = class {
|
|
|
184
186
|
getApiKey() {
|
|
185
187
|
return this.apiKey;
|
|
186
188
|
}
|
|
189
|
+
/** The attribution origin stamped into requests that do not set their own. */
|
|
190
|
+
getOrigin() {
|
|
191
|
+
return this.origin;
|
|
192
|
+
}
|
|
187
193
|
/** The client-wide default request timeout, for callers that need to
|
|
188
194
|
* extend a specific request beyond it (e.g. scrape auto-resume). */
|
|
189
195
|
getTimeoutMs() {
|
|
190
196
|
return this.instance.defaults.timeout ?? 3e5;
|
|
191
197
|
}
|
|
192
198
|
async request(config) {
|
|
193
|
-
const version2 = getVersion();
|
|
194
199
|
config.headers = {
|
|
195
200
|
...config.headers || {}
|
|
196
201
|
};
|
|
@@ -205,7 +210,7 @@ var HttpClient = class {
|
|
|
205
210
|
const data = cfg.data ?? {};
|
|
206
211
|
cfg.data = {
|
|
207
212
|
...data,
|
|
208
|
-
origin: typeof data.origin === "string" && data.origin
|
|
213
|
+
origin: typeof data.origin === "string" && data.origin ? data.origin : this.origin
|
|
209
214
|
};
|
|
210
215
|
}
|
|
211
216
|
if (isFormDataBody) {
|
|
@@ -788,10 +793,9 @@ async function parse(http, file, options) {
|
|
|
788
793
|
throw new Error("file data cannot be empty");
|
|
789
794
|
}
|
|
790
795
|
if (options) ensureValidParseOptions(options);
|
|
791
|
-
const version2 = getVersion();
|
|
792
796
|
const normalizedOptions = {
|
|
793
797
|
...options ?? {},
|
|
794
|
-
origin:
|
|
798
|
+
origin: options?.origin || http.getOrigin()
|
|
795
799
|
};
|
|
796
800
|
const formData = new FormData();
|
|
797
801
|
formData.append("options", JSON.stringify(normalizedOptions));
|
|
@@ -1909,8 +1913,8 @@ function appendParam(params, key, value) {
|
|
|
1909
1913
|
params.append(key, String(value));
|
|
1910
1914
|
}
|
|
1911
1915
|
}
|
|
1912
|
-
function withQuery(path, params) {
|
|
1913
|
-
params.append("origin",
|
|
1916
|
+
function withQuery(origin, path, params) {
|
|
1917
|
+
params.append("origin", origin);
|
|
1914
1918
|
const qs = params.toString();
|
|
1915
1919
|
return qs ? `${path}?${qs}` : path;
|
|
1916
1920
|
}
|
|
@@ -1965,7 +1969,7 @@ var ResearchClient = class {
|
|
|
1965
1969
|
appendParam(params, "to", options.to);
|
|
1966
1970
|
try {
|
|
1967
1971
|
const res = await this.http.get(
|
|
1968
|
-
withQuery(`${BASE}/papers`, params)
|
|
1972
|
+
withQuery(this.http.getOrigin(), `${BASE}/papers`, params)
|
|
1969
1973
|
);
|
|
1970
1974
|
if (res.status !== 200) throwForBadResponse(res, "search papers");
|
|
1971
1975
|
return res.data;
|
|
@@ -1983,7 +1987,13 @@ var ResearchClient = class {
|
|
|
1983
1987
|
appendParam(params, "query", options.query);
|
|
1984
1988
|
appendParam(params, "k", options.k);
|
|
1985
1989
|
try {
|
|
1986
|
-
const res = await this.http.get(
|
|
1990
|
+
const res = await this.http.get(
|
|
1991
|
+
withQuery(
|
|
1992
|
+
this.http.getOrigin(),
|
|
1993
|
+
`${BASE}/papers/${encodeURIComponent(id)}`,
|
|
1994
|
+
params
|
|
1995
|
+
)
|
|
1996
|
+
);
|
|
1987
1997
|
if (res.status !== 200) throwForBadResponse(res, "get paper");
|
|
1988
1998
|
return res.data;
|
|
1989
1999
|
} catch (err) {
|
|
@@ -2009,7 +2019,11 @@ var ResearchClient = class {
|
|
|
2009
2019
|
appendParam(params, "anchor", options.anchor);
|
|
2010
2020
|
try {
|
|
2011
2021
|
const res = await this.http.get(
|
|
2012
|
-
withQuery(
|
|
2022
|
+
withQuery(
|
|
2023
|
+
this.http.getOrigin(),
|
|
2024
|
+
`${BASE}/papers/${encodeURIComponent(id)}/similar`,
|
|
2025
|
+
params
|
|
2026
|
+
)
|
|
2013
2027
|
);
|
|
2014
2028
|
if (res.status !== 200) throwForBadResponse(res, "find similar papers");
|
|
2015
2029
|
return res.data;
|
|
@@ -2040,7 +2054,7 @@ var ResearchClient = class {
|
|
|
2040
2054
|
appendParam(params, "k", options.k);
|
|
2041
2055
|
try {
|
|
2042
2056
|
const res = await this.http.get(
|
|
2043
|
-
withQuery(`${BASE}/github`, params)
|
|
2057
|
+
withQuery(this.http.getOrigin(), `${BASE}/github`, params)
|
|
2044
2058
|
);
|
|
2045
2059
|
if (res.status !== 200) throwForBadResponse(res, "search github");
|
|
2046
2060
|
return res.data;
|
|
@@ -2170,6 +2184,67 @@ async function getMonitorCheck(http, monitorId, checkId, options) {
|
|
|
2170
2184
|
}
|
|
2171
2185
|
}
|
|
2172
2186
|
|
|
2187
|
+
// src/utils/callerOrigin.ts
|
|
2188
|
+
var NODE_MODULES = "/node_modules/";
|
|
2189
|
+
function packageOf(file) {
|
|
2190
|
+
let path = file.replace(/^file:\/\//, "").replace(/\\/g, "/");
|
|
2191
|
+
try {
|
|
2192
|
+
path = decodeURIComponent(path);
|
|
2193
|
+
} catch {
|
|
2194
|
+
}
|
|
2195
|
+
const at = path.lastIndexOf(NODE_MODULES);
|
|
2196
|
+
if (at < 0) return null;
|
|
2197
|
+
const [first, second] = path.slice(at + NODE_MODULES.length).split("/");
|
|
2198
|
+
const name = first?.startsWith("@") ? second ? `${first}/${second}` : "" : first;
|
|
2199
|
+
return name && !name.startsWith(".") ? name : null;
|
|
2200
|
+
}
|
|
2201
|
+
function frameFile(line) {
|
|
2202
|
+
const text = line.trim().replace(/^at /, "");
|
|
2203
|
+
const open = text.indexOf(" (");
|
|
2204
|
+
const location = open >= 0 && text.endsWith(")") ? text.slice(open + 2, -1) : text;
|
|
2205
|
+
const match = /^(.*):\d+:\d+$/.exec(location);
|
|
2206
|
+
return match && !match[1].startsWith("node:") ? match[1] : null;
|
|
2207
|
+
}
|
|
2208
|
+
function slugify(name) {
|
|
2209
|
+
return name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 48).replace(/-+$/, "");
|
|
2210
|
+
}
|
|
2211
|
+
function detectCallerPackage(stack) {
|
|
2212
|
+
try {
|
|
2213
|
+
if (process.env.FIRECRAWL_DISABLE_CALLER_ORIGIN === "1") return null;
|
|
2214
|
+
if (stack === void 0) {
|
|
2215
|
+
const limit = Error.stackTraceLimit;
|
|
2216
|
+
Error.stackTraceLimit = 50;
|
|
2217
|
+
try {
|
|
2218
|
+
stack = new Error().stack ?? "";
|
|
2219
|
+
} finally {
|
|
2220
|
+
Error.stackTraceLimit = limit;
|
|
2221
|
+
}
|
|
2222
|
+
}
|
|
2223
|
+
let ownFile = null;
|
|
2224
|
+
let ownPackage = null;
|
|
2225
|
+
for (const line of stack.split("\n")) {
|
|
2226
|
+
if (!/^\s*at /.test(line)) continue;
|
|
2227
|
+
const file = frameFile(line);
|
|
2228
|
+
if (!file) continue;
|
|
2229
|
+
if (ownFile === null) {
|
|
2230
|
+
ownFile = file;
|
|
2231
|
+
ownPackage = packageOf(file);
|
|
2232
|
+
}
|
|
2233
|
+
if (file === ownFile) continue;
|
|
2234
|
+
const name = packageOf(file);
|
|
2235
|
+
if (name && name === ownPackage) continue;
|
|
2236
|
+
const slug = name ? slugify(name) : "";
|
|
2237
|
+
return slug && !slug.includes("playground") ? slug : null;
|
|
2238
|
+
}
|
|
2239
|
+
} catch {
|
|
2240
|
+
}
|
|
2241
|
+
return null;
|
|
2242
|
+
}
|
|
2243
|
+
function defaultOrigin(version2) {
|
|
2244
|
+
const caller = detectCallerPackage();
|
|
2245
|
+
return caller ? `js-sdk.${caller}@${version2}` : `js-sdk@${version2}`;
|
|
2246
|
+
}
|
|
2247
|
+
|
|
2173
2248
|
// src/v2/watcher.ts
|
|
2174
2249
|
var import_events = require("events");
|
|
2175
2250
|
var hasGlobalWebSocket = () => {
|
|
@@ -2432,7 +2507,8 @@ var FirecrawlClient = class {
|
|
|
2432
2507
|
apiUrl,
|
|
2433
2508
|
timeoutMs: opts.timeoutMs,
|
|
2434
2509
|
maxRetries: opts.maxRetries,
|
|
2435
|
-
backoffFactor: opts.backoffFactor
|
|
2510
|
+
backoffFactor: opts.backoffFactor,
|
|
2511
|
+
origin: opts.origin || defaultOrigin(getVersion())
|
|
2436
2512
|
});
|
|
2437
2513
|
}
|
|
2438
2514
|
async scrape(url, options) {
|
|
@@ -2958,6 +3034,8 @@ var FirecrawlApp = class {
|
|
|
2958
3034
|
apiKey;
|
|
2959
3035
|
apiUrl;
|
|
2960
3036
|
version = "1.25.1";
|
|
3037
|
+
clientOrigin;
|
|
3038
|
+
callerPackage;
|
|
2961
3039
|
isCloudService(url) {
|
|
2962
3040
|
return url.includes("api.firecrawl.dev");
|
|
2963
3041
|
}
|
|
@@ -2983,15 +3061,22 @@ var FirecrawlApp = class {
|
|
|
2983
3061
|
* Initializes a new instance of the FirecrawlApp class.
|
|
2984
3062
|
* @param config - Configuration options for the FirecrawlApp instance.
|
|
2985
3063
|
*/
|
|
2986
|
-
constructor({ apiKey = null, apiUrl = null }) {
|
|
3064
|
+
constructor({ apiKey = null, apiUrl = null, origin }) {
|
|
2987
3065
|
const baseUrl = apiUrl || "https://api.firecrawl.dev";
|
|
2988
3066
|
if (this.isCloudService(baseUrl) && typeof apiKey !== "string") {
|
|
2989
3067
|
throw new FirecrawlError("No API key provided", 401);
|
|
2990
3068
|
}
|
|
2991
3069
|
this.apiKey = apiKey || "";
|
|
2992
3070
|
this.apiUrl = baseUrl;
|
|
3071
|
+
this.clientOrigin = origin || void 0;
|
|
3072
|
+
this.callerPackage = this.clientOrigin ? null : detectCallerPackage();
|
|
2993
3073
|
this.init();
|
|
2994
3074
|
}
|
|
3075
|
+
resolveOrigin(params) {
|
|
3076
|
+
if (typeof params?.origin === "string" && params.origin) return params.origin;
|
|
3077
|
+
if (this.clientOrigin) return this.clientOrigin;
|
|
3078
|
+
return this.callerPackage ? `js-sdk.${this.callerPackage}@${this.version}` : `js-sdk@${this.version}`;
|
|
3079
|
+
}
|
|
2995
3080
|
/**
|
|
2996
3081
|
* Scrapes a URL using the Firecrawl API.
|
|
2997
3082
|
* @param url - The URL to scrape.
|
|
@@ -3003,7 +3088,7 @@ var FirecrawlApp = class {
|
|
|
3003
3088
|
"Content-Type": "application/json",
|
|
3004
3089
|
Authorization: `Bearer ${this.apiKey}`
|
|
3005
3090
|
};
|
|
3006
|
-
let jsonData = { url, ...params, origin:
|
|
3091
|
+
let jsonData = { url, ...params, origin: this.resolveOrigin(params) };
|
|
3007
3092
|
if (jsonData?.extract?.schema) {
|
|
3008
3093
|
jsonData = {
|
|
3009
3094
|
...jsonData,
|
|
@@ -3067,7 +3152,7 @@ var FirecrawlApp = class {
|
|
|
3067
3152
|
lang: params?.lang ?? "en",
|
|
3068
3153
|
country: params?.country ?? "us",
|
|
3069
3154
|
location: params?.location,
|
|
3070
|
-
origin:
|
|
3155
|
+
origin: this.resolveOrigin(params),
|
|
3071
3156
|
timeout: params?.timeout ?? 6e4,
|
|
3072
3157
|
scrapeOptions: params?.scrapeOptions ?? { formats: [] }
|
|
3073
3158
|
};
|
|
@@ -3122,7 +3207,7 @@ var FirecrawlApp = class {
|
|
|
3122
3207
|
*/
|
|
3123
3208
|
async crawlUrl(url, params, pollInterval = 2, idempotencyKey) {
|
|
3124
3209
|
const headers = this.prepareHeaders(idempotencyKey);
|
|
3125
|
-
let jsonData = { url, ...params, origin:
|
|
3210
|
+
let jsonData = { url, ...params, origin: this.resolveOrigin(params) };
|
|
3126
3211
|
try {
|
|
3127
3212
|
const response = await this.postRequest(
|
|
3128
3213
|
this.apiUrl + `/v1/crawl`,
|
|
@@ -3146,7 +3231,7 @@ var FirecrawlApp = class {
|
|
|
3146
3231
|
}
|
|
3147
3232
|
async asyncCrawlUrl(url, params, idempotencyKey) {
|
|
3148
3233
|
const headers = this.prepareHeaders(idempotencyKey);
|
|
3149
|
-
let jsonData = { url, ...params, origin:
|
|
3234
|
+
let jsonData = { url, ...params, origin: this.resolveOrigin(params) };
|
|
3150
3235
|
try {
|
|
3151
3236
|
const response = await this.postRequest(
|
|
3152
3237
|
this.apiUrl + `/v1/crawl`,
|
|
@@ -3305,7 +3390,7 @@ var FirecrawlApp = class {
|
|
|
3305
3390
|
*/
|
|
3306
3391
|
async mapUrl(url, params) {
|
|
3307
3392
|
const headers = this.prepareHeaders();
|
|
3308
|
-
let jsonData = { url, ...params, origin:
|
|
3393
|
+
let jsonData = { url, ...params, origin: this.resolveOrigin(params) };
|
|
3309
3394
|
try {
|
|
3310
3395
|
const response = await this.postRequest(
|
|
3311
3396
|
this.apiUrl + `/v1/map`,
|
|
@@ -3334,7 +3419,7 @@ var FirecrawlApp = class {
|
|
|
3334
3419
|
*/
|
|
3335
3420
|
async batchScrapeUrls(urls, params, pollInterval = 2, idempotencyKey, webhook, ignoreInvalidURLs, maxConcurrency) {
|
|
3336
3421
|
const headers = this.prepareHeaders(idempotencyKey);
|
|
3337
|
-
let jsonData = { urls, webhook, ignoreInvalidURLs, maxConcurrency, ...params, origin:
|
|
3422
|
+
let jsonData = { urls, webhook, ignoreInvalidURLs, maxConcurrency, ...params, origin: this.resolveOrigin(params) };
|
|
3338
3423
|
if (jsonData?.extract?.schema) {
|
|
3339
3424
|
jsonData = {
|
|
3340
3425
|
...jsonData,
|
|
@@ -3376,7 +3461,7 @@ var FirecrawlApp = class {
|
|
|
3376
3461
|
}
|
|
3377
3462
|
async asyncBatchScrapeUrls(urls, params, idempotencyKey, webhook, ignoreInvalidURLs) {
|
|
3378
3463
|
const headers = this.prepareHeaders(idempotencyKey);
|
|
3379
|
-
let jsonData = { urls, webhook, ignoreInvalidURLs, ...params, origin:
|
|
3464
|
+
let jsonData = { urls, webhook, ignoreInvalidURLs, ...params, origin: this.resolveOrigin(params) };
|
|
3380
3465
|
try {
|
|
3381
3466
|
const response = await this.postRequest(
|
|
3382
3467
|
this.apiUrl + `/v1/batch/scrape`,
|
|
@@ -3520,7 +3605,7 @@ var FirecrawlApp = class {
|
|
|
3520
3605
|
try {
|
|
3521
3606
|
const response = await this.postRequest(
|
|
3522
3607
|
this.apiUrl + `/v1/extract`,
|
|
3523
|
-
{ ...jsonData, schema: jsonSchema, origin:
|
|
3608
|
+
{ ...jsonData, schema: jsonSchema, origin: this.resolveOrigin(params) },
|
|
3524
3609
|
headers
|
|
3525
3610
|
);
|
|
3526
3611
|
if (response.status === 200) {
|
|
@@ -3573,7 +3658,7 @@ var FirecrawlApp = class {
|
|
|
3573
3658
|
try {
|
|
3574
3659
|
const response = await this.postRequest(
|
|
3575
3660
|
this.apiUrl + `/v1/extract`,
|
|
3576
|
-
{ ...jsonData, schema: jsonSchema, origin:
|
|
3661
|
+
{ ...jsonData, schema: jsonSchema, origin: this.resolveOrigin(params) },
|
|
3577
3662
|
headers
|
|
3578
3663
|
);
|
|
3579
3664
|
if (response.status === 200) {
|
|
@@ -3855,7 +3940,7 @@ var FirecrawlApp = class {
|
|
|
3855
3940
|
*/
|
|
3856
3941
|
async asyncDeepResearch(query, params) {
|
|
3857
3942
|
const headers = this.prepareHeaders();
|
|
3858
|
-
let jsonData = { query, ...params, origin:
|
|
3943
|
+
let jsonData = { query, ...params, origin: this.resolveOrigin(params) };
|
|
3859
3944
|
if (jsonData?.jsonOptions?.schema) {
|
|
3860
3945
|
jsonData = {
|
|
3861
3946
|
...jsonData,
|
|
@@ -3974,7 +4059,7 @@ var FirecrawlApp = class {
|
|
|
3974
4059
|
async __asyncDeepResearch(topic, params) {
|
|
3975
4060
|
const headers = this.prepareHeaders();
|
|
3976
4061
|
try {
|
|
3977
|
-
let jsonData = { topic, ...params, origin:
|
|
4062
|
+
let jsonData = { topic, ...params, origin: this.resolveOrigin(params) };
|
|
3978
4063
|
const response = await this.postRequest(
|
|
3979
4064
|
`${this.apiUrl}/v1/deep-research`,
|
|
3980
4065
|
jsonData,
|
|
@@ -4074,7 +4159,7 @@ var FirecrawlApp = class {
|
|
|
4074
4159
|
*/
|
|
4075
4160
|
async asyncGenerateLLMsText(url, params) {
|
|
4076
4161
|
const headers = this.prepareHeaders();
|
|
4077
|
-
let jsonData = { url, ...params, origin:
|
|
4162
|
+
let jsonData = { url, ...params, origin: this.resolveOrigin(params) };
|
|
4078
4163
|
try {
|
|
4079
4164
|
const response = await this.postRequest(
|
|
4080
4165
|
`${this.apiUrl}/v1/llmstxt`,
|
|
@@ -4342,7 +4427,8 @@ var Firecrawl = class extends FirecrawlClient {
|
|
|
4342
4427
|
super(resolved);
|
|
4343
4428
|
this._v1Opts = {
|
|
4344
4429
|
apiKey: resolved.apiKey,
|
|
4345
|
-
apiUrl: resolved.apiUrl
|
|
4430
|
+
apiUrl: resolved.apiUrl,
|
|
4431
|
+
origin: this.http.getOrigin()
|
|
4346
4432
|
};
|
|
4347
4433
|
}
|
|
4348
4434
|
/** Access the legacy v1 client (instantiated on first access). */
|
package/dist/index.d.cts
CHANGED
|
@@ -2019,6 +2019,7 @@ interface HttpClientOptions {
|
|
|
2019
2019
|
timeoutMs?: number;
|
|
2020
2020
|
maxRetries?: number;
|
|
2021
2021
|
backoffFactor?: number;
|
|
2022
|
+
origin?: string;
|
|
2022
2023
|
}
|
|
2023
2024
|
interface RequestOptions {
|
|
2024
2025
|
headers?: Record<string, string>;
|
|
@@ -2030,9 +2031,12 @@ declare class HttpClient {
|
|
|
2030
2031
|
private readonly apiUrl;
|
|
2031
2032
|
private readonly maxRetries;
|
|
2032
2033
|
private readonly backoffFactor;
|
|
2034
|
+
private readonly origin;
|
|
2033
2035
|
constructor(options: HttpClientOptions);
|
|
2034
2036
|
getApiUrl(): string;
|
|
2035
2037
|
getApiKey(): string;
|
|
2038
|
+
/** The attribution origin stamped into requests that do not set their own. */
|
|
2039
|
+
getOrigin(): string;
|
|
2036
2040
|
/** The client-wide default request timeout, for callers that need to
|
|
2037
2041
|
* extend a specific request beyond it (e.g. scrape auto-resume). */
|
|
2038
2042
|
getTimeoutMs(): number;
|
|
@@ -2265,6 +2269,12 @@ interface FirecrawlClientOptions {
|
|
|
2265
2269
|
maxRetries?: number;
|
|
2266
2270
|
/** Exponential backoff factor for retries (optional). */
|
|
2267
2271
|
backoffFactor?: number;
|
|
2272
|
+
/**
|
|
2273
|
+
* Attribution tag stamped into request bodies. Defaults to `js-sdk@<version>`,
|
|
2274
|
+
* or `js-sdk.<package>@<version>` when an installed package creates the client
|
|
2275
|
+
* (set FIRECRAWL_DISABLE_CALLER_ORIGIN=1 to keep the plain default).
|
|
2276
|
+
*/
|
|
2277
|
+
origin?: string;
|
|
2268
2278
|
}
|
|
2269
2279
|
/** Accepts a plain API key string or a full options object. */
|
|
2270
2280
|
type FirecrawlClientInput = FirecrawlClientOptions | string;
|
|
@@ -2272,7 +2282,7 @@ type FirecrawlClientInput = FirecrawlClientOptions | string;
|
|
|
2272
2282
|
* Firecrawl v2 client. Provides typed access to all v2 endpoints and utilities.
|
|
2273
2283
|
*/
|
|
2274
2284
|
declare class FirecrawlClient {
|
|
2275
|
-
|
|
2285
|
+
protected readonly http: HttpClient;
|
|
2276
2286
|
private _research?;
|
|
2277
2287
|
private isCloudService;
|
|
2278
2288
|
/**
|
|
@@ -2662,10 +2672,12 @@ declare class FirecrawlClient {
|
|
|
2662
2672
|
* Configuration interface for FirecrawlApp.
|
|
2663
2673
|
* @param apiKey - Optional API key for authentication.
|
|
2664
2674
|
* @param apiUrl - Optional base URL of the API; defaults to 'https://api.firecrawl.dev'.
|
|
2675
|
+
* @param origin - Optional attribution tag stamped into request bodies.
|
|
2665
2676
|
*/
|
|
2666
2677
|
interface FirecrawlAppConfig {
|
|
2667
2678
|
apiKey?: string | null;
|
|
2668
2679
|
apiUrl?: string | null;
|
|
2680
|
+
origin?: string;
|
|
2669
2681
|
}
|
|
2670
2682
|
/**
|
|
2671
2683
|
* Metadata for a Firecrawl document.
|
|
@@ -3262,6 +3274,8 @@ declare class FirecrawlApp {
|
|
|
3262
3274
|
apiKey: string;
|
|
3263
3275
|
apiUrl: string;
|
|
3264
3276
|
version: string;
|
|
3277
|
+
private readonly clientOrigin?;
|
|
3278
|
+
private readonly callerPackage;
|
|
3265
3279
|
private isCloudService;
|
|
3266
3280
|
private getVersion;
|
|
3267
3281
|
private init;
|
|
@@ -3269,7 +3283,8 @@ declare class FirecrawlApp {
|
|
|
3269
3283
|
* Initializes a new instance of the FirecrawlApp class.
|
|
3270
3284
|
* @param config - Configuration options for the FirecrawlApp instance.
|
|
3271
3285
|
*/
|
|
3272
|
-
constructor({ apiKey, apiUrl }: FirecrawlAppConfig);
|
|
3286
|
+
constructor({ apiKey, apiUrl, origin }: FirecrawlAppConfig);
|
|
3287
|
+
private resolveOrigin;
|
|
3273
3288
|
/**
|
|
3274
3289
|
* Scrapes a URL using the Firecrawl API.
|
|
3275
3290
|
* @param url - The URL to scrape.
|
package/dist/index.d.ts
CHANGED
|
@@ -2019,6 +2019,7 @@ interface HttpClientOptions {
|
|
|
2019
2019
|
timeoutMs?: number;
|
|
2020
2020
|
maxRetries?: number;
|
|
2021
2021
|
backoffFactor?: number;
|
|
2022
|
+
origin?: string;
|
|
2022
2023
|
}
|
|
2023
2024
|
interface RequestOptions {
|
|
2024
2025
|
headers?: Record<string, string>;
|
|
@@ -2030,9 +2031,12 @@ declare class HttpClient {
|
|
|
2030
2031
|
private readonly apiUrl;
|
|
2031
2032
|
private readonly maxRetries;
|
|
2032
2033
|
private readonly backoffFactor;
|
|
2034
|
+
private readonly origin;
|
|
2033
2035
|
constructor(options: HttpClientOptions);
|
|
2034
2036
|
getApiUrl(): string;
|
|
2035
2037
|
getApiKey(): string;
|
|
2038
|
+
/** The attribution origin stamped into requests that do not set their own. */
|
|
2039
|
+
getOrigin(): string;
|
|
2036
2040
|
/** The client-wide default request timeout, for callers that need to
|
|
2037
2041
|
* extend a specific request beyond it (e.g. scrape auto-resume). */
|
|
2038
2042
|
getTimeoutMs(): number;
|
|
@@ -2265,6 +2269,12 @@ interface FirecrawlClientOptions {
|
|
|
2265
2269
|
maxRetries?: number;
|
|
2266
2270
|
/** Exponential backoff factor for retries (optional). */
|
|
2267
2271
|
backoffFactor?: number;
|
|
2272
|
+
/**
|
|
2273
|
+
* Attribution tag stamped into request bodies. Defaults to `js-sdk@<version>`,
|
|
2274
|
+
* or `js-sdk.<package>@<version>` when an installed package creates the client
|
|
2275
|
+
* (set FIRECRAWL_DISABLE_CALLER_ORIGIN=1 to keep the plain default).
|
|
2276
|
+
*/
|
|
2277
|
+
origin?: string;
|
|
2268
2278
|
}
|
|
2269
2279
|
/** Accepts a plain API key string or a full options object. */
|
|
2270
2280
|
type FirecrawlClientInput = FirecrawlClientOptions | string;
|
|
@@ -2272,7 +2282,7 @@ type FirecrawlClientInput = FirecrawlClientOptions | string;
|
|
|
2272
2282
|
* Firecrawl v2 client. Provides typed access to all v2 endpoints and utilities.
|
|
2273
2283
|
*/
|
|
2274
2284
|
declare class FirecrawlClient {
|
|
2275
|
-
|
|
2285
|
+
protected readonly http: HttpClient;
|
|
2276
2286
|
private _research?;
|
|
2277
2287
|
private isCloudService;
|
|
2278
2288
|
/**
|
|
@@ -2662,10 +2672,12 @@ declare class FirecrawlClient {
|
|
|
2662
2672
|
* Configuration interface for FirecrawlApp.
|
|
2663
2673
|
* @param apiKey - Optional API key for authentication.
|
|
2664
2674
|
* @param apiUrl - Optional base URL of the API; defaults to 'https://api.firecrawl.dev'.
|
|
2675
|
+
* @param origin - Optional attribution tag stamped into request bodies.
|
|
2665
2676
|
*/
|
|
2666
2677
|
interface FirecrawlAppConfig {
|
|
2667
2678
|
apiKey?: string | null;
|
|
2668
2679
|
apiUrl?: string | null;
|
|
2680
|
+
origin?: string;
|
|
2669
2681
|
}
|
|
2670
2682
|
/**
|
|
2671
2683
|
* Metadata for a Firecrawl document.
|
|
@@ -3262,6 +3274,8 @@ declare class FirecrawlApp {
|
|
|
3262
3274
|
apiKey: string;
|
|
3263
3275
|
apiUrl: string;
|
|
3264
3276
|
version: string;
|
|
3277
|
+
private readonly clientOrigin?;
|
|
3278
|
+
private readonly callerPackage;
|
|
3265
3279
|
private isCloudService;
|
|
3266
3280
|
private getVersion;
|
|
3267
3281
|
private init;
|
|
@@ -3269,7 +3283,8 @@ declare class FirecrawlApp {
|
|
|
3269
3283
|
* Initializes a new instance of the FirecrawlApp class.
|
|
3270
3284
|
* @param config - Configuration options for the FirecrawlApp instance.
|
|
3271
3285
|
*/
|
|
3272
|
-
constructor({ apiKey, apiUrl }: FirecrawlAppConfig);
|
|
3286
|
+
constructor({ apiKey, apiUrl, origin }: FirecrawlAppConfig);
|
|
3287
|
+
private resolveOrigin;
|
|
3273
3288
|
/**
|
|
3274
3289
|
* Scrapes a URL using the Firecrawl API.
|
|
3275
3290
|
* @param url - The URL to scrape.
|