mcpscraper-sdk 0.12.2 → 0.12.4
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 +16 -0
- package/dist/index.cjs +26 -5
- package/dist/index.d.cts +68 -19
- package/dist/index.d.ts +68 -19
- package/dist/index.js +26 -5
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -62,6 +62,22 @@ Core operations are flat on the client: `searchSerp`, `harvestPaa`, `extractUrl`
|
|
|
62
62
|
|
|
63
63
|
Everything else is namespaced by product area, matching the OpenAPI spec's tags: `client.youtube`, `client.screenshot`, `client.facebook`, `client.googleAds`, `client.instagram`, `client.reddit`, `client.video`, `client.maps`, `client.directory`, `client.serpIntelligence`, `client.workflows`.
|
|
64
64
|
|
|
65
|
+
### Retry-safe SERP Intelligence captures
|
|
66
|
+
|
|
67
|
+
Pass a stable idempotency key when a capture may be retried. The regular method continues to return the response body; `captureWithReceipt` also returns the key accepted or generated by the server so it can be reused after a timeout or uncertain response:
|
|
68
|
+
|
|
69
|
+
```ts
|
|
70
|
+
const result = await client.serpIntelligence.capture(
|
|
71
|
+
{ query: 'roofers near me' },
|
|
72
|
+
{ idempotencyKey: 'serp-run-2026-07-14-001' },
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
const receipt = await client.serpIntelligence.captureWithReceipt({ query: 'roofers near me' })
|
|
76
|
+
console.log(receipt.data.billing.creditsUsed, receipt.idempotencyKey)
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Reusing a key with the same body recovers the original debit and settlement. Reusing it with a different body throws `ScraperApiError` with status `409` and code `idempotency_conflict`.
|
|
80
|
+
|
|
65
81
|
## Scrape → memory vault
|
|
66
82
|
|
|
67
83
|
`extractUrl` accepts `depositToVault: true` (optionally with `vaultName`) to embed the full scraped body server-side into your mcp-memory vault instead of returning it inline — the response's `memory` field reports `{ deposited, vault, noteId, path, chunks }` (or falls back to a temporary `fileUrl` download if the vault deposit itself fails):
|
package/dist/index.cjs
CHANGED
|
@@ -71,18 +71,22 @@ var Requester = class {
|
|
|
71
71
|
apiKey;
|
|
72
72
|
baseUrl;
|
|
73
73
|
fetchImpl;
|
|
74
|
-
async call(method, path, body) {
|
|
74
|
+
async call(method, path, body, extraHeaders = {}) {
|
|
75
|
+
return (await this.callWithReceipt(method, path, body, extraHeaders)).data;
|
|
76
|
+
}
|
|
77
|
+
async callWithReceipt(method, path, body, extraHeaders = {}) {
|
|
75
78
|
const res = await this.fetchImpl(`${this.baseUrl}${path}`, {
|
|
76
79
|
method,
|
|
77
80
|
headers: {
|
|
78
81
|
"x-api-key": this.apiKey,
|
|
79
|
-
...body !== void 0 ? { "content-type": "application/json" } : {}
|
|
82
|
+
...body !== void 0 ? { "content-type": "application/json" } : {},
|
|
83
|
+
...extraHeaders
|
|
80
84
|
},
|
|
81
85
|
body: body !== void 0 ? JSON.stringify(body) : void 0
|
|
82
86
|
});
|
|
83
87
|
const data = await res.json().catch(() => void 0);
|
|
84
88
|
if (!res.ok) throw new ScraperApiError(res.status, data);
|
|
85
|
-
return data;
|
|
89
|
+
return { data, headers: res.headers };
|
|
86
90
|
}
|
|
87
91
|
async callRaw(method, path) {
|
|
88
92
|
const res = await this.fetchImpl(`${this.baseUrl}${path}`, { method, headers: { "x-api-key": this.apiKey } });
|
|
@@ -212,8 +216,25 @@ var SerpIntelligenceNamespace = class {
|
|
|
212
216
|
this.r = r;
|
|
213
217
|
}
|
|
214
218
|
r;
|
|
215
|
-
capture(params) {
|
|
216
|
-
return this.r.call(
|
|
219
|
+
capture(params, options = {}) {
|
|
220
|
+
return this.r.call(
|
|
221
|
+
"POST",
|
|
222
|
+
"/serp-intelligence/capture",
|
|
223
|
+
params,
|
|
224
|
+
options.idempotencyKey === void 0 ? {} : { "Idempotency-Key": options.idempotencyKey }
|
|
225
|
+
);
|
|
226
|
+
}
|
|
227
|
+
async captureWithReceipt(params, options = {}) {
|
|
228
|
+
const result = await this.r.callWithReceipt(
|
|
229
|
+
"POST",
|
|
230
|
+
"/serp-intelligence/capture",
|
|
231
|
+
params,
|
|
232
|
+
options.idempotencyKey === void 0 ? {} : { "Idempotency-Key": options.idempotencyKey }
|
|
233
|
+
);
|
|
234
|
+
return {
|
|
235
|
+
data: result.data,
|
|
236
|
+
idempotencyKey: result.headers.get("Idempotency-Key")
|
|
237
|
+
};
|
|
217
238
|
}
|
|
218
239
|
pageSnapshots(params) {
|
|
219
240
|
return this.r.call("POST", "/serp-intelligence/page-snapshots", params);
|
package/dist/index.d.cts
CHANGED
|
@@ -17,8 +17,9 @@ interface paths {
|
|
|
17
17
|
put?: never;
|
|
18
18
|
/**
|
|
19
19
|
* Run a Google SERP search, or a full People-Also-Ask harvest
|
|
20
|
-
* @description Set `serpOnly: true` for a pure organic-results/SERP call (
|
|
21
|
-
*
|
|
20
|
+
* @description Set `serpOnly: true` for a pure organic-results/SERP call (4 credits, headless —
|
|
21
|
+
* 14 credits if an anti-bot escalation forces a headful retry; overestimate refunded).
|
|
22
|
+
* Omit or set `false` for a full People-Also-Ask harvest, which also returns SERP data
|
|
22
23
|
* (55 credit base + 3 credits per question actually returned; unused estimate is
|
|
23
24
|
* refunded). Runs synchronously and returns the result inline.
|
|
24
25
|
*/
|
|
@@ -591,7 +592,11 @@ interface paths {
|
|
|
591
592
|
put?: never;
|
|
592
593
|
/**
|
|
593
594
|
* Structured SERP capture with AI Overview/AI Mode detection, entity IDs, and location-match evidence
|
|
594
|
-
* @description
|
|
595
|
+
* @description Holds 14 credits for the SERP and settles to 4 credits when the capture is served
|
|
596
|
+
* headless, or retains 14 credits when anti-bot escalation requires headful mode.
|
|
597
|
+
* When `includePageSnapshots` is true, also holds 1 credit per requested
|
|
598
|
+
* `pageSnapshotLimit` slot and settles to 1 credit per URL actually attempted.
|
|
599
|
+
* Rate-limited to 60 requests/minute per account.
|
|
595
600
|
*/
|
|
596
601
|
post: operations["serpIntelligenceCapture"];
|
|
597
602
|
delete?: never;
|
|
@@ -1259,16 +1264,29 @@ interface components {
|
|
|
1259
1264
|
pages: number;
|
|
1260
1265
|
/** @default false */
|
|
1261
1266
|
debug: boolean;
|
|
1262
|
-
/**
|
|
1267
|
+
/**
|
|
1268
|
+
* @description Also attempt ranking-page snapshots at 1 credit per URL.
|
|
1269
|
+
* @default false
|
|
1270
|
+
*/
|
|
1263
1271
|
includePageSnapshots: boolean;
|
|
1264
|
-
/**
|
|
1272
|
+
/**
|
|
1273
|
+
* @description Maximum snapshot attempts; capacity is held up front and unused capacity is refunded.
|
|
1274
|
+
* @default 0
|
|
1275
|
+
*/
|
|
1265
1276
|
pageSnapshotLimit: number;
|
|
1266
1277
|
};
|
|
1267
1278
|
SerpIntelligencePageSnapshotsRequest: {
|
|
1268
1279
|
urls: string[];
|
|
1269
|
-
|
|
1280
|
+
/** @default 2 */
|
|
1281
|
+
maxConcurrency: number;
|
|
1282
|
+
/** @default 15000 */
|
|
1283
|
+
timeoutMs: number;
|
|
1284
|
+
/** @default false */
|
|
1285
|
+
debug: boolean;
|
|
1286
|
+
} | {
|
|
1287
|
+
targets: {
|
|
1270
1288
|
/** Format: uri */
|
|
1271
|
-
url
|
|
1289
|
+
url: string;
|
|
1272
1290
|
/**
|
|
1273
1291
|
* @default configured_target
|
|
1274
1292
|
* @enum {string}
|
|
@@ -1399,10 +1417,8 @@ interface components {
|
|
|
1399
1417
|
[key: string]: unknown;
|
|
1400
1418
|
} | null;
|
|
1401
1419
|
pageSnapshotArtifacts?: components["schemas"]["SerpPageSnapshotCapture"][];
|
|
1402
|
-
billing
|
|
1403
|
-
creditsUsed
|
|
1404
|
-
requestId?: string;
|
|
1405
|
-
jobId?: string;
|
|
1420
|
+
billing: {
|
|
1421
|
+
creditsUsed: number;
|
|
1406
1422
|
};
|
|
1407
1423
|
};
|
|
1408
1424
|
SerpIntelligencePageSnapshotsResponse: {
|
|
@@ -2702,7 +2718,15 @@ interface operations {
|
|
|
2702
2718
|
serpIntelligenceCapture: {
|
|
2703
2719
|
parameters: {
|
|
2704
2720
|
query?: never;
|
|
2705
|
-
header?:
|
|
2721
|
+
header?: {
|
|
2722
|
+
/**
|
|
2723
|
+
* @description Stable retry key for this capture. Reusing the same key with the same
|
|
2724
|
+
* request body recovers the original debit and settlement; reusing it with
|
|
2725
|
+
* a different body returns `409 idempotency_conflict`. When omitted, the
|
|
2726
|
+
* server generates a key and returns it in the response header.
|
|
2727
|
+
*/
|
|
2728
|
+
"Idempotency-Key"?: string;
|
|
2729
|
+
};
|
|
2706
2730
|
path?: never;
|
|
2707
2731
|
cookie?: never;
|
|
2708
2732
|
};
|
|
@@ -2715,6 +2739,8 @@ interface operations {
|
|
|
2715
2739
|
/** @description Structured SERP capture. */
|
|
2716
2740
|
200: {
|
|
2717
2741
|
headers: {
|
|
2742
|
+
/** @description Retry key accepted from the request or generated by the server. */
|
|
2743
|
+
"Idempotency-Key"?: string;
|
|
2718
2744
|
[name: string]: unknown;
|
|
2719
2745
|
};
|
|
2720
2746
|
content: {
|
|
@@ -2723,6 +2749,17 @@ interface operations {
|
|
|
2723
2749
|
};
|
|
2724
2750
|
400: components["responses"]["StructuredBadRequest"];
|
|
2725
2751
|
402: components["responses"]["InsufficientBalance"];
|
|
2752
|
+
/** @description The Idempotency-Key was already used with a different request body. */
|
|
2753
|
+
409: {
|
|
2754
|
+
headers: {
|
|
2755
|
+
/** @description The conflicting retry key. */
|
|
2756
|
+
"Idempotency-Key"?: string;
|
|
2757
|
+
[name: string]: unknown;
|
|
2758
|
+
};
|
|
2759
|
+
content: {
|
|
2760
|
+
"application/json": components["schemas"]["StructuredError"];
|
|
2761
|
+
};
|
|
2762
|
+
};
|
|
2726
2763
|
429: components["responses"]["StructuredRateLimited"];
|
|
2727
2764
|
500: components["responses"]["StructuredCaptureFailed"];
|
|
2728
2765
|
};
|
|
@@ -3156,12 +3193,25 @@ interface ScraperClientOptions {
|
|
|
3156
3193
|
baseUrl?: string;
|
|
3157
3194
|
fetch?: typeof globalThis.fetch;
|
|
3158
3195
|
}
|
|
3196
|
+
type SerpIntelligenceCaptureDefaultedKey = 'gl' | 'hl' | 'device' | 'proxyMode' | 'pages' | 'debug' | 'includePageSnapshots' | 'pageSnapshotLimit';
|
|
3197
|
+
type SerpIntelligenceCaptureParams = Omit<RequestBodyOf<'serpIntelligenceCapture'>, SerpIntelligenceCaptureDefaultedKey> & Partial<Pick<RequestBodyOf<'serpIntelligenceCapture'>, SerpIntelligenceCaptureDefaultedKey>>;
|
|
3198
|
+
interface SerpIntelligenceCaptureOptions {
|
|
3199
|
+
idempotencyKey?: string;
|
|
3200
|
+
}
|
|
3201
|
+
interface SerpIntelligenceCaptureReceipt {
|
|
3202
|
+
data: SuccessBodyOf<'serpIntelligenceCapture'>;
|
|
3203
|
+
idempotencyKey: string | null;
|
|
3204
|
+
}
|
|
3159
3205
|
declare class Requester {
|
|
3160
3206
|
private readonly apiKey;
|
|
3161
3207
|
private readonly baseUrl;
|
|
3162
3208
|
private readonly fetchImpl;
|
|
3163
3209
|
constructor(apiKey: string, baseUrl: string, fetchImpl: typeof globalThis.fetch);
|
|
3164
|
-
call<K extends OperationId>(method: string, path: string, body?: RequestBodyOf<K>): Promise<SuccessBodyOf<K>>;
|
|
3210
|
+
call<K extends OperationId>(method: string, path: string, body?: RequestBodyOf<K>, extraHeaders?: Record<string, string>): Promise<SuccessBodyOf<K>>;
|
|
3211
|
+
callWithReceipt<K extends OperationId>(method: string, path: string, body?: RequestBodyOf<K>, extraHeaders?: Record<string, string>): Promise<{
|
|
3212
|
+
data: SuccessBodyOf<K>;
|
|
3213
|
+
headers: Headers;
|
|
3214
|
+
}>;
|
|
3165
3215
|
callRaw(method: string, path: string): Promise<ArrayBuffer>;
|
|
3166
3216
|
}
|
|
3167
3217
|
declare class YoutubeNamespace {
|
|
@@ -3330,19 +3380,18 @@ declare class DirectoryNamespace {
|
|
|
3330
3380
|
declare class SerpIntelligenceNamespace {
|
|
3331
3381
|
private readonly r;
|
|
3332
3382
|
constructor(r: Requester);
|
|
3333
|
-
capture(params:
|
|
3383
|
+
capture(params: SerpIntelligenceCaptureParams, options?: SerpIntelligenceCaptureOptions): Promise<{
|
|
3334
3384
|
harvestResult?: components["schemas"]["SerpIntelligenceHarvestResult"];
|
|
3335
3385
|
attempts?: components["schemas"]["SerpIntelligenceCaptureAttempt"][];
|
|
3336
3386
|
locationEvidence?: {
|
|
3337
3387
|
[key: string]: unknown;
|
|
3338
3388
|
} | null;
|
|
3339
3389
|
pageSnapshotArtifacts?: components["schemas"]["SerpPageSnapshotCapture"][];
|
|
3340
|
-
billing
|
|
3341
|
-
creditsUsed
|
|
3342
|
-
requestId?: string;
|
|
3343
|
-
jobId?: string;
|
|
3390
|
+
billing: {
|
|
3391
|
+
creditsUsed: number;
|
|
3344
3392
|
};
|
|
3345
3393
|
}>;
|
|
3394
|
+
captureWithReceipt(params: SerpIntelligenceCaptureParams, options?: SerpIntelligenceCaptureOptions): Promise<SerpIntelligenceCaptureReceipt>;
|
|
3346
3395
|
pageSnapshots(params: RequestBodyOf<'serpIntelligencePageSnapshots'>): Promise<{
|
|
3347
3396
|
pageSnapshotArtifacts?: components["schemas"]["SerpPageSnapshotCapture"][];
|
|
3348
3397
|
attempts?: components["schemas"]["SerpIntelligenceCaptureAttempt"][];
|
|
@@ -3749,4 +3798,4 @@ declare class ScraperApiError extends Error {
|
|
|
3749
3798
|
};
|
|
3750
3799
|
}
|
|
3751
3800
|
|
|
3752
|
-
export { type ConcurrencyLimitBody, type InsufficientBalanceBody, ScraperApiError, ScraperClient, type ScraperClientOptions, type StructuredErrorBody, type components, type operations, type paths };
|
|
3801
|
+
export { type ConcurrencyLimitBody, type InsufficientBalanceBody, ScraperApiError, ScraperClient, type ScraperClientOptions, type SerpIntelligenceCaptureOptions, type SerpIntelligenceCaptureParams, type SerpIntelligenceCaptureReceipt, type StructuredErrorBody, type components, type operations, type paths };
|
package/dist/index.d.ts
CHANGED
|
@@ -17,8 +17,9 @@ interface paths {
|
|
|
17
17
|
put?: never;
|
|
18
18
|
/**
|
|
19
19
|
* Run a Google SERP search, or a full People-Also-Ask harvest
|
|
20
|
-
* @description Set `serpOnly: true` for a pure organic-results/SERP call (
|
|
21
|
-
*
|
|
20
|
+
* @description Set `serpOnly: true` for a pure organic-results/SERP call (4 credits, headless —
|
|
21
|
+
* 14 credits if an anti-bot escalation forces a headful retry; overestimate refunded).
|
|
22
|
+
* Omit or set `false` for a full People-Also-Ask harvest, which also returns SERP data
|
|
22
23
|
* (55 credit base + 3 credits per question actually returned; unused estimate is
|
|
23
24
|
* refunded). Runs synchronously and returns the result inline.
|
|
24
25
|
*/
|
|
@@ -591,7 +592,11 @@ interface paths {
|
|
|
591
592
|
put?: never;
|
|
592
593
|
/**
|
|
593
594
|
* Structured SERP capture with AI Overview/AI Mode detection, entity IDs, and location-match evidence
|
|
594
|
-
* @description
|
|
595
|
+
* @description Holds 14 credits for the SERP and settles to 4 credits when the capture is served
|
|
596
|
+
* headless, or retains 14 credits when anti-bot escalation requires headful mode.
|
|
597
|
+
* When `includePageSnapshots` is true, also holds 1 credit per requested
|
|
598
|
+
* `pageSnapshotLimit` slot and settles to 1 credit per URL actually attempted.
|
|
599
|
+
* Rate-limited to 60 requests/minute per account.
|
|
595
600
|
*/
|
|
596
601
|
post: operations["serpIntelligenceCapture"];
|
|
597
602
|
delete?: never;
|
|
@@ -1259,16 +1264,29 @@ interface components {
|
|
|
1259
1264
|
pages: number;
|
|
1260
1265
|
/** @default false */
|
|
1261
1266
|
debug: boolean;
|
|
1262
|
-
/**
|
|
1267
|
+
/**
|
|
1268
|
+
* @description Also attempt ranking-page snapshots at 1 credit per URL.
|
|
1269
|
+
* @default false
|
|
1270
|
+
*/
|
|
1263
1271
|
includePageSnapshots: boolean;
|
|
1264
|
-
/**
|
|
1272
|
+
/**
|
|
1273
|
+
* @description Maximum snapshot attempts; capacity is held up front and unused capacity is refunded.
|
|
1274
|
+
* @default 0
|
|
1275
|
+
*/
|
|
1265
1276
|
pageSnapshotLimit: number;
|
|
1266
1277
|
};
|
|
1267
1278
|
SerpIntelligencePageSnapshotsRequest: {
|
|
1268
1279
|
urls: string[];
|
|
1269
|
-
|
|
1280
|
+
/** @default 2 */
|
|
1281
|
+
maxConcurrency: number;
|
|
1282
|
+
/** @default 15000 */
|
|
1283
|
+
timeoutMs: number;
|
|
1284
|
+
/** @default false */
|
|
1285
|
+
debug: boolean;
|
|
1286
|
+
} | {
|
|
1287
|
+
targets: {
|
|
1270
1288
|
/** Format: uri */
|
|
1271
|
-
url
|
|
1289
|
+
url: string;
|
|
1272
1290
|
/**
|
|
1273
1291
|
* @default configured_target
|
|
1274
1292
|
* @enum {string}
|
|
@@ -1399,10 +1417,8 @@ interface components {
|
|
|
1399
1417
|
[key: string]: unknown;
|
|
1400
1418
|
} | null;
|
|
1401
1419
|
pageSnapshotArtifacts?: components["schemas"]["SerpPageSnapshotCapture"][];
|
|
1402
|
-
billing
|
|
1403
|
-
creditsUsed
|
|
1404
|
-
requestId?: string;
|
|
1405
|
-
jobId?: string;
|
|
1420
|
+
billing: {
|
|
1421
|
+
creditsUsed: number;
|
|
1406
1422
|
};
|
|
1407
1423
|
};
|
|
1408
1424
|
SerpIntelligencePageSnapshotsResponse: {
|
|
@@ -2702,7 +2718,15 @@ interface operations {
|
|
|
2702
2718
|
serpIntelligenceCapture: {
|
|
2703
2719
|
parameters: {
|
|
2704
2720
|
query?: never;
|
|
2705
|
-
header?:
|
|
2721
|
+
header?: {
|
|
2722
|
+
/**
|
|
2723
|
+
* @description Stable retry key for this capture. Reusing the same key with the same
|
|
2724
|
+
* request body recovers the original debit and settlement; reusing it with
|
|
2725
|
+
* a different body returns `409 idempotency_conflict`. When omitted, the
|
|
2726
|
+
* server generates a key and returns it in the response header.
|
|
2727
|
+
*/
|
|
2728
|
+
"Idempotency-Key"?: string;
|
|
2729
|
+
};
|
|
2706
2730
|
path?: never;
|
|
2707
2731
|
cookie?: never;
|
|
2708
2732
|
};
|
|
@@ -2715,6 +2739,8 @@ interface operations {
|
|
|
2715
2739
|
/** @description Structured SERP capture. */
|
|
2716
2740
|
200: {
|
|
2717
2741
|
headers: {
|
|
2742
|
+
/** @description Retry key accepted from the request or generated by the server. */
|
|
2743
|
+
"Idempotency-Key"?: string;
|
|
2718
2744
|
[name: string]: unknown;
|
|
2719
2745
|
};
|
|
2720
2746
|
content: {
|
|
@@ -2723,6 +2749,17 @@ interface operations {
|
|
|
2723
2749
|
};
|
|
2724
2750
|
400: components["responses"]["StructuredBadRequest"];
|
|
2725
2751
|
402: components["responses"]["InsufficientBalance"];
|
|
2752
|
+
/** @description The Idempotency-Key was already used with a different request body. */
|
|
2753
|
+
409: {
|
|
2754
|
+
headers: {
|
|
2755
|
+
/** @description The conflicting retry key. */
|
|
2756
|
+
"Idempotency-Key"?: string;
|
|
2757
|
+
[name: string]: unknown;
|
|
2758
|
+
};
|
|
2759
|
+
content: {
|
|
2760
|
+
"application/json": components["schemas"]["StructuredError"];
|
|
2761
|
+
};
|
|
2762
|
+
};
|
|
2726
2763
|
429: components["responses"]["StructuredRateLimited"];
|
|
2727
2764
|
500: components["responses"]["StructuredCaptureFailed"];
|
|
2728
2765
|
};
|
|
@@ -3156,12 +3193,25 @@ interface ScraperClientOptions {
|
|
|
3156
3193
|
baseUrl?: string;
|
|
3157
3194
|
fetch?: typeof globalThis.fetch;
|
|
3158
3195
|
}
|
|
3196
|
+
type SerpIntelligenceCaptureDefaultedKey = 'gl' | 'hl' | 'device' | 'proxyMode' | 'pages' | 'debug' | 'includePageSnapshots' | 'pageSnapshotLimit';
|
|
3197
|
+
type SerpIntelligenceCaptureParams = Omit<RequestBodyOf<'serpIntelligenceCapture'>, SerpIntelligenceCaptureDefaultedKey> & Partial<Pick<RequestBodyOf<'serpIntelligenceCapture'>, SerpIntelligenceCaptureDefaultedKey>>;
|
|
3198
|
+
interface SerpIntelligenceCaptureOptions {
|
|
3199
|
+
idempotencyKey?: string;
|
|
3200
|
+
}
|
|
3201
|
+
interface SerpIntelligenceCaptureReceipt {
|
|
3202
|
+
data: SuccessBodyOf<'serpIntelligenceCapture'>;
|
|
3203
|
+
idempotencyKey: string | null;
|
|
3204
|
+
}
|
|
3159
3205
|
declare class Requester {
|
|
3160
3206
|
private readonly apiKey;
|
|
3161
3207
|
private readonly baseUrl;
|
|
3162
3208
|
private readonly fetchImpl;
|
|
3163
3209
|
constructor(apiKey: string, baseUrl: string, fetchImpl: typeof globalThis.fetch);
|
|
3164
|
-
call<K extends OperationId>(method: string, path: string, body?: RequestBodyOf<K>): Promise<SuccessBodyOf<K>>;
|
|
3210
|
+
call<K extends OperationId>(method: string, path: string, body?: RequestBodyOf<K>, extraHeaders?: Record<string, string>): Promise<SuccessBodyOf<K>>;
|
|
3211
|
+
callWithReceipt<K extends OperationId>(method: string, path: string, body?: RequestBodyOf<K>, extraHeaders?: Record<string, string>): Promise<{
|
|
3212
|
+
data: SuccessBodyOf<K>;
|
|
3213
|
+
headers: Headers;
|
|
3214
|
+
}>;
|
|
3165
3215
|
callRaw(method: string, path: string): Promise<ArrayBuffer>;
|
|
3166
3216
|
}
|
|
3167
3217
|
declare class YoutubeNamespace {
|
|
@@ -3330,19 +3380,18 @@ declare class DirectoryNamespace {
|
|
|
3330
3380
|
declare class SerpIntelligenceNamespace {
|
|
3331
3381
|
private readonly r;
|
|
3332
3382
|
constructor(r: Requester);
|
|
3333
|
-
capture(params:
|
|
3383
|
+
capture(params: SerpIntelligenceCaptureParams, options?: SerpIntelligenceCaptureOptions): Promise<{
|
|
3334
3384
|
harvestResult?: components["schemas"]["SerpIntelligenceHarvestResult"];
|
|
3335
3385
|
attempts?: components["schemas"]["SerpIntelligenceCaptureAttempt"][];
|
|
3336
3386
|
locationEvidence?: {
|
|
3337
3387
|
[key: string]: unknown;
|
|
3338
3388
|
} | null;
|
|
3339
3389
|
pageSnapshotArtifacts?: components["schemas"]["SerpPageSnapshotCapture"][];
|
|
3340
|
-
billing
|
|
3341
|
-
creditsUsed
|
|
3342
|
-
requestId?: string;
|
|
3343
|
-
jobId?: string;
|
|
3390
|
+
billing: {
|
|
3391
|
+
creditsUsed: number;
|
|
3344
3392
|
};
|
|
3345
3393
|
}>;
|
|
3394
|
+
captureWithReceipt(params: SerpIntelligenceCaptureParams, options?: SerpIntelligenceCaptureOptions): Promise<SerpIntelligenceCaptureReceipt>;
|
|
3346
3395
|
pageSnapshots(params: RequestBodyOf<'serpIntelligencePageSnapshots'>): Promise<{
|
|
3347
3396
|
pageSnapshotArtifacts?: components["schemas"]["SerpPageSnapshotCapture"][];
|
|
3348
3397
|
attempts?: components["schemas"]["SerpIntelligenceCaptureAttempt"][];
|
|
@@ -3749,4 +3798,4 @@ declare class ScraperApiError extends Error {
|
|
|
3749
3798
|
};
|
|
3750
3799
|
}
|
|
3751
3800
|
|
|
3752
|
-
export { type ConcurrencyLimitBody, type InsufficientBalanceBody, ScraperApiError, ScraperClient, type ScraperClientOptions, type StructuredErrorBody, type components, type operations, type paths };
|
|
3801
|
+
export { type ConcurrencyLimitBody, type InsufficientBalanceBody, ScraperApiError, ScraperClient, type ScraperClientOptions, type SerpIntelligenceCaptureOptions, type SerpIntelligenceCaptureParams, type SerpIntelligenceCaptureReceipt, type StructuredErrorBody, type components, type operations, type paths };
|
package/dist/index.js
CHANGED
|
@@ -56,18 +56,22 @@ var Requester = class {
|
|
|
56
56
|
apiKey;
|
|
57
57
|
baseUrl;
|
|
58
58
|
fetchImpl;
|
|
59
|
-
async call(method, path, body) {
|
|
59
|
+
async call(method, path, body, extraHeaders = {}) {
|
|
60
|
+
return (await this.callWithReceipt(method, path, body, extraHeaders)).data;
|
|
61
|
+
}
|
|
62
|
+
async callWithReceipt(method, path, body, extraHeaders = {}) {
|
|
60
63
|
const res = await this.fetchImpl(`${this.baseUrl}${path}`, {
|
|
61
64
|
method,
|
|
62
65
|
headers: {
|
|
63
66
|
"x-api-key": this.apiKey,
|
|
64
|
-
...body !== void 0 ? { "content-type": "application/json" } : {}
|
|
67
|
+
...body !== void 0 ? { "content-type": "application/json" } : {},
|
|
68
|
+
...extraHeaders
|
|
65
69
|
},
|
|
66
70
|
body: body !== void 0 ? JSON.stringify(body) : void 0
|
|
67
71
|
});
|
|
68
72
|
const data = await res.json().catch(() => void 0);
|
|
69
73
|
if (!res.ok) throw new ScraperApiError(res.status, data);
|
|
70
|
-
return data;
|
|
74
|
+
return { data, headers: res.headers };
|
|
71
75
|
}
|
|
72
76
|
async callRaw(method, path) {
|
|
73
77
|
const res = await this.fetchImpl(`${this.baseUrl}${path}`, { method, headers: { "x-api-key": this.apiKey } });
|
|
@@ -197,8 +201,25 @@ var SerpIntelligenceNamespace = class {
|
|
|
197
201
|
this.r = r;
|
|
198
202
|
}
|
|
199
203
|
r;
|
|
200
|
-
capture(params) {
|
|
201
|
-
return this.r.call(
|
|
204
|
+
capture(params, options = {}) {
|
|
205
|
+
return this.r.call(
|
|
206
|
+
"POST",
|
|
207
|
+
"/serp-intelligence/capture",
|
|
208
|
+
params,
|
|
209
|
+
options.idempotencyKey === void 0 ? {} : { "Idempotency-Key": options.idempotencyKey }
|
|
210
|
+
);
|
|
211
|
+
}
|
|
212
|
+
async captureWithReceipt(params, options = {}) {
|
|
213
|
+
const result = await this.r.callWithReceipt(
|
|
214
|
+
"POST",
|
|
215
|
+
"/serp-intelligence/capture",
|
|
216
|
+
params,
|
|
217
|
+
options.idempotencyKey === void 0 ? {} : { "Idempotency-Key": options.idempotencyKey }
|
|
218
|
+
);
|
|
219
|
+
return {
|
|
220
|
+
data: result.data,
|
|
221
|
+
idempotencyKey: result.headers.get("Idempotency-Key")
|
|
222
|
+
};
|
|
202
223
|
}
|
|
203
224
|
pageSnapshots(params) {
|
|
204
225
|
return this.r.call("POST", "/serp-intelligence/page-snapshots", params);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mcpscraper-sdk",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.4",
|
|
4
4
|
"description": "Official Node.js client for all 159 mcpscraper.dev MCP tools and the REST API",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"seo-api"
|
|
32
32
|
],
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"mcpscraper-memory-sdk": "^0.11.
|
|
34
|
+
"mcpscraper-memory-sdk": "^0.11.4"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"openapi-typescript": "^7.13.0"
|