mcpscraper-sdk 0.12.3 → 0.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.
- package/README.md +17 -1
- package/dist/index.cjs +26 -5
- package/dist/index.d.cts +65 -17
- package/dist/index.d.ts +65 -17
- package/dist/index.js +26 -5
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -54,7 +54,7 @@ await client.tools.connections.exportConnectedServiceData({
|
|
|
54
54
|
})
|
|
55
55
|
```
|
|
56
56
|
|
|
57
|
-
The connected-data export performs bounded Gmail, Calendar, Zoom, Meta Marketing, or Resend pagination server-side and returns small results inline or a private seven-day JSONL artifact. Use `meta_ads_insights` for daily account, campaign, ad-set, and ad reporting across connected Meta ad accounts. Resend can aggregate sent/received mail, logs, contacts, broadcasts, and templates with `resend_data`. Resume partial exports with the returned `continuation` object; renew an expired signed URL with `client.tools.connections.renewConnectedDataDownload({ artifactId })`. Use `listServiceConnections` for verified grants and per-tool permission blockers, then `describeServiceConnectionTool` for the exact provider-native schema before calling through the generic connection bridges.
|
|
57
|
+
The connected-data export performs bounded Gmail, Calendar, Google Search Console, Zoom, Meta Marketing, or Resend pagination server-side and returns small results inline or a private seven-day JSONL artifact. Use `search_console_performance` for bounded Search Analytics rows across every accessible property, and `meta_ads_insights` for daily account, campaign, ad-set, and ad reporting across connected Meta ad accounts. Resend can aggregate sent/received mail, logs, contacts, broadcasts, and templates with `resend_data`. Resume partial exports with the returned `continuation` object; renew an expired signed URL with `client.tools.connections.renewConnectedDataDownload({ artifactId })`. Use `listServiceConnections` for verified grants and per-tool permission blockers, then `describeServiceConnectionTool` for the exact provider-native schema before calling through the generic connection bridges.
|
|
58
58
|
|
|
59
59
|
Integrations are included with an active Starter plan or higher: OAuth connect/reconnect and direct connected-service reads, approved actions, exports, and snapshots do not currently have an extra connection-operation debit. Scheduled Actions use the shared Credit balance at 75 Credits per started occurrence; agent-mode runs also add 1.5 times OpenRouter's actual reported model cost. Inspect the live policy with `await client.tools.schedule.getScheduleStatus()`.
|
|
60
60
|
|
|
@@ -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
|
@@ -592,7 +592,11 @@ interface paths {
|
|
|
592
592
|
put?: never;
|
|
593
593
|
/**
|
|
594
594
|
* Structured SERP capture with AI Overview/AI Mode detection, entity IDs, and location-match evidence
|
|
595
|
-
* @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.
|
|
596
600
|
*/
|
|
597
601
|
post: operations["serpIntelligenceCapture"];
|
|
598
602
|
delete?: never;
|
|
@@ -1260,16 +1264,29 @@ interface components {
|
|
|
1260
1264
|
pages: number;
|
|
1261
1265
|
/** @default false */
|
|
1262
1266
|
debug: boolean;
|
|
1263
|
-
/**
|
|
1267
|
+
/**
|
|
1268
|
+
* @description Also attempt ranking-page snapshots at 1 credit per URL.
|
|
1269
|
+
* @default false
|
|
1270
|
+
*/
|
|
1264
1271
|
includePageSnapshots: boolean;
|
|
1265
|
-
/**
|
|
1272
|
+
/**
|
|
1273
|
+
* @description Maximum snapshot attempts; capacity is held up front and unused capacity is refunded.
|
|
1274
|
+
* @default 0
|
|
1275
|
+
*/
|
|
1266
1276
|
pageSnapshotLimit: number;
|
|
1267
1277
|
};
|
|
1268
1278
|
SerpIntelligencePageSnapshotsRequest: {
|
|
1269
1279
|
urls: string[];
|
|
1270
|
-
|
|
1280
|
+
/** @default 2 */
|
|
1281
|
+
maxConcurrency: number;
|
|
1282
|
+
/** @default 15000 */
|
|
1283
|
+
timeoutMs: number;
|
|
1284
|
+
/** @default false */
|
|
1285
|
+
debug: boolean;
|
|
1286
|
+
} | {
|
|
1287
|
+
targets: {
|
|
1271
1288
|
/** Format: uri */
|
|
1272
|
-
url
|
|
1289
|
+
url: string;
|
|
1273
1290
|
/**
|
|
1274
1291
|
* @default configured_target
|
|
1275
1292
|
* @enum {string}
|
|
@@ -1400,10 +1417,8 @@ interface components {
|
|
|
1400
1417
|
[key: string]: unknown;
|
|
1401
1418
|
} | null;
|
|
1402
1419
|
pageSnapshotArtifacts?: components["schemas"]["SerpPageSnapshotCapture"][];
|
|
1403
|
-
billing
|
|
1404
|
-
creditsUsed
|
|
1405
|
-
requestId?: string;
|
|
1406
|
-
jobId?: string;
|
|
1420
|
+
billing: {
|
|
1421
|
+
creditsUsed: number;
|
|
1407
1422
|
};
|
|
1408
1423
|
};
|
|
1409
1424
|
SerpIntelligencePageSnapshotsResponse: {
|
|
@@ -2703,7 +2718,15 @@ interface operations {
|
|
|
2703
2718
|
serpIntelligenceCapture: {
|
|
2704
2719
|
parameters: {
|
|
2705
2720
|
query?: never;
|
|
2706
|
-
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
|
+
};
|
|
2707
2730
|
path?: never;
|
|
2708
2731
|
cookie?: never;
|
|
2709
2732
|
};
|
|
@@ -2716,6 +2739,8 @@ interface operations {
|
|
|
2716
2739
|
/** @description Structured SERP capture. */
|
|
2717
2740
|
200: {
|
|
2718
2741
|
headers: {
|
|
2742
|
+
/** @description Retry key accepted from the request or generated by the server. */
|
|
2743
|
+
"Idempotency-Key"?: string;
|
|
2719
2744
|
[name: string]: unknown;
|
|
2720
2745
|
};
|
|
2721
2746
|
content: {
|
|
@@ -2724,6 +2749,17 @@ interface operations {
|
|
|
2724
2749
|
};
|
|
2725
2750
|
400: components["responses"]["StructuredBadRequest"];
|
|
2726
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
|
+
};
|
|
2727
2763
|
429: components["responses"]["StructuredRateLimited"];
|
|
2728
2764
|
500: components["responses"]["StructuredCaptureFailed"];
|
|
2729
2765
|
};
|
|
@@ -3157,12 +3193,25 @@ interface ScraperClientOptions {
|
|
|
3157
3193
|
baseUrl?: string;
|
|
3158
3194
|
fetch?: typeof globalThis.fetch;
|
|
3159
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
|
+
}
|
|
3160
3205
|
declare class Requester {
|
|
3161
3206
|
private readonly apiKey;
|
|
3162
3207
|
private readonly baseUrl;
|
|
3163
3208
|
private readonly fetchImpl;
|
|
3164
3209
|
constructor(apiKey: string, baseUrl: string, fetchImpl: typeof globalThis.fetch);
|
|
3165
|
-
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
|
+
}>;
|
|
3166
3215
|
callRaw(method: string, path: string): Promise<ArrayBuffer>;
|
|
3167
3216
|
}
|
|
3168
3217
|
declare class YoutubeNamespace {
|
|
@@ -3331,19 +3380,18 @@ declare class DirectoryNamespace {
|
|
|
3331
3380
|
declare class SerpIntelligenceNamespace {
|
|
3332
3381
|
private readonly r;
|
|
3333
3382
|
constructor(r: Requester);
|
|
3334
|
-
capture(params:
|
|
3383
|
+
capture(params: SerpIntelligenceCaptureParams, options?: SerpIntelligenceCaptureOptions): Promise<{
|
|
3335
3384
|
harvestResult?: components["schemas"]["SerpIntelligenceHarvestResult"];
|
|
3336
3385
|
attempts?: components["schemas"]["SerpIntelligenceCaptureAttempt"][];
|
|
3337
3386
|
locationEvidence?: {
|
|
3338
3387
|
[key: string]: unknown;
|
|
3339
3388
|
} | null;
|
|
3340
3389
|
pageSnapshotArtifacts?: components["schemas"]["SerpPageSnapshotCapture"][];
|
|
3341
|
-
billing
|
|
3342
|
-
creditsUsed
|
|
3343
|
-
requestId?: string;
|
|
3344
|
-
jobId?: string;
|
|
3390
|
+
billing: {
|
|
3391
|
+
creditsUsed: number;
|
|
3345
3392
|
};
|
|
3346
3393
|
}>;
|
|
3394
|
+
captureWithReceipt(params: SerpIntelligenceCaptureParams, options?: SerpIntelligenceCaptureOptions): Promise<SerpIntelligenceCaptureReceipt>;
|
|
3347
3395
|
pageSnapshots(params: RequestBodyOf<'serpIntelligencePageSnapshots'>): Promise<{
|
|
3348
3396
|
pageSnapshotArtifacts?: components["schemas"]["SerpPageSnapshotCapture"][];
|
|
3349
3397
|
attempts?: components["schemas"]["SerpIntelligenceCaptureAttempt"][];
|
|
@@ -3750,4 +3798,4 @@ declare class ScraperApiError extends Error {
|
|
|
3750
3798
|
};
|
|
3751
3799
|
}
|
|
3752
3800
|
|
|
3753
|
-
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
|
@@ -592,7 +592,11 @@ interface paths {
|
|
|
592
592
|
put?: never;
|
|
593
593
|
/**
|
|
594
594
|
* Structured SERP capture with AI Overview/AI Mode detection, entity IDs, and location-match evidence
|
|
595
|
-
* @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.
|
|
596
600
|
*/
|
|
597
601
|
post: operations["serpIntelligenceCapture"];
|
|
598
602
|
delete?: never;
|
|
@@ -1260,16 +1264,29 @@ interface components {
|
|
|
1260
1264
|
pages: number;
|
|
1261
1265
|
/** @default false */
|
|
1262
1266
|
debug: boolean;
|
|
1263
|
-
/**
|
|
1267
|
+
/**
|
|
1268
|
+
* @description Also attempt ranking-page snapshots at 1 credit per URL.
|
|
1269
|
+
* @default false
|
|
1270
|
+
*/
|
|
1264
1271
|
includePageSnapshots: boolean;
|
|
1265
|
-
/**
|
|
1272
|
+
/**
|
|
1273
|
+
* @description Maximum snapshot attempts; capacity is held up front and unused capacity is refunded.
|
|
1274
|
+
* @default 0
|
|
1275
|
+
*/
|
|
1266
1276
|
pageSnapshotLimit: number;
|
|
1267
1277
|
};
|
|
1268
1278
|
SerpIntelligencePageSnapshotsRequest: {
|
|
1269
1279
|
urls: string[];
|
|
1270
|
-
|
|
1280
|
+
/** @default 2 */
|
|
1281
|
+
maxConcurrency: number;
|
|
1282
|
+
/** @default 15000 */
|
|
1283
|
+
timeoutMs: number;
|
|
1284
|
+
/** @default false */
|
|
1285
|
+
debug: boolean;
|
|
1286
|
+
} | {
|
|
1287
|
+
targets: {
|
|
1271
1288
|
/** Format: uri */
|
|
1272
|
-
url
|
|
1289
|
+
url: string;
|
|
1273
1290
|
/**
|
|
1274
1291
|
* @default configured_target
|
|
1275
1292
|
* @enum {string}
|
|
@@ -1400,10 +1417,8 @@ interface components {
|
|
|
1400
1417
|
[key: string]: unknown;
|
|
1401
1418
|
} | null;
|
|
1402
1419
|
pageSnapshotArtifacts?: components["schemas"]["SerpPageSnapshotCapture"][];
|
|
1403
|
-
billing
|
|
1404
|
-
creditsUsed
|
|
1405
|
-
requestId?: string;
|
|
1406
|
-
jobId?: string;
|
|
1420
|
+
billing: {
|
|
1421
|
+
creditsUsed: number;
|
|
1407
1422
|
};
|
|
1408
1423
|
};
|
|
1409
1424
|
SerpIntelligencePageSnapshotsResponse: {
|
|
@@ -2703,7 +2718,15 @@ interface operations {
|
|
|
2703
2718
|
serpIntelligenceCapture: {
|
|
2704
2719
|
parameters: {
|
|
2705
2720
|
query?: never;
|
|
2706
|
-
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
|
+
};
|
|
2707
2730
|
path?: never;
|
|
2708
2731
|
cookie?: never;
|
|
2709
2732
|
};
|
|
@@ -2716,6 +2739,8 @@ interface operations {
|
|
|
2716
2739
|
/** @description Structured SERP capture. */
|
|
2717
2740
|
200: {
|
|
2718
2741
|
headers: {
|
|
2742
|
+
/** @description Retry key accepted from the request or generated by the server. */
|
|
2743
|
+
"Idempotency-Key"?: string;
|
|
2719
2744
|
[name: string]: unknown;
|
|
2720
2745
|
};
|
|
2721
2746
|
content: {
|
|
@@ -2724,6 +2749,17 @@ interface operations {
|
|
|
2724
2749
|
};
|
|
2725
2750
|
400: components["responses"]["StructuredBadRequest"];
|
|
2726
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
|
+
};
|
|
2727
2763
|
429: components["responses"]["StructuredRateLimited"];
|
|
2728
2764
|
500: components["responses"]["StructuredCaptureFailed"];
|
|
2729
2765
|
};
|
|
@@ -3157,12 +3193,25 @@ interface ScraperClientOptions {
|
|
|
3157
3193
|
baseUrl?: string;
|
|
3158
3194
|
fetch?: typeof globalThis.fetch;
|
|
3159
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
|
+
}
|
|
3160
3205
|
declare class Requester {
|
|
3161
3206
|
private readonly apiKey;
|
|
3162
3207
|
private readonly baseUrl;
|
|
3163
3208
|
private readonly fetchImpl;
|
|
3164
3209
|
constructor(apiKey: string, baseUrl: string, fetchImpl: typeof globalThis.fetch);
|
|
3165
|
-
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
|
+
}>;
|
|
3166
3215
|
callRaw(method: string, path: string): Promise<ArrayBuffer>;
|
|
3167
3216
|
}
|
|
3168
3217
|
declare class YoutubeNamespace {
|
|
@@ -3331,19 +3380,18 @@ declare class DirectoryNamespace {
|
|
|
3331
3380
|
declare class SerpIntelligenceNamespace {
|
|
3332
3381
|
private readonly r;
|
|
3333
3382
|
constructor(r: Requester);
|
|
3334
|
-
capture(params:
|
|
3383
|
+
capture(params: SerpIntelligenceCaptureParams, options?: SerpIntelligenceCaptureOptions): Promise<{
|
|
3335
3384
|
harvestResult?: components["schemas"]["SerpIntelligenceHarvestResult"];
|
|
3336
3385
|
attempts?: components["schemas"]["SerpIntelligenceCaptureAttempt"][];
|
|
3337
3386
|
locationEvidence?: {
|
|
3338
3387
|
[key: string]: unknown;
|
|
3339
3388
|
} | null;
|
|
3340
3389
|
pageSnapshotArtifacts?: components["schemas"]["SerpPageSnapshotCapture"][];
|
|
3341
|
-
billing
|
|
3342
|
-
creditsUsed
|
|
3343
|
-
requestId?: string;
|
|
3344
|
-
jobId?: string;
|
|
3390
|
+
billing: {
|
|
3391
|
+
creditsUsed: number;
|
|
3345
3392
|
};
|
|
3346
3393
|
}>;
|
|
3394
|
+
captureWithReceipt(params: SerpIntelligenceCaptureParams, options?: SerpIntelligenceCaptureOptions): Promise<SerpIntelligenceCaptureReceipt>;
|
|
3347
3395
|
pageSnapshots(params: RequestBodyOf<'serpIntelligencePageSnapshots'>): Promise<{
|
|
3348
3396
|
pageSnapshotArtifacts?: components["schemas"]["SerpPageSnapshotCapture"][];
|
|
3349
3397
|
attempts?: components["schemas"]["SerpIntelligenceCaptureAttempt"][];
|
|
@@ -3750,4 +3798,4 @@ declare class ScraperApiError extends Error {
|
|
|
3750
3798
|
};
|
|
3751
3799
|
}
|
|
3752
3800
|
|
|
3753
|
-
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.
|
|
3
|
+
"version": "0.13.0",
|
|
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.
|
|
34
|
+
"mcpscraper-memory-sdk": "^0.12.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"openapi-typescript": "^7.13.0"
|