scrapfly-sdk 0.9.0 → 0.10.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/esm/client.d.ts +16 -0
- package/esm/client.d.ts.map +1 -1
- package/esm/client.js +116 -0
- package/esm/main.d.ts +1 -0
- package/esm/main.d.ts.map +1 -1
- package/esm/monitoringconfig.d.ts +36 -0
- package/esm/monitoringconfig.d.ts.map +1 -0
- package/esm/monitoringconfig.js +10 -0
- package/package.json +1 -1
- package/script/client.d.ts +16 -0
- package/script/client.d.ts.map +1 -1
- package/script/client.js +116 -0
- package/script/main.d.ts +1 -0
- package/script/main.d.ts.map +1 -1
- package/script/monitoringconfig.d.ts +36 -0
- package/script/monitoringconfig.d.ts.map +1 -0
- package/script/monitoringconfig.js +13 -0
package/esm/client.d.ts
CHANGED
|
@@ -5,8 +5,10 @@ import type { ScreenshotConfig } from './screenshotconfig.js';
|
|
|
5
5
|
import type { ExtractionConfig } from './extractionconfig.js';
|
|
6
6
|
import { BrowserConfig } from './browserconfig.js';
|
|
7
7
|
import { type AccountData, ExtractionResult, ScrapeResult, ScreenshotResult } from './result.js';
|
|
8
|
+
import type { Rec } from './types.js';
|
|
8
9
|
import type { CrawlerConfig, CrawlerContentFormat } from './crawlerconfig.js';
|
|
9
10
|
import { CrawlerArtifact, type CrawlerArtifactType, CrawlerContents, CrawlerStatus, CrawlerUrls } from './crawlerresult.js';
|
|
11
|
+
import { type CloudBrowserMonitoringOptions, type MonitoringMetricsOptions, type MonitoringTargetMetricsOptions } from './monitoringconfig.js';
|
|
10
12
|
export declare class ScrapflyClient {
|
|
11
13
|
HOST: string;
|
|
12
14
|
CLOUD_BROWSER_HOST: string;
|
|
@@ -37,6 +39,20 @@ export declare class ScrapflyClient {
|
|
|
37
39
|
* Retrieve Scrapfly account details
|
|
38
40
|
*/
|
|
39
41
|
account(): Promise<AccountData>;
|
|
42
|
+
private monitoringRequest;
|
|
43
|
+
private buildMetricsParams;
|
|
44
|
+
private buildTargetParams;
|
|
45
|
+
getMonitoringMetrics(options?: MonitoringMetricsOptions): Promise<Rec<any>>;
|
|
46
|
+
getMonitoringTargetMetrics(options: MonitoringTargetMetricsOptions): Promise<Rec<any>>;
|
|
47
|
+
getScreenshotMonitoringMetrics(options?: MonitoringMetricsOptions): Promise<Rec<any>>;
|
|
48
|
+
getScreenshotMonitoringTargetMetrics(options: MonitoringTargetMetricsOptions): Promise<Rec<any>>;
|
|
49
|
+
getExtractionMonitoringMetrics(options?: MonitoringMetricsOptions): Promise<Rec<any>>;
|
|
50
|
+
getExtractionMonitoringTargetMetrics(options: MonitoringTargetMetricsOptions): Promise<Rec<any>>;
|
|
51
|
+
getCrawlerMonitoringMetrics(options?: MonitoringMetricsOptions): Promise<Rec<any>>;
|
|
52
|
+
getCrawlerMonitoringTargetMetrics(options: MonitoringTargetMetricsOptions): Promise<Rec<any>>;
|
|
53
|
+
getBrowserMonitoringMetrics(options?: CloudBrowserMonitoringOptions): Promise<Rec<any>>;
|
|
54
|
+
getBrowserMonitoringTimeseries(options?: CloudBrowserMonitoringOptions): Promise<Rec<any>>;
|
|
55
|
+
private buildBrowserParams;
|
|
40
56
|
/**
|
|
41
57
|
* Issue a single scrape command from a given scrape configuration
|
|
42
58
|
*/
|
package/esm/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAC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BAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,WAAW,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;IAkBxF;;OAEG;IACG,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAgBvE;;OAEG;IACG,oBAAoB,IAAI,OAAO,CAAC;QAAE,QAAQ,EAAE,GAAG,EAAE,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;CAe1E"}
|
package/esm/client.js
CHANGED
|
@@ -6,6 +6,7 @@ import { BrowserConfig } from './browserconfig.js';
|
|
|
6
6
|
import { ExtractionResult, ScrapeResult, ScreenshotResult } from './result.js';
|
|
7
7
|
import { log } from './logger.js';
|
|
8
8
|
import { CrawlerArtifact, CrawlerContents, CrawlerStatus, CrawlerUrls } from './crawlerresult.js';
|
|
9
|
+
import { formatMonitoringDate, } from './monitoringconfig.js';
|
|
9
10
|
export class ScrapflyClient {
|
|
10
11
|
constructor(options) {
|
|
11
12
|
Object.defineProperty(this, "HOST", {
|
|
@@ -229,6 +230,121 @@ export class ScrapflyClient {
|
|
|
229
230
|
}
|
|
230
231
|
return data;
|
|
231
232
|
}
|
|
233
|
+
// ── Monitoring API (Enterprise+ plan only) ──────────────────────
|
|
234
|
+
// The Monitoring API exposes per-product aggregates and per-target
|
|
235
|
+
// timeseries. Web Scraping / Screenshot / Extraction / Crawler share
|
|
236
|
+
// one shape (request-based) but live under different URL prefixes;
|
|
237
|
+
// Cloud Browser is session-based and exposes a distinct shape.
|
|
238
|
+
// See https://scrapfly.io/docs/monitoring#api
|
|
239
|
+
async monitoringRequest(path, params) {
|
|
240
|
+
const url = new URL(this.HOST + path);
|
|
241
|
+
url.search = new URLSearchParams(params).toString();
|
|
242
|
+
const response = await this.fetch({
|
|
243
|
+
url: url.toString(),
|
|
244
|
+
method: 'GET',
|
|
245
|
+
headers: {
|
|
246
|
+
'user-agent': this.ua,
|
|
247
|
+
'accept-encoding': 'gzip, deflate, br',
|
|
248
|
+
accept: 'application/json',
|
|
249
|
+
},
|
|
250
|
+
});
|
|
251
|
+
const data = (await response.json());
|
|
252
|
+
if ('error_id' in data) {
|
|
253
|
+
if (data.http_code == 401 || response.status == 401) {
|
|
254
|
+
throw new errors.BadApiKeyError(JSON.stringify(data));
|
|
255
|
+
}
|
|
256
|
+
throw new errors.ApiHttpClientError(JSON.stringify(data));
|
|
257
|
+
}
|
|
258
|
+
return data;
|
|
259
|
+
}
|
|
260
|
+
buildMetricsParams(options) {
|
|
261
|
+
const params = {
|
|
262
|
+
key: this.key,
|
|
263
|
+
format: options.format ?? 'structured',
|
|
264
|
+
};
|
|
265
|
+
if (options.period !== undefined)
|
|
266
|
+
params.period = options.period;
|
|
267
|
+
if (options.aggregation !== undefined && options.aggregation.length > 0) {
|
|
268
|
+
params.aggregation = options.aggregation.join(',');
|
|
269
|
+
}
|
|
270
|
+
if (options.includeWebhook)
|
|
271
|
+
params.include_webhook = 'true';
|
|
272
|
+
return params;
|
|
273
|
+
}
|
|
274
|
+
buildTargetParams(options) {
|
|
275
|
+
if ((options.start && !options.end) || (!options.start && options.end)) {
|
|
276
|
+
throw new Error('You must provide both start and end date');
|
|
277
|
+
}
|
|
278
|
+
const params = {
|
|
279
|
+
key: this.key,
|
|
280
|
+
domain: options.domain,
|
|
281
|
+
group_subdomain: String(options.groupSubdomain ?? false),
|
|
282
|
+
};
|
|
283
|
+
if (options.start && options.end) {
|
|
284
|
+
params.start = formatMonitoringDate(options.start);
|
|
285
|
+
params.end = formatMonitoringDate(options.end);
|
|
286
|
+
}
|
|
287
|
+
else if (options.period !== undefined) {
|
|
288
|
+
params.period = options.period;
|
|
289
|
+
}
|
|
290
|
+
else {
|
|
291
|
+
params.period = 'last24h';
|
|
292
|
+
}
|
|
293
|
+
if (options.includeWebhook)
|
|
294
|
+
params.include_webhook = 'true';
|
|
295
|
+
return params;
|
|
296
|
+
}
|
|
297
|
+
// ── Web Scraping API (existing — kept for backward compat) ──────
|
|
298
|
+
async getMonitoringMetrics(options = {}) {
|
|
299
|
+
return this.monitoringRequest('/scrape/monitoring/metrics', this.buildMetricsParams(options));
|
|
300
|
+
}
|
|
301
|
+
async getMonitoringTargetMetrics(options) {
|
|
302
|
+
return this.monitoringRequest('/scrape/monitoring/metrics/target', this.buildTargetParams(options));
|
|
303
|
+
}
|
|
304
|
+
// ── Screenshot API ───────────────────────────────────────────────
|
|
305
|
+
async getScreenshotMonitoringMetrics(options = {}) {
|
|
306
|
+
return this.monitoringRequest('/screenshot/monitoring/metrics', this.buildMetricsParams(options));
|
|
307
|
+
}
|
|
308
|
+
async getScreenshotMonitoringTargetMetrics(options) {
|
|
309
|
+
return this.monitoringRequest('/screenshot/monitoring/metrics/target', this.buildTargetParams(options));
|
|
310
|
+
}
|
|
311
|
+
// ── Extraction API ───────────────────────────────────────────────
|
|
312
|
+
async getExtractionMonitoringMetrics(options = {}) {
|
|
313
|
+
return this.monitoringRequest('/extraction/monitoring/metrics', this.buildMetricsParams(options));
|
|
314
|
+
}
|
|
315
|
+
async getExtractionMonitoringTargetMetrics(options) {
|
|
316
|
+
return this.monitoringRequest('/extraction/monitoring/metrics/target', this.buildTargetParams(options));
|
|
317
|
+
}
|
|
318
|
+
// ── Crawler API ──────────────────────────────────────────────────
|
|
319
|
+
async getCrawlerMonitoringMetrics(options = {}) {
|
|
320
|
+
return this.monitoringRequest('/crawl/monitoring/metrics', this.buildMetricsParams(options));
|
|
321
|
+
}
|
|
322
|
+
async getCrawlerMonitoringTargetMetrics(options) {
|
|
323
|
+
return this.monitoringRequest('/crawl/monitoring/metrics/target', this.buildTargetParams(options));
|
|
324
|
+
}
|
|
325
|
+
// ── Cloud Browser API (session-based, distinct shape) ────────────
|
|
326
|
+
async getBrowserMonitoringMetrics(options = {}) {
|
|
327
|
+
return this.monitoringRequest('/browser/monitoring/metrics', this.buildBrowserParams(options));
|
|
328
|
+
}
|
|
329
|
+
async getBrowserMonitoringTimeseries(options = {}) {
|
|
330
|
+
return this.monitoringRequest('/browser/monitoring/metrics/timeseries', this.buildBrowserParams(options));
|
|
331
|
+
}
|
|
332
|
+
buildBrowserParams(options) {
|
|
333
|
+
if ((options.start && !options.end) || (!options.start && options.end)) {
|
|
334
|
+
throw new Error('You must provide both start and end date');
|
|
335
|
+
}
|
|
336
|
+
const params = { key: this.key };
|
|
337
|
+
if (options.start && options.end) {
|
|
338
|
+
params.start = formatMonitoringDate(options.start);
|
|
339
|
+
params.end = formatMonitoringDate(options.end);
|
|
340
|
+
}
|
|
341
|
+
else if (options.period !== undefined) {
|
|
342
|
+
params.period = options.period;
|
|
343
|
+
}
|
|
344
|
+
if (options.proxyPool !== undefined)
|
|
345
|
+
params.proxy_pool = options.proxyPool;
|
|
346
|
+
return params;
|
|
347
|
+
}
|
|
232
348
|
/**
|
|
233
349
|
* Issue a single scrape command from a given scrape configuration
|
|
234
350
|
*/
|
package/esm/main.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export type { CrawlerConfigOptions, CrawlerContentFormat, CrawlerWebhookEventNam
|
|
|
12
12
|
export { Crawl } from './crawl.js';
|
|
13
13
|
export { CrawlerArtifact, CrawlerContents, CrawlerStatus, CrawlerUrls, parseCrawlerWebhook, } from './crawlerresult.js';
|
|
14
14
|
export type { CrawlerArtifactType, CrawlerLifecycleWebhook, CrawlerState, CrawlerStatusValue, CrawlerStopReason, CrawlerUrlDiscoveredWebhook, CrawlerUrlEntry, CrawlerUrlFailedWebhook, CrawlerUrlSkippedWebhook, CrawlerUrlVisitedWebhook, CrawlerWebhookCommon, CrawlerWebhookPayload, } from './crawlerresult.js';
|
|
15
|
+
export type { CloudBrowserMonitoringOptions, MonitoringAggregation, MonitoringDataFormat, MonitoringMetricsOptions, MonitoringPeriod, MonitoringTargetMetricsOptions, } from './monitoringconfig.js';
|
|
15
16
|
export { log } from './logger.js';
|
|
16
17
|
export { createServer, verifySignature } from './webhookserver.js';
|
|
17
18
|
//# sourceMappingURL=main.d.ts.map
|
package/esm/main.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EACL,MAAM,IAAI,YAAY,EACtB,YAAY,IAAI,mBAAmB,EACnC,YAAY,EACZ,eAAe,GAChB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,MAAM,IAAI,gBAAgB,EAC1B,OAAO,IAAI,iBAAiB,EAC5B,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC/E,YAAY,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AAEtC,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/E,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAGxG,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,YAAY,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAC9G,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EACL,eAAe,EACf,eAAe,EACf,aAAa,EACb,WAAW,EACX,mBAAmB,GACpB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACV,mBAAmB,EACnB,uBAAuB,EACvB,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,2BAA2B,EA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jB,2BAA2B,EAC3B,eAAe,EACf,uBAAuB,EACvB,wBAAwB,EACxB,wBAAwB,EACxB,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,oBAAoB,CAAC;AAG5B,YAAY,EACV,6BAA6B,EAC7B,qBAAqB,EACrB,oBAAoB,EACpB,wBAAwB,EACxB,gBAAgB,EAChB,8BAA8B,GAC/B,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAElC,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export type MonitoringDataFormat = 'structured' | 'prometheus';
|
|
2
|
+
export type MonitoringPeriod = 'subscription' | 'last7d' | 'last24h' | 'last1h' | 'last5m';
|
|
3
|
+
export type MonitoringAggregation = 'account' | 'project' | 'target';
|
|
4
|
+
export interface MonitoringMetricsOptions {
|
|
5
|
+
format?: MonitoringDataFormat;
|
|
6
|
+
period?: MonitoringPeriod;
|
|
7
|
+
aggregation?: MonitoringAggregation[];
|
|
8
|
+
/** Fold WEBHOOK origin events (callbacks executed by the webhook
|
|
9
|
+
* worker) into this product's totals. Defaults to false to match
|
|
10
|
+
* the dashboard's default view. */
|
|
11
|
+
includeWebhook?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface MonitoringTargetMetricsOptions {
|
|
14
|
+
domain: string;
|
|
15
|
+
groupSubdomain?: boolean;
|
|
16
|
+
period?: MonitoringPeriod;
|
|
17
|
+
start?: Date;
|
|
18
|
+
end?: Date;
|
|
19
|
+
/** Fold WEBHOOK origin events into this product's totals. */
|
|
20
|
+
includeWebhook?: boolean;
|
|
21
|
+
}
|
|
22
|
+
/** Options for the Cloud Browser monitoring endpoints. Cloud Browser
|
|
23
|
+
* is session-based (one allocation = one long-lived browser, billed
|
|
24
|
+
* by runtime + bandwidth) and exposes a distinct shape from the
|
|
25
|
+
* request-based products. There is no `domain`/`target` and no
|
|
26
|
+
* `includeWebhook`. */
|
|
27
|
+
export interface CloudBrowserMonitoringOptions {
|
|
28
|
+
period?: MonitoringPeriod;
|
|
29
|
+
/** Optional filter to a single proxy pool
|
|
30
|
+
* (e.g. `public_datacenter_pool`, `public_residential_pool`, `byop`). */
|
|
31
|
+
proxyPool?: string;
|
|
32
|
+
start?: Date;
|
|
33
|
+
end?: Date;
|
|
34
|
+
}
|
|
35
|
+
export declare function formatMonitoringDate(d: Date): string;
|
|
36
|
+
//# sourceMappingURL=monitoringconfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"monitoringconfig.d.ts","sourceRoot":"","sources":["../src/monitoringconfig.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,oBAAoB,GAAG,YAAY,GAAG,YAAY,CAAC;AAE/D,MAAM,MAAM,gBAAgB,GAAG,cAAc,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAE3F,MAAM,MAAM,qBAAqB,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,CAAC;AAErE,MAAM,WAAW,wBAAwB;IACvC,MAAM,CAAC,EAAE,oBAAoB,CAAC;IAC9B,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B,WAAW,CAAC,EAAE,qBAAqB,EAAE,CAAC;IACtC;;uCAEmC;IACnC,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,8BAA8B;IAC7C,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B,KAAK,CAAC,EAAE,IAAI,CAAC;IACb,GAAG,CAAC,EAAE,IAAI,CAAC;IACX,6DAA6D;IAC7D,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED;;;;uBAIuB;AACvB,MAAM,WAAW,6BAA6B;IAC5C,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B;8EAC0E;IAC1E,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,IAAI,CAAC;IACb,GAAG,CAAC,EAAE,IAAI,CAAC;CACZ;AAED,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,IAAI,GAAG,MAAM,CASpD"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export function formatMonitoringDate(d) {
|
|
2
|
+
const pad = (n) => n.toString().padStart(2, '0');
|
|
3
|
+
const y = d.getUTCFullYear();
|
|
4
|
+
const mo = pad(d.getUTCMonth() + 1);
|
|
5
|
+
const da = pad(d.getUTCDate());
|
|
6
|
+
const h = pad(d.getUTCHours());
|
|
7
|
+
const mi = pad(d.getUTCMinutes());
|
|
8
|
+
const s = pad(d.getUTCSeconds());
|
|
9
|
+
return `${y}-${mo}-${da} ${h}:${mi}:${s}`;
|
|
10
|
+
}
|
package/package.json
CHANGED
package/script/client.d.ts
CHANGED
|
@@ -5,8 +5,10 @@ import type { ScreenshotConfig } from './screenshotconfig.js';
|
|
|
5
5
|
import type { ExtractionConfig } from './extractionconfig.js';
|
|
6
6
|
import { BrowserConfig } from './browserconfig.js';
|
|
7
7
|
import { type AccountData, ExtractionResult, ScrapeResult, ScreenshotResult } from './result.js';
|
|
8
|
+
import type { Rec } from './types.js';
|
|
8
9
|
import type { CrawlerConfig, CrawlerContentFormat } from './crawlerconfig.js';
|
|
9
10
|
import { CrawlerArtifact, type CrawlerArtifactType, CrawlerContents, CrawlerStatus, CrawlerUrls } from './crawlerresult.js';
|
|
11
|
+
import { type CloudBrowserMonitoringOptions, type MonitoringMetricsOptions, type MonitoringTargetMetricsOptions } from './monitoringconfig.js';
|
|
10
12
|
export declare class ScrapflyClient {
|
|
11
13
|
HOST: string;
|
|
12
14
|
CLOUD_BROWSER_HOST: string;
|
|
@@ -37,6 +39,20 @@ export declare class ScrapflyClient {
|
|
|
37
39
|
* Retrieve Scrapfly account details
|
|
38
40
|
*/
|
|
39
41
|
account(): Promise<AccountData>;
|
|
42
|
+
private monitoringRequest;
|
|
43
|
+
private buildMetricsParams;
|
|
44
|
+
private buildTargetParams;
|
|
45
|
+
getMonitoringMetrics(options?: MonitoringMetricsOptions): Promise<Rec<any>>;
|
|
46
|
+
getMonitoringTargetMetrics(options: MonitoringTargetMetricsOptions): Promise<Rec<any>>;
|
|
47
|
+
getScreenshotMonitoringMetrics(options?: MonitoringMetricsOptions): Promise<Rec<any>>;
|
|
48
|
+
getScreenshotMonitoringTargetMetrics(options: MonitoringTargetMetricsOptions): Promise<Rec<any>>;
|
|
49
|
+
getExtractionMonitoringMetrics(options?: MonitoringMetricsOptions): Promise<Rec<any>>;
|
|
50
|
+
getExtractionMonitoringTargetMetrics(options: MonitoringTargetMetricsOptions): Promise<Rec<any>>;
|
|
51
|
+
getCrawlerMonitoringMetrics(options?: MonitoringMetricsOptions): Promise<Rec<any>>;
|
|
52
|
+
getCrawlerMonitoringTargetMetrics(options: MonitoringTargetMetricsOptions): Promise<Rec<any>>;
|
|
53
|
+
getBrowserMonitoringMetrics(options?: CloudBrowserMonitoringOptions): Promise<Rec<any>>;
|
|
54
|
+
getBrowserMonitoringTimeseries(options?: CloudBrowserMonitoringOptions): Promise<Rec<any>>;
|
|
55
|
+
private buildBrowserParams;
|
|
40
56
|
/**
|
|
41
57
|
* Issue a single scrape command from a given scrape configuration
|
|
42
58
|
*/
|
package/script/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AA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AAE,OAAO,CAAA;KAAE,CAAC;IAoB/H;;;OAGG;IACG,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,WAAW,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;IAkBxF;;OAEG;IACG,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAgBvE;;OAEG;IACG,oBAAoB,IAAI,OAAO,CAAC;QAAE,QAAQ,EAAE,GAAG,EAAE,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;CAe1E"}
|
package/script/client.js
CHANGED
|
@@ -32,6 +32,7 @@ const browserconfig_js_1 = require("./browserconfig.js");
|
|
|
32
32
|
const result_js_1 = require("./result.js");
|
|
33
33
|
const logger_js_1 = require("./logger.js");
|
|
34
34
|
const crawlerresult_js_1 = require("./crawlerresult.js");
|
|
35
|
+
const monitoringconfig_js_1 = require("./monitoringconfig.js");
|
|
35
36
|
class ScrapflyClient {
|
|
36
37
|
constructor(options) {
|
|
37
38
|
Object.defineProperty(this, "HOST", {
|
|
@@ -255,6 +256,121 @@ class ScrapflyClient {
|
|
|
255
256
|
}
|
|
256
257
|
return data;
|
|
257
258
|
}
|
|
259
|
+
// ── Monitoring API (Enterprise+ plan only) ──────────────────────
|
|
260
|
+
// The Monitoring API exposes per-product aggregates and per-target
|
|
261
|
+
// timeseries. Web Scraping / Screenshot / Extraction / Crawler share
|
|
262
|
+
// one shape (request-based) but live under different URL prefixes;
|
|
263
|
+
// Cloud Browser is session-based and exposes a distinct shape.
|
|
264
|
+
// See https://scrapfly.io/docs/monitoring#api
|
|
265
|
+
async monitoringRequest(path, params) {
|
|
266
|
+
const url = new URL(this.HOST + path);
|
|
267
|
+
url.search = new URLSearchParams(params).toString();
|
|
268
|
+
const response = await this.fetch({
|
|
269
|
+
url: url.toString(),
|
|
270
|
+
method: 'GET',
|
|
271
|
+
headers: {
|
|
272
|
+
'user-agent': this.ua,
|
|
273
|
+
'accept-encoding': 'gzip, deflate, br',
|
|
274
|
+
accept: 'application/json',
|
|
275
|
+
},
|
|
276
|
+
});
|
|
277
|
+
const data = (await response.json());
|
|
278
|
+
if ('error_id' in data) {
|
|
279
|
+
if (data.http_code == 401 || response.status == 401) {
|
|
280
|
+
throw new errors.BadApiKeyError(JSON.stringify(data));
|
|
281
|
+
}
|
|
282
|
+
throw new errors.ApiHttpClientError(JSON.stringify(data));
|
|
283
|
+
}
|
|
284
|
+
return data;
|
|
285
|
+
}
|
|
286
|
+
buildMetricsParams(options) {
|
|
287
|
+
const params = {
|
|
288
|
+
key: this.key,
|
|
289
|
+
format: options.format ?? 'structured',
|
|
290
|
+
};
|
|
291
|
+
if (options.period !== undefined)
|
|
292
|
+
params.period = options.period;
|
|
293
|
+
if (options.aggregation !== undefined && options.aggregation.length > 0) {
|
|
294
|
+
params.aggregation = options.aggregation.join(',');
|
|
295
|
+
}
|
|
296
|
+
if (options.includeWebhook)
|
|
297
|
+
params.include_webhook = 'true';
|
|
298
|
+
return params;
|
|
299
|
+
}
|
|
300
|
+
buildTargetParams(options) {
|
|
301
|
+
if ((options.start && !options.end) || (!options.start && options.end)) {
|
|
302
|
+
throw new Error('You must provide both start and end date');
|
|
303
|
+
}
|
|
304
|
+
const params = {
|
|
305
|
+
key: this.key,
|
|
306
|
+
domain: options.domain,
|
|
307
|
+
group_subdomain: String(options.groupSubdomain ?? false),
|
|
308
|
+
};
|
|
309
|
+
if (options.start && options.end) {
|
|
310
|
+
params.start = (0, monitoringconfig_js_1.formatMonitoringDate)(options.start);
|
|
311
|
+
params.end = (0, monitoringconfig_js_1.formatMonitoringDate)(options.end);
|
|
312
|
+
}
|
|
313
|
+
else if (options.period !== undefined) {
|
|
314
|
+
params.period = options.period;
|
|
315
|
+
}
|
|
316
|
+
else {
|
|
317
|
+
params.period = 'last24h';
|
|
318
|
+
}
|
|
319
|
+
if (options.includeWebhook)
|
|
320
|
+
params.include_webhook = 'true';
|
|
321
|
+
return params;
|
|
322
|
+
}
|
|
323
|
+
// ── Web Scraping API (existing — kept for backward compat) ──────
|
|
324
|
+
async getMonitoringMetrics(options = {}) {
|
|
325
|
+
return this.monitoringRequest('/scrape/monitoring/metrics', this.buildMetricsParams(options));
|
|
326
|
+
}
|
|
327
|
+
async getMonitoringTargetMetrics(options) {
|
|
328
|
+
return this.monitoringRequest('/scrape/monitoring/metrics/target', this.buildTargetParams(options));
|
|
329
|
+
}
|
|
330
|
+
// ── Screenshot API ───────────────────────────────────────────────
|
|
331
|
+
async getScreenshotMonitoringMetrics(options = {}) {
|
|
332
|
+
return this.monitoringRequest('/screenshot/monitoring/metrics', this.buildMetricsParams(options));
|
|
333
|
+
}
|
|
334
|
+
async getScreenshotMonitoringTargetMetrics(options) {
|
|
335
|
+
return this.monitoringRequest('/screenshot/monitoring/metrics/target', this.buildTargetParams(options));
|
|
336
|
+
}
|
|
337
|
+
// ── Extraction API ───────────────────────────────────────────────
|
|
338
|
+
async getExtractionMonitoringMetrics(options = {}) {
|
|
339
|
+
return this.monitoringRequest('/extraction/monitoring/metrics', this.buildMetricsParams(options));
|
|
340
|
+
}
|
|
341
|
+
async getExtractionMonitoringTargetMetrics(options) {
|
|
342
|
+
return this.monitoringRequest('/extraction/monitoring/metrics/target', this.buildTargetParams(options));
|
|
343
|
+
}
|
|
344
|
+
// ── Crawler API ──────────────────────────────────────────────────
|
|
345
|
+
async getCrawlerMonitoringMetrics(options = {}) {
|
|
346
|
+
return this.monitoringRequest('/crawl/monitoring/metrics', this.buildMetricsParams(options));
|
|
347
|
+
}
|
|
348
|
+
async getCrawlerMonitoringTargetMetrics(options) {
|
|
349
|
+
return this.monitoringRequest('/crawl/monitoring/metrics/target', this.buildTargetParams(options));
|
|
350
|
+
}
|
|
351
|
+
// ── Cloud Browser API (session-based, distinct shape) ────────────
|
|
352
|
+
async getBrowserMonitoringMetrics(options = {}) {
|
|
353
|
+
return this.monitoringRequest('/browser/monitoring/metrics', this.buildBrowserParams(options));
|
|
354
|
+
}
|
|
355
|
+
async getBrowserMonitoringTimeseries(options = {}) {
|
|
356
|
+
return this.monitoringRequest('/browser/monitoring/metrics/timeseries', this.buildBrowserParams(options));
|
|
357
|
+
}
|
|
358
|
+
buildBrowserParams(options) {
|
|
359
|
+
if ((options.start && !options.end) || (!options.start && options.end)) {
|
|
360
|
+
throw new Error('You must provide both start and end date');
|
|
361
|
+
}
|
|
362
|
+
const params = { key: this.key };
|
|
363
|
+
if (options.start && options.end) {
|
|
364
|
+
params.start = (0, monitoringconfig_js_1.formatMonitoringDate)(options.start);
|
|
365
|
+
params.end = (0, monitoringconfig_js_1.formatMonitoringDate)(options.end);
|
|
366
|
+
}
|
|
367
|
+
else if (options.period !== undefined) {
|
|
368
|
+
params.period = options.period;
|
|
369
|
+
}
|
|
370
|
+
if (options.proxyPool !== undefined)
|
|
371
|
+
params.proxy_pool = options.proxyPool;
|
|
372
|
+
return params;
|
|
373
|
+
}
|
|
258
374
|
/**
|
|
259
375
|
* Issue a single scrape command from a given scrape configuration
|
|
260
376
|
*/
|
package/script/main.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export type { CrawlerConfigOptions, CrawlerContentFormat, CrawlerWebhookEventNam
|
|
|
12
12
|
export { Crawl } from './crawl.js';
|
|
13
13
|
export { CrawlerArtifact, CrawlerContents, CrawlerStatus, CrawlerUrls, parseCrawlerWebhook, } from './crawlerresult.js';
|
|
14
14
|
export type { CrawlerArtifactType, CrawlerLifecycleWebhook, CrawlerState, CrawlerStatusValue, CrawlerStopReason, CrawlerUrlDiscoveredWebhook, CrawlerUrlEntry, CrawlerUrlFailedWebhook, CrawlerUrlSkippedWebhook, CrawlerUrlVisitedWebhook, CrawlerWebhookCommon, CrawlerWebhookPayload, } from './crawlerresult.js';
|
|
15
|
+
export type { CloudBrowserMonitoringOptions, MonitoringAggregation, MonitoringDataFormat, MonitoringMetricsOptions, MonitoringPeriod, MonitoringTargetMetricsOptions, } from './monitoringconfig.js';
|
|
15
16
|
export { log } from './logger.js';
|
|
16
17
|
export { createServer, verifySignature } from './webhookserver.js';
|
|
17
18
|
//# sourceMappingURL=main.d.ts.map
|
package/script/main.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EACL,MAAM,IAAI,YAAY,EACtB,YAAY,IAAI,mBAAmB,EACnC,YAAY,EACZ,eAAe,GAChB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,MAAM,IAAI,gBAAgB,EAC1B,OAAO,IAAI,iBAAiB,EAC5B,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC/E,YAAY,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AAEtC,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/E,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAGxG,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,YAAY,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAC9G,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EACL,eAAe,EACf,eAAe,EACf,aAAa,EACb,WAAW,EACX,mBAAmB,GACpB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,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;AAC5B,YAAY,EACV,mBAAmB,EACnB,uBAAuB,EACvB,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,2BAA2B,EAC3B,eAAe,EACf,uBAAuB,EACvB,wBAAwB,EACxB,wBAAwB,EACxB,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,oBAAoB,CAAC;AAG5B,YAAY,EACV,6BAA6B,EAC7B,qBAAqB,EACrB,oBAAoB,EACpB,wBAAwB,EACxB,gBAAgB,EAChB,8BAA8B,GAC/B,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAElC,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export type MonitoringDataFormat = 'structured' | 'prometheus';
|
|
2
|
+
export type MonitoringPeriod = 'subscription' | 'last7d' | 'last24h' | 'last1h' | 'last5m';
|
|
3
|
+
export type MonitoringAggregation = 'account' | 'project' | 'target';
|
|
4
|
+
export interface MonitoringMetricsOptions {
|
|
5
|
+
format?: MonitoringDataFormat;
|
|
6
|
+
period?: MonitoringPeriod;
|
|
7
|
+
aggregation?: MonitoringAggregation[];
|
|
8
|
+
/** Fold WEBHOOK origin events (callbacks executed by the webhook
|
|
9
|
+
* worker) into this product's totals. Defaults to false to match
|
|
10
|
+
* the dashboard's default view. */
|
|
11
|
+
includeWebhook?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface MonitoringTargetMetricsOptions {
|
|
14
|
+
domain: string;
|
|
15
|
+
groupSubdomain?: boolean;
|
|
16
|
+
period?: MonitoringPeriod;
|
|
17
|
+
start?: Date;
|
|
18
|
+
end?: Date;
|
|
19
|
+
/** Fold WEBHOOK origin events into this product's totals. */
|
|
20
|
+
includeWebhook?: boolean;
|
|
21
|
+
}
|
|
22
|
+
/** Options for the Cloud Browser monitoring endpoints. Cloud Browser
|
|
23
|
+
* is session-based (one allocation = one long-lived browser, billed
|
|
24
|
+
* by runtime + bandwidth) and exposes a distinct shape from the
|
|
25
|
+
* request-based products. There is no `domain`/`target` and no
|
|
26
|
+
* `includeWebhook`. */
|
|
27
|
+
export interface CloudBrowserMonitoringOptions {
|
|
28
|
+
period?: MonitoringPeriod;
|
|
29
|
+
/** Optional filter to a single proxy pool
|
|
30
|
+
* (e.g. `public_datacenter_pool`, `public_residential_pool`, `byop`). */
|
|
31
|
+
proxyPool?: string;
|
|
32
|
+
start?: Date;
|
|
33
|
+
end?: Date;
|
|
34
|
+
}
|
|
35
|
+
export declare function formatMonitoringDate(d: Date): string;
|
|
36
|
+
//# sourceMappingURL=monitoringconfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"monitoringconfig.d.ts","sourceRoot":"","sources":["../src/monitoringconfig.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,oBAAoB,GAAG,YAAY,GAAG,YAAY,CAAC;AAE/D,MAAM,MAAM,gBAAgB,GAAG,cAAc,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAE3F,MAAM,MAAM,qBAAqB,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,CAAC;AAErE,MAAM,WAAW,wBAAwB;IACvC,MAAM,CAAC,EAAE,oBAAoB,CAAC;IAC9B,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B,WAAW,CAAC,EAAE,qBAAqB,EAAE,CAAC;IACtC;;uCAEmC;IACnC,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,8BAA8B;IAC7C,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B,KAAK,CAAC,EAAE,IAAI,CAAC;IACb,GAAG,CAAC,EAAE,IAAI,CAAC;IACX,6DAA6D;IAC7D,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED;;;;uBAIuB;AACvB,MAAM,WAAW,6BAA6B;IAC5C,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B;8EAC0E;IAC1E,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,IAAI,CAAC;IACb,GAAG,CAAC,EAAE,IAAI,CAAC;CACZ;AAED,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,IAAI,GAAG,MAAM,CASpD"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatMonitoringDate = formatMonitoringDate;
|
|
4
|
+
function formatMonitoringDate(d) {
|
|
5
|
+
const pad = (n) => n.toString().padStart(2, '0');
|
|
6
|
+
const y = d.getUTCFullYear();
|
|
7
|
+
const mo = pad(d.getUTCMonth() + 1);
|
|
8
|
+
const da = pad(d.getUTCDate());
|
|
9
|
+
const h = pad(d.getUTCHours());
|
|
10
|
+
const mi = pad(d.getUTCMinutes());
|
|
11
|
+
const s = pad(d.getUTCSeconds());
|
|
12
|
+
return `${y}-${mo}-${da} ${h}:${mi}:${s}`;
|
|
13
|
+
}
|