@getanyapi/sdk 0.22.0 → 0.24.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 +13 -7
- package/dist/index.cjs +272 -128
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +635 -39
- package/dist/index.d.ts +635 -39
- package/dist/index.js +271 -128
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -79,6 +79,12 @@ billing. This handwritten discovery client safety-scans the response, projects k
|
|
|
79
79
|
preserves schemas as opaque JSON, and ignores safe additions. It does not recompute gateway
|
|
80
80
|
business rules. Generated per-SKU methods remain a separate OpenAPI-driven surface.
|
|
81
81
|
|
|
82
|
+
Every catalog and search result carries the gateway-authored `method`, `path`, and execution
|
|
83
|
+
mode. Lanes carry their public source identity and complete health sample counts when health is
|
|
84
|
+
available. Eligible APIs may carry `tryMaxItems`; ranked search carries the gateway's failover
|
|
85
|
+
facts. `describe` also returns `latency`, either the complete trailing-window p50/p95/p99
|
|
86
|
+
distribution or `null` when no sample is available.
|
|
87
|
+
|
|
82
88
|
## Pagination
|
|
83
89
|
|
|
84
90
|
Paginated SKUs expose an iterator that yields items across pages and follows the cursor for
|
|
@@ -162,13 +168,13 @@ No other `409` retries: `idempotency_conflict` (the same key with different inpu
|
|
|
162
168
|
Automatic network retry of a billed `run()` requires structured runtime evidence that the
|
|
163
169
|
request body was not sent:
|
|
164
170
|
|
|
165
|
-
| Runtime
|
|
166
|
-
|
|
|
167
|
-
| Node 18+ with built-in undici `fetch` | Yes
|
|
168
|
-
| Bun 1.3.11
|
|
169
|
-
| Cloudflare Workers
|
|
170
|
-
| Deno
|
|
171
|
-
| Browsers
|
|
171
|
+
| Runtime | Automatic billed-run network retry | Evidence available to the SDK |
|
|
172
|
+
| ------------------------------------- | ---------------------------------- | --------------------------------------------------------------------------------------------------------- |
|
|
173
|
+
| Node 18+ with built-in undici `fetch` | Yes | DNS and connect codes, connect-phase timeouts, or an undici socket reporting zero bytes written |
|
|
174
|
+
| Bun 1.3.11 | Yes | `ConnectionRefused`, which Bun 1.3.11 emits only while establishing the origin or proxy connection |
|
|
175
|
+
| Cloudflare Workers | No | `retryable: true` means transient, not undelivered; it can appear after the origin received the full body |
|
|
176
|
+
| Deno | No | Fetch exposes only prose without a structured connection code |
|
|
177
|
+
| Browsers | No | Fetch generally exposes an opaque `TypeError` |
|
|
172
178
|
|
|
173
179
|
On a runtime without strict non-delivery evidence, the SDK makes no automatic network retry for a
|
|
174
180
|
billed `run()`. HTTP 429 retry is unchanged. Handle other retries explicitly only when your
|
package/dist/index.cjs
CHANGED
|
@@ -60,6 +60,7 @@ __export(index_exports, {
|
|
|
60
60
|
LinkedinNamespace: () => LinkedinNamespace,
|
|
61
61
|
MapsNamespace: () => MapsNamespace,
|
|
62
62
|
MobilePhoneNamespace: () => MobilePhoneNamespace,
|
|
63
|
+
NaverNamespace: () => NaverNamespace,
|
|
63
64
|
NotFoundError: () => NotFoundError,
|
|
64
65
|
PandaexpressNamespace: () => PandaexpressNamespace,
|
|
65
66
|
PeopleSearchNamespace: () => PeopleSearchNamespace,
|
|
@@ -232,23 +233,92 @@ function pageIdempotencyKey(key, pageNumber) {
|
|
|
232
233
|
|
|
233
234
|
// src/core/account.ts
|
|
234
235
|
var DEFAULT_BASE_URL = "https://api.getanyapi.com";
|
|
236
|
+
function mapProfile(raw) {
|
|
237
|
+
const profile = {
|
|
238
|
+
id: raw.id,
|
|
239
|
+
status: raw.status,
|
|
240
|
+
createdAt: raw.createdAt,
|
|
241
|
+
onboardingComplete: raw.onboardingComplete
|
|
242
|
+
};
|
|
243
|
+
if (raw.email !== void 0 && raw.email !== null) {
|
|
244
|
+
profile.email = raw.email;
|
|
245
|
+
}
|
|
246
|
+
return profile;
|
|
247
|
+
}
|
|
248
|
+
async function agentSignup(options = {}) {
|
|
249
|
+
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
250
|
+
if (typeof fetchImpl !== "function") {
|
|
251
|
+
throw new AnyAPIError(
|
|
252
|
+
"no fetch implementation available: pass options.fetch or run on a runtime with global fetch",
|
|
253
|
+
0
|
|
254
|
+
);
|
|
255
|
+
}
|
|
256
|
+
const base = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, "");
|
|
257
|
+
const body = {};
|
|
258
|
+
if (options.sponsorEmail !== void 0) {
|
|
259
|
+
body["sponsorEmail"] = options.sponsorEmail;
|
|
260
|
+
}
|
|
261
|
+
if (options.label !== void 0) {
|
|
262
|
+
body["label"] = options.label;
|
|
263
|
+
}
|
|
264
|
+
let response;
|
|
265
|
+
try {
|
|
266
|
+
response = await fetchImpl(`${base}/agent/signup`, {
|
|
267
|
+
method: "POST",
|
|
268
|
+
headers: {
|
|
269
|
+
"Content-Type": "application/json",
|
|
270
|
+
Accept: "application/json"
|
|
271
|
+
},
|
|
272
|
+
body: JSON.stringify(body)
|
|
273
|
+
});
|
|
274
|
+
} catch (err) {
|
|
275
|
+
throw new ConnectionError(
|
|
276
|
+
err instanceof Error ? err.message : "connection failed",
|
|
277
|
+
0
|
|
278
|
+
);
|
|
279
|
+
}
|
|
280
|
+
const requestId = requestIdOf(response.headers);
|
|
281
|
+
const text = await response.text().catch(() => "");
|
|
282
|
+
if (response.status !== 200) {
|
|
283
|
+
let message = `request failed with status ${response.status}`;
|
|
284
|
+
let code;
|
|
285
|
+
try {
|
|
286
|
+
const parsed2 = JSON.parse(text);
|
|
287
|
+
if (typeof parsed2.error === "string" && parsed2.error !== "") {
|
|
288
|
+
message = parsed2.error;
|
|
289
|
+
}
|
|
290
|
+
if (typeof parsed2.code === "string" && parsed2.code !== "") {
|
|
291
|
+
code = parsed2.code;
|
|
292
|
+
}
|
|
293
|
+
} catch {
|
|
294
|
+
}
|
|
295
|
+
throw errorFromStatus(response.status, message, requestId, code);
|
|
296
|
+
}
|
|
297
|
+
const parsed = JSON.parse(text);
|
|
298
|
+
return {
|
|
299
|
+
secret: parsed.secret,
|
|
300
|
+
capUsd: parsed.capUsd,
|
|
301
|
+
claimToken: parsed.claimToken,
|
|
302
|
+
claimUrl: parsed.claimUrl
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
// src/core/discovery-validation.ts
|
|
235
307
|
function malformed(path) {
|
|
236
308
|
throw new AnyAPIError(`malformed discovery response: ${path}`, 0);
|
|
237
309
|
}
|
|
238
|
-
function
|
|
310
|
+
function rejectUnsafeFields(value, path) {
|
|
239
311
|
if (Array.isArray(value)) {
|
|
240
312
|
value.forEach(
|
|
241
|
-
(item, index) =>
|
|
313
|
+
(item, index) => rejectUnsafeFields(item, `${path}[${index}]`)
|
|
242
314
|
);
|
|
243
315
|
return;
|
|
244
316
|
}
|
|
245
317
|
if (typeof value !== "object" || value === null) return;
|
|
246
318
|
for (const [key, item] of Object.entries(value)) {
|
|
247
319
|
if (key.toLowerCase().includes("credit")) malformed(`${path}.${key}`);
|
|
248
|
-
if (key === "provider" && item !== "AnyAPI") {
|
|
249
|
-
|
|
250
|
-
}
|
|
251
|
-
rejectUnsafeDiscoveryFields(item, `${path}.${key}`);
|
|
320
|
+
if (key === "provider" && item !== "AnyAPI") malformed(`${path}.${key}`);
|
|
321
|
+
rejectUnsafeFields(item, `${path}.${key}`);
|
|
252
322
|
}
|
|
253
323
|
}
|
|
254
324
|
function record(value, path) {
|
|
@@ -259,8 +329,7 @@ function record(value, path) {
|
|
|
259
329
|
}
|
|
260
330
|
function stringField(raw, key, path) {
|
|
261
331
|
const value = raw[key];
|
|
262
|
-
|
|
263
|
-
return value;
|
|
332
|
+
return typeof value === "string" ? value : malformed(`${path}.${key}`);
|
|
264
333
|
}
|
|
265
334
|
function numberField(raw, key, path) {
|
|
266
335
|
const value = raw[key];
|
|
@@ -271,7 +340,16 @@ function numberField(raw, key, path) {
|
|
|
271
340
|
}
|
|
272
341
|
function integerField(raw, key, path) {
|
|
273
342
|
const value = numberField(raw, key, path);
|
|
274
|
-
|
|
343
|
+
return Number.isInteger(value) ? value : malformed(`${path}.${key}`);
|
|
344
|
+
}
|
|
345
|
+
function methodField(raw, key, path) {
|
|
346
|
+
return stringField(raw, key, path) === "POST" ? "POST" : malformed(`${path}.${key}`);
|
|
347
|
+
}
|
|
348
|
+
function pathField(raw, key, path) {
|
|
349
|
+
const value = stringField(raw, key, path);
|
|
350
|
+
if (value.length < 2 || !value.startsWith("/") || value.startsWith("//")) {
|
|
351
|
+
return malformed(`${path}.${key}`);
|
|
352
|
+
}
|
|
275
353
|
return value;
|
|
276
354
|
}
|
|
277
355
|
function boundedNumberField(raw, key, path, minimumExclusive, maximumInclusive) {
|
|
@@ -287,22 +365,17 @@ function parseOffer(value, path) {
|
|
|
287
365
|
const unit = stringField(raw, "unit", path);
|
|
288
366
|
const maxUsd = numberField(raw, "maxUsd", path);
|
|
289
367
|
if (model === "flat") {
|
|
290
|
-
|
|
291
|
-
return malformed(path);
|
|
292
|
-
}
|
|
293
|
-
return { model, unit, maxUsd };
|
|
294
|
-
}
|
|
295
|
-
if (model === "linear") {
|
|
296
|
-
if (unit.length === 0) return malformed(`${path}.unit`);
|
|
297
|
-
return {
|
|
298
|
-
model,
|
|
299
|
-
unit,
|
|
300
|
-
baseUsd: numberField(raw, "baseUsd", path),
|
|
301
|
-
perUnitUsd: numberField(raw, "perUnitUsd", path),
|
|
302
|
-
maxUsd
|
|
303
|
-
};
|
|
368
|
+
return unit === "request" ? { model, unit, maxUsd } : malformed(path);
|
|
304
369
|
}
|
|
305
|
-
return malformed(`${path}.model`);
|
|
370
|
+
if (model !== "linear") return malformed(`${path}.model`);
|
|
371
|
+
if (unit.length === 0) return malformed(`${path}.unit`);
|
|
372
|
+
return {
|
|
373
|
+
model,
|
|
374
|
+
unit,
|
|
375
|
+
baseUsd: numberField(raw, "baseUsd", path),
|
|
376
|
+
perUnitUsd: numberField(raw, "perUnitUsd", path),
|
|
377
|
+
maxUsd
|
|
378
|
+
};
|
|
306
379
|
}
|
|
307
380
|
function parsePricing(value, path) {
|
|
308
381
|
const raw = record(value, path);
|
|
@@ -311,31 +384,64 @@ function parsePricing(value, path) {
|
|
|
311
384
|
failoverMaxUsd: numberField(raw, "failoverMaxUsd", path)
|
|
312
385
|
};
|
|
313
386
|
}
|
|
387
|
+
function parseExecution(value, path) {
|
|
388
|
+
const raw = record(value, path);
|
|
389
|
+
const mode = stringField(raw, "mode", path);
|
|
390
|
+
return mode === "sync" || mode === "durable" ? { mode } : malformed(`${path}.mode`);
|
|
391
|
+
}
|
|
392
|
+
function parseSource(value, path) {
|
|
393
|
+
const raw = record(value, path);
|
|
394
|
+
const kind = stringField(raw, "kind", path);
|
|
395
|
+
if (kind !== "anonymous" && kind !== "brand")
|
|
396
|
+
return malformed(`${path}.kind`);
|
|
397
|
+
return {
|
|
398
|
+
id: stringField(raw, "id", path),
|
|
399
|
+
name: stringField(raw, "name", path),
|
|
400
|
+
kind,
|
|
401
|
+
artworkKey: stringField(raw, "artworkKey", path)
|
|
402
|
+
};
|
|
403
|
+
}
|
|
314
404
|
function parseHealth(value, path) {
|
|
315
405
|
const raw = record(value, path);
|
|
316
406
|
return {
|
|
317
407
|
window: stringField(raw, "window", path),
|
|
318
408
|
uptimePct: boundedNumberField(raw, "uptimePct", path, void 0, 100),
|
|
319
409
|
latencyP50Ms: integerField(raw, "latencyP50Ms", path),
|
|
320
|
-
|
|
410
|
+
uptimeSample: integerField(raw, "uptimeSample", path),
|
|
411
|
+
latencySample: integerField(raw, "latencySample", path),
|
|
412
|
+
requests: integerField(raw, "requests", path),
|
|
413
|
+
servedRequests: integerField(raw, "servedRequests", path)
|
|
321
414
|
};
|
|
322
415
|
}
|
|
323
416
|
function parseLane(value, path) {
|
|
324
417
|
const raw = record(value, path);
|
|
325
418
|
const lane = {
|
|
326
|
-
pricing: parseOffer(raw["pricing"], `${path}.pricing`)
|
|
419
|
+
pricing: parseOffer(raw["pricing"], `${path}.pricing`),
|
|
420
|
+
source: parseSource(raw["source"], `${path}.source`)
|
|
327
421
|
};
|
|
328
|
-
if (raw["health"] !== void 0)
|
|
422
|
+
if (raw["health"] !== void 0)
|
|
329
423
|
lane.health = parseHealth(raw["health"], `${path}.health`);
|
|
330
|
-
}
|
|
331
424
|
return lane;
|
|
332
425
|
}
|
|
333
|
-
function
|
|
334
|
-
|
|
335
|
-
|
|
426
|
+
function parseLatency(value, path) {
|
|
427
|
+
const raw = record(value, path);
|
|
428
|
+
const basis = stringField(raw, "basis", path);
|
|
429
|
+
if (basis !== "service_time_excludes_caller_requested_delay") {
|
|
430
|
+
return malformed(`${path}.basis`);
|
|
431
|
+
}
|
|
432
|
+
const sample = integerField(raw, "sample", path);
|
|
433
|
+
if (sample < 1) return malformed(`${path}.sample`);
|
|
434
|
+
return {
|
|
435
|
+
window: stringField(raw, "window", path),
|
|
436
|
+
p50Ms: integerField(raw, "p50Ms", path),
|
|
437
|
+
p95Ms: integerField(raw, "p95Ms", path),
|
|
438
|
+
p99Ms: integerField(raw, "p99Ms", path),
|
|
439
|
+
sample,
|
|
440
|
+
basis
|
|
441
|
+
};
|
|
336
442
|
}
|
|
337
|
-
function
|
|
338
|
-
return
|
|
443
|
+
function parseProvider(raw, path) {
|
|
444
|
+
return raw["provider"] === "AnyAPI" ? "AnyAPI" : malformed(`${path}.provider`);
|
|
339
445
|
}
|
|
340
446
|
function parseHighlight(value, path) {
|
|
341
447
|
const raw = record(value, path);
|
|
@@ -346,31 +452,22 @@ function parseHighlight(value, path) {
|
|
|
346
452
|
if (raw["why"] !== void 0) field.why = stringField(raw, "why", path);
|
|
347
453
|
return field;
|
|
348
454
|
}
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
id: raw.id,
|
|
352
|
-
status: raw.status,
|
|
353
|
-
createdAt: raw.createdAt,
|
|
354
|
-
onboardingComplete: raw.onboardingComplete
|
|
355
|
-
};
|
|
356
|
-
if (raw.email !== void 0 && raw.email !== null) {
|
|
357
|
-
profile.email = raw.email;
|
|
358
|
-
}
|
|
359
|
-
return profile;
|
|
360
|
-
}
|
|
455
|
+
|
|
456
|
+
// src/core/discovery.ts
|
|
361
457
|
function mapCatalogEntry(raw) {
|
|
362
|
-
|
|
458
|
+
rejectUnsafeFields(raw, "api");
|
|
363
459
|
const value = record(raw, "api");
|
|
364
460
|
const lanesRaw = value["lanes"];
|
|
365
|
-
if (!Array.isArray(lanesRaw))
|
|
366
|
-
return malformed("api.lanes");
|
|
367
|
-
}
|
|
461
|
+
if (!Array.isArray(lanesRaw)) return malformed("api.lanes");
|
|
368
462
|
const entry = {
|
|
369
463
|
id: stringField(value, "id", "api"),
|
|
370
464
|
slug: stringField(value, "slug", "api"),
|
|
371
465
|
category: stringField(value, "category", "api"),
|
|
372
466
|
name: stringField(value, "name", "api"),
|
|
373
467
|
description: stringField(value, "description", "api"),
|
|
468
|
+
method: methodField(value, "method", "api"),
|
|
469
|
+
path: pathField(value, "path", "api"),
|
|
470
|
+
execution: parseExecution(value["execution"], "api.execution"),
|
|
374
471
|
provider: parseProvider(value, "api"),
|
|
375
472
|
pricing: parsePricing(value["pricing"], "api.pricing"),
|
|
376
473
|
lanes: lanesRaw.map(
|
|
@@ -379,37 +476,42 @@ function mapCatalogEntry(raw) {
|
|
|
379
476
|
heavy: value["heavy"] === void 0 ? false : value["heavy"] === true,
|
|
380
477
|
tryEligible: value["tryEligible"] === true
|
|
381
478
|
};
|
|
382
|
-
if (value["heavy"] !== void 0 && typeof value["heavy"] !== "boolean")
|
|
383
|
-
|
|
479
|
+
if (value["heavy"] !== void 0 && typeof value["heavy"] !== "boolean")
|
|
480
|
+
malformed("api.heavy");
|
|
481
|
+
if (typeof value["tryEligible"] !== "boolean") malformed("api.tryEligible");
|
|
482
|
+
if (value["tryMaxItems"] !== void 0) {
|
|
483
|
+
const tryMaxItems = integerField(value, "tryMaxItems", "api");
|
|
484
|
+
if (tryMaxItems < 1) malformed("api.tryMaxItems");
|
|
485
|
+
entry.tryMaxItems = tryMaxItems;
|
|
384
486
|
}
|
|
385
|
-
if (typeof value["tryEligible"] !== "boolean")
|
|
386
|
-
return malformed("api.tryEligible");
|
|
387
487
|
if (value["failover"] !== void 0) {
|
|
388
|
-
if (typeof value["failover"] !== "boolean")
|
|
389
|
-
return malformed("api.failover");
|
|
488
|
+
if (typeof value["failover"] !== "boolean") malformed("api.failover");
|
|
390
489
|
entry.failover = value["failover"];
|
|
391
490
|
}
|
|
392
491
|
if (value["excludesCallerDelay"] !== void 0) {
|
|
393
492
|
if (typeof value["excludesCallerDelay"] !== "boolean")
|
|
394
|
-
|
|
493
|
+
malformed("api.excludesCallerDelay");
|
|
395
494
|
entry.excludesCallerDelay = value["excludesCallerDelay"];
|
|
396
495
|
}
|
|
397
|
-
if (value["inputSchema"] !== void 0)
|
|
398
|
-
entry.inputSchema =
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
496
|
+
if (value["inputSchema"] !== void 0)
|
|
497
|
+
entry.inputSchema = record(value["inputSchema"], "api.inputSchema");
|
|
498
|
+
if (value["outputSchema"] !== void 0)
|
|
499
|
+
entry.outputSchema = record(value["outputSchema"], "api.outputSchema");
|
|
500
|
+
if (value["latency"] !== void 0) {
|
|
501
|
+
entry.latency = value["latency"] === null ? null : parseLatency(value["latency"], "api.latency");
|
|
402
502
|
}
|
|
403
503
|
return entry;
|
|
404
504
|
}
|
|
405
505
|
function mapCatalogDetail(raw) {
|
|
406
506
|
const entry = mapCatalogEntry(raw);
|
|
507
|
+
const value = record(raw, "api");
|
|
407
508
|
if (entry.inputSchema === void 0) return malformed("api.inputSchema");
|
|
408
509
|
if (entry.outputSchema === void 0) return malformed("api.outputSchema");
|
|
510
|
+
if (!("latency" in value)) return malformed("api.latency");
|
|
409
511
|
return entry;
|
|
410
512
|
}
|
|
411
513
|
function mapCatalogList(raw) {
|
|
412
|
-
|
|
514
|
+
rejectUnsafeFields(raw, "catalog");
|
|
413
515
|
const envelope = record(raw, "catalog");
|
|
414
516
|
if (!Array.isArray(envelope["apis"])) return malformed("catalog.apis");
|
|
415
517
|
return envelope["apis"].map(mapCatalogEntry);
|
|
@@ -422,13 +524,27 @@ function mapSearchResult(value, path) {
|
|
|
422
524
|
name: stringField(raw, "name", path),
|
|
423
525
|
description: stringField(raw, "description", path),
|
|
424
526
|
category: stringField(raw, "category", path),
|
|
527
|
+
method: methodField(raw, "method", path),
|
|
528
|
+
path: pathField(raw, "path", path),
|
|
529
|
+
execution: parseExecution(raw["execution"], `${path}.execution`),
|
|
425
530
|
provider: parseProvider(raw, path),
|
|
426
531
|
pricing: parsePricing(raw["pricing"], `${path}.pricing`),
|
|
532
|
+
failover: typeof raw["failover"] === "boolean" ? raw["failover"] : malformed(`${path}.failover`),
|
|
427
533
|
relevance: boundedNumberField(raw, "relevance", path, 0, 1)
|
|
428
534
|
};
|
|
535
|
+
if (raw["tryMaxItems"] !== void 0) {
|
|
536
|
+
const tryMaxItems = integerField(raw, "tryMaxItems", path);
|
|
537
|
+
if (tryMaxItems < 1) malformed(`${path}.tryMaxItems`);
|
|
538
|
+
result.tryMaxItems = tryMaxItems;
|
|
539
|
+
}
|
|
540
|
+
if (raw["excludesCallerDelay"] !== void 0) {
|
|
541
|
+
if (typeof raw["excludesCallerDelay"] !== "boolean")
|
|
542
|
+
malformed(`${path}.excludesCallerDelay`);
|
|
543
|
+
result.excludesCallerDelay = raw["excludesCallerDelay"];
|
|
544
|
+
}
|
|
429
545
|
if (raw["highlightFields"] !== void 0) {
|
|
430
546
|
if (!Array.isArray(raw["highlightFields"]))
|
|
431
|
-
|
|
547
|
+
malformed(`${path}.highlightFields`);
|
|
432
548
|
result.highlightFields = raw["highlightFields"].map(
|
|
433
549
|
(field, index) => parseHighlight(field, `${path}.highlightFields[${index}]`)
|
|
434
550
|
);
|
|
@@ -436,7 +552,7 @@ function mapSearchResult(value, path) {
|
|
|
436
552
|
return result;
|
|
437
553
|
}
|
|
438
554
|
function mapCatalogSearch(raw) {
|
|
439
|
-
|
|
555
|
+
rejectUnsafeFields(raw, "search");
|
|
440
556
|
const envelope = record(raw, "search");
|
|
441
557
|
if (!Array.isArray(envelope["results"])) return malformed("search.results");
|
|
442
558
|
const ranking = envelope["ranking"];
|
|
@@ -450,63 +566,6 @@ function mapCatalogSearch(raw) {
|
|
|
450
566
|
ranking
|
|
451
567
|
};
|
|
452
568
|
}
|
|
453
|
-
async function agentSignup(options = {}) {
|
|
454
|
-
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
455
|
-
if (typeof fetchImpl !== "function") {
|
|
456
|
-
throw new AnyAPIError(
|
|
457
|
-
"no fetch implementation available: pass options.fetch or run on a runtime with global fetch",
|
|
458
|
-
0
|
|
459
|
-
);
|
|
460
|
-
}
|
|
461
|
-
const base = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, "");
|
|
462
|
-
const body = {};
|
|
463
|
-
if (options.sponsorEmail !== void 0) {
|
|
464
|
-
body["sponsorEmail"] = options.sponsorEmail;
|
|
465
|
-
}
|
|
466
|
-
if (options.label !== void 0) {
|
|
467
|
-
body["label"] = options.label;
|
|
468
|
-
}
|
|
469
|
-
let response;
|
|
470
|
-
try {
|
|
471
|
-
response = await fetchImpl(`${base}/agent/signup`, {
|
|
472
|
-
method: "POST",
|
|
473
|
-
headers: {
|
|
474
|
-
"Content-Type": "application/json",
|
|
475
|
-
Accept: "application/json"
|
|
476
|
-
},
|
|
477
|
-
body: JSON.stringify(body)
|
|
478
|
-
});
|
|
479
|
-
} catch (err) {
|
|
480
|
-
throw new ConnectionError(
|
|
481
|
-
err instanceof Error ? err.message : "connection failed",
|
|
482
|
-
0
|
|
483
|
-
);
|
|
484
|
-
}
|
|
485
|
-
const requestId = requestIdOf(response.headers);
|
|
486
|
-
const text = await response.text().catch(() => "");
|
|
487
|
-
if (response.status !== 200) {
|
|
488
|
-
let message = `request failed with status ${response.status}`;
|
|
489
|
-
let code;
|
|
490
|
-
try {
|
|
491
|
-
const parsed2 = JSON.parse(text);
|
|
492
|
-
if (typeof parsed2.error === "string" && parsed2.error !== "") {
|
|
493
|
-
message = parsed2.error;
|
|
494
|
-
}
|
|
495
|
-
if (typeof parsed2.code === "string" && parsed2.code !== "") {
|
|
496
|
-
code = parsed2.code;
|
|
497
|
-
}
|
|
498
|
-
} catch {
|
|
499
|
-
}
|
|
500
|
-
throw errorFromStatus(response.status, message, requestId, code);
|
|
501
|
-
}
|
|
502
|
-
const parsed = JSON.parse(text);
|
|
503
|
-
return {
|
|
504
|
-
secret: parsed.secret,
|
|
505
|
-
capUsd: parsed.capUsd,
|
|
506
|
-
claimToken: parsed.claimToken,
|
|
507
|
-
claimUrl: parsed.claimUrl
|
|
508
|
-
};
|
|
509
|
-
}
|
|
510
569
|
|
|
511
570
|
// src/core/client.ts
|
|
512
571
|
var DEFAULT_BASE_URL2 = "https://api.getanyapi.com";
|
|
@@ -1840,11 +1899,24 @@ var FacebookNamespace = class {
|
|
|
1840
1899
|
* Price: $0.002 per request.
|
|
1841
1900
|
*
|
|
1842
1901
|
* @example
|
|
1843
|
-
* const res = await client.facebook.adDetails({ id: "
|
|
1902
|
+
* const res = await client.facebook.adDetails({ id: "1249043200627555" });
|
|
1844
1903
|
*/
|
|
1845
1904
|
adDetails(input, options) {
|
|
1846
1905
|
return this._core.run("facebook.ad_details", input, options);
|
|
1847
1906
|
}
|
|
1907
|
+
/**
|
|
1908
|
+
* Facebook Ad Creative Details
|
|
1909
|
+
*
|
|
1910
|
+
* Pull one Meta Ad Library ad with its creative: every carousel variant, image and video URL, headline, body, and call to action.
|
|
1911
|
+
*
|
|
1912
|
+
* Price: $0.00441 per request plus $0 per result (maximum $0.00441).
|
|
1913
|
+
*
|
|
1914
|
+
* @example
|
|
1915
|
+
* const res = await client.facebook.adDetailsFull({ id: "1519158199783790" });
|
|
1916
|
+
*/
|
|
1917
|
+
adDetailsFull(input, options) {
|
|
1918
|
+
return this._core.run("facebook.ad_details_full", input, options);
|
|
1919
|
+
}
|
|
1848
1920
|
/**
|
|
1849
1921
|
* Facebook Ad Transcript
|
|
1850
1922
|
*
|
|
@@ -2313,7 +2385,7 @@ var FacebookNamespace = class {
|
|
|
2313
2385
|
*
|
|
2314
2386
|
* Search public Facebook posts by keyword, optionally filtered by location, and get structured post records (text, author, engagement).
|
|
2315
2387
|
*
|
|
2316
|
-
* Price: $0 per request plus $0.00315 per result (maximum $0.
|
|
2388
|
+
* Price: $0.00006 per request plus $0.00315 per result (maximum $0.0631).
|
|
2317
2389
|
*
|
|
2318
2390
|
* @example
|
|
2319
2391
|
* const res = await client.facebook.searchPosts({ query: "nike", limit: 3 });
|
|
@@ -3188,7 +3260,7 @@ var InstagramNamespace = class {
|
|
|
3188
3260
|
*
|
|
3189
3261
|
* Fetch an Instagram account's public profile (followers, posts, bio, verification) by handle.
|
|
3190
3262
|
*
|
|
3191
|
-
* Price: $0.
|
|
3263
|
+
* Price: $0.002 per request.
|
|
3192
3264
|
*
|
|
3193
3265
|
* @example
|
|
3194
3266
|
* const res = await client.instagram.profile({ handle: "nasa" });
|
|
@@ -3243,7 +3315,7 @@ var InstagramNamespace = class {
|
|
|
3243
3315
|
* Price: $0.002 per request.
|
|
3244
3316
|
*
|
|
3245
3317
|
* @example
|
|
3246
|
-
* const res = await client.instagram.searchHashtag({ hashtag: "
|
|
3318
|
+
* const res = await client.instagram.searchHashtag({ hashtag: "skincare", datePosted: "last-month", mediaType: "reel" });
|
|
3247
3319
|
*/
|
|
3248
3320
|
searchHashtag(input, options) {
|
|
3249
3321
|
return this._core.run("instagram.search_hashtag", input, options);
|
|
@@ -3842,6 +3914,43 @@ var MobilePhoneNamespace = class {
|
|
|
3842
3914
|
}
|
|
3843
3915
|
};
|
|
3844
3916
|
|
|
3917
|
+
// src/generated/platforms/naver.ts
|
|
3918
|
+
var NaverNamespace = class {
|
|
3919
|
+
constructor(_core) {
|
|
3920
|
+
this._core = _core;
|
|
3921
|
+
}
|
|
3922
|
+
_core;
|
|
3923
|
+
/**
|
|
3924
|
+
* Naver Blog Search
|
|
3925
|
+
*
|
|
3926
|
+
* Search up to five enriched Naver blog results by keyword with stable cursor pagination: result rank, title, excerpt, post and blogger URLs, blogger name, publish time, and Naver's total match count.
|
|
3927
|
+
*
|
|
3928
|
+
* Price: $0.036 per request.
|
|
3929
|
+
*
|
|
3930
|
+
* @example
|
|
3931
|
+
* const res = await client.naver.blogSearch({ query: "제주도 맛집", limit: 5, sort: "relevance" });
|
|
3932
|
+
*/
|
|
3933
|
+
blogSearch(input, options) {
|
|
3934
|
+
return this._core.run("naver.blog_search", input, options);
|
|
3935
|
+
}
|
|
3936
|
+
/**
|
|
3937
|
+
* Iterate every result of Naver Blog Search across pages.
|
|
3938
|
+
*
|
|
3939
|
+
* Yields items directly; call `.pages()` on the return value to walk whole
|
|
3940
|
+
* result pages instead (each carries its own costUsd).
|
|
3941
|
+
*/
|
|
3942
|
+
iterBlogSearch(input, options) {
|
|
3943
|
+
return paginate(
|
|
3944
|
+
this._core,
|
|
3945
|
+
"naver.blog_search",
|
|
3946
|
+
input,
|
|
3947
|
+
"items",
|
|
3948
|
+
false,
|
|
3949
|
+
options
|
|
3950
|
+
);
|
|
3951
|
+
}
|
|
3952
|
+
};
|
|
3953
|
+
|
|
3845
3954
|
// src/generated/platforms/pandaexpress.ts
|
|
3846
3955
|
var PandaexpressNamespace = class {
|
|
3847
3956
|
constructor(_core) {
|
|
@@ -5414,6 +5523,19 @@ var TiktokNamespace = class {
|
|
|
5414
5523
|
videoTranscript(input, options) {
|
|
5415
5524
|
return this._core.run("tiktok.video_transcript", input, options);
|
|
5416
5525
|
}
|
|
5526
|
+
/**
|
|
5527
|
+
* TikTok Video Transcript (Audio)
|
|
5528
|
+
*
|
|
5529
|
+
* Transcribe the spoken audio of a TikTok video with timed segments, speaker labels, and per-word confidence - for videos TikTok publishes no subtitle track for.
|
|
5530
|
+
*
|
|
5531
|
+
* Price: $0.0168 per request plus $0 per result (maximum $0.0168).
|
|
5532
|
+
*
|
|
5533
|
+
* @example
|
|
5534
|
+
* const res = await client.tiktok.videoTranscriptFull({ url: "https://www.tiktok.com/@thatdudecancook/video/7649086431641521421" });
|
|
5535
|
+
*/
|
|
5536
|
+
videoTranscriptFull(input, options) {
|
|
5537
|
+
return this._core.run("tiktok.video_transcript_full", input, options);
|
|
5538
|
+
}
|
|
5417
5539
|
};
|
|
5418
5540
|
|
|
5419
5541
|
// src/generated/platforms/tiktok_shop.ts
|
|
@@ -6264,12 +6386,12 @@ var YoutubeNamespace = class {
|
|
|
6264
6386
|
/**
|
|
6265
6387
|
* YouTube Channel Shorts
|
|
6266
6388
|
*
|
|
6267
|
-
* List a YouTube channel's Shorts by handle or channel ID with cursor pagination
|
|
6389
|
+
* List a YouTube channel's Shorts by handle or channel ID with cursor pagination, views, and publish timestamps.
|
|
6268
6390
|
*
|
|
6269
6391
|
* Price: $0.002 per request.
|
|
6270
6392
|
*
|
|
6271
6393
|
* @example
|
|
6272
|
-
* const res = await client.youtube.channelShorts({ handle: "@
|
|
6394
|
+
* const res = await client.youtube.channelShorts({ handle: "@zachking", sort: "latest" });
|
|
6273
6395
|
*/
|
|
6274
6396
|
channelShorts(input, options) {
|
|
6275
6397
|
return this._core.run("youtube.channel_shorts", input, options);
|
|
@@ -6473,7 +6595,7 @@ var YoutubeNamespace = class {
|
|
|
6473
6595
|
*
|
|
6474
6596
|
* Fetch the transcript/captions of a YouTube video by URL or ID.
|
|
6475
6597
|
*
|
|
6476
|
-
* Price: $0.
|
|
6598
|
+
* Price: $0.011 per request.
|
|
6477
6599
|
*
|
|
6478
6600
|
* @example
|
|
6479
6601
|
* const res = await client.youtube.videoTranscript({ url: "https://www.youtube.com/watch?v=dQw4w9WgXcQ" });
|
|
@@ -6481,6 +6603,19 @@ var YoutubeNamespace = class {
|
|
|
6481
6603
|
videoTranscript(input, options) {
|
|
6482
6604
|
return this._core.run("youtube.video_transcript", input, options);
|
|
6483
6605
|
}
|
|
6606
|
+
/**
|
|
6607
|
+
* YouTube Video Transcript (Provenance)
|
|
6608
|
+
*
|
|
6609
|
+
* Fetch a YouTube transcript with timed segments and its provenance: whether the words are creator-written captions or machine speech recognition.
|
|
6610
|
+
*
|
|
6611
|
+
* Price: $0.00294 per request plus $0 per result (maximum $0.00294).
|
|
6612
|
+
*
|
|
6613
|
+
* @example
|
|
6614
|
+
* const res = await client.youtube.videoTranscriptFull({ url: "https://www.youtube.com/watch?v=dQw4w9WgXcQ" });
|
|
6615
|
+
*/
|
|
6616
|
+
videoTranscriptFull(input, options) {
|
|
6617
|
+
return this._core.run("youtube.video_transcript_full", input, options);
|
|
6618
|
+
}
|
|
6484
6619
|
};
|
|
6485
6620
|
|
|
6486
6621
|
// src/generated/platforms/zhihu.ts
|
|
@@ -6864,6 +6999,14 @@ var AnyAPI2 = class extends AnyAPI {
|
|
|
6864
6999
|
this._core
|
|
6865
7000
|
);
|
|
6866
7001
|
}
|
|
7002
|
+
/**
|
|
7003
|
+
* Typed methods for the naver platform.
|
|
7004
|
+
*/
|
|
7005
|
+
get naver() {
|
|
7006
|
+
return this._namespaces["naver"] ??= new NaverNamespace(
|
|
7007
|
+
this._core
|
|
7008
|
+
);
|
|
7009
|
+
}
|
|
6867
7010
|
/**
|
|
6868
7011
|
* Typed methods for the pandaexpress platform.
|
|
6869
7012
|
*/
|
|
@@ -7185,6 +7328,7 @@ var AnyAPI2 = class extends AnyAPI {
|
|
|
7185
7328
|
LinkedinNamespace,
|
|
7186
7329
|
MapsNamespace,
|
|
7187
7330
|
MobilePhoneNamespace,
|
|
7331
|
+
NaverNamespace,
|
|
7188
7332
|
NotFoundError,
|
|
7189
7333
|
PandaexpressNamespace,
|
|
7190
7334
|
PeopleSearchNamespace,
|