@apinoa/ sdk (英语)
正式类型脚本和 JavaScript SDK 阿皮诺阿:亚马逊的产品数据, Walmart, Shopify, TikTok Shop and AliExpress; 来自TikTok, YouTube, Instagram的文章、简介和评论, 线索、X、Reddit和LinkedIn;搜索结果来自Google、Bing、Naver和另外13个搜索引擎;AI 来自ChatGPT,双子座,Google AI Overviews,Google AI Mode和Naver的答案;和图像翻译,通过 一个API.
npm install @apinoa/sdk
需要20个或以后的节点(或任何运行时间) fetch: Bun, Deno, Cloudflare工人).
使用量
在下方创建密钥 盘盘 > API 密钥 时间 apinoa.com (英语),则:
import { ApinoaClient } from "@apinoa/sdk";
const apinoa = new ApinoaClient({ apiKey: process.env.APINOA_API_KEY });
const { data } = await apinoa.amazon.search({ query: "wool socks", priceMax: 30 });
for (const item of data.items) console.log(item.title, item.price?.amount);
apiKey 默认为 APINOA_API_KEY 环境变量。 在您的服务器上保留密钥: 它花费
你的平衡。 。 .
每个电话都是 apinoa.<platform>.<operation>(params),拼写了 URL 的方式 : /v1/tiktokshop/product
实值 apinoa.tiktokshop.product(...)。每个答案是: { success, data, requestId }。 。 。 .
市场
每个市场都用一个商业计划来回答:a Product 从亚马逊读起来就像从Shoppify读出来的.
const product = await apinoa.walmart.product({ id: "18256507800" });
const reviews = await apinoa.shopify.reviews({ id: "allbirds.com/products/mens-tree-runners" });
const tree = await apinoa.amazon.categories({});
社会平台
每个平台都用一个社会计划来回答Account, (中文(简体) ), Post, (中文(简体) ), Comment, (中文(简体) ), Group),仅用一个
平台在 ext。 。 。 .
const creator = await apinoa.tiktok.profile({ username: "khaby.lame" });
const page = await apinoa.reddit.posts({ community: "typescript" });
const next = await apinoa.reddit.posts({ cursor: page.data.cursor }); // the next page: the cursor alone
搜索引擎
每个搜索引擎都用一个结果页的计划来回答:Google, Bing, Naver, Baidu, Yandex, Yahoo and the
休息,返回同样的 items。 。 。 .
const { data } = await apinoa.google.search({ q: "trail running shoes", country: "US" });
for (const item of data.items) if (item.type === "organic") console.log(item.position, item.title, item.url);
const naver = await apinoa.naver.search({ q: "러닝화 추천" });
大赦国际的答复
什么ChatGPT,双子座,Google AI Overviews,Google AI Mode和Naver对一个快报的回答,及其引用,
来源和它命名的品牌,一个 Answer 类型.
const { data } = await apinoa.chatgpt.answer({ prompt: "Best running shoes for beginners?", country: "US" });
console.log(data.text);
for (const s of data.sources) if (s.cited) console.log(s.url);
const aio = await apinoa.googleAio.answer({ prompt: "best running shoes for beginners" });
图像翻译
import { readFile, writeFile } from "node:fs/promises";
const image = await apinoa.imageTranslate.translate(await readFile("product.jpg"), {
source_language: "zh-CN",
target_language: "ko",
});
await writeFile("translated.jpg", Buffer.from(await image.arrayBuffer()));
与 render: false 尸体是JSON(被清理的图像和每个文本区域):用
JSON.parse(await image.text())。 。 。 .
错误
失败的调用会丢出一个子类 ApinoaError 以其地位命名(BadRequestError, (中文(简体) ),
PaymentRequiredError, (中文(简体) ), NotFoundError, (中文(简体) ), TooManyRequestsError(中文(简体) ). err.body.error.code 是马厩
代码到分支; 每个代码在 apinoa.com/docs/errors (中文(简体) )A级
无法调用 .
import { Apinoa, ApinoaError } from "@apinoa/sdk";
try {
await apinoa.amazon.product({ id: "B000000000" });
} catch (err) {
if (err instanceof Apinoa.NotFoundError) console.log("no such product");
else if (err instanceof Apinoa.PaymentRequiredError) console.log("top up your balance");
else throw err;
}
检索和超时
429, (中文(简体) ), 408 财务报告和审定财务报表 5xx 回答要重复两次, 以指数反射, 尊重 Retry-After。 。 。 .
换一个 maxRetries,每个客户或每个呼叫。 默认超时为 300 秒, 因为图像
装入时的翻译需要几分钟; 设定 timeoutInSeconds 如果您愿意,请降低数据调用.
const apinoa = new ApinoaClient({ maxRetries: 4, timeoutInSeconds: 60 });
await apinoa.tiktok.posts({ username: "nasa" }, { maxRetries: 0, abortSignal: AbortSignal.timeout(10_000) });
实例
examples/ 持有四个小程序来复制和适应: 一个价格跟踪器,一个等级跟踪器,
社会倾听和人工智能回答监视器。 每个文件都是用 npx tsx。 。 。 .
参考文献
每一种方法和参数: 页:1API本身: apinoa.com/docs (中文(简体) )。此 SDK 文档的 OpenAPI 来源于 : apinoa.com/openapi.json 页面存档备份,存于互联网档案馆。 。 。 .
许可证
麻省理工学院