@haatlabs-core/services

中文文档
0.18.5发布于 2026/11/14Apache-2.0TypeScriptESM + CJS近 30 天下载 5694

The client for the Haatlabs API on RapidAPI: Amazon lookups, image search, background removal, AI and jobs.

原始使用文档
文档目录4 节
  1. Install
  2. Use
  3. Errors
  4. Testing

@haatlabs-core/services

The client for the Haatlabs API on RapidAPI: Amazon search and product pages, image search, background removal, AI product descriptions and image checks, and jobs that chain them. One RapidAPI key; the work runs on Haatlabs' servers.

Install

pnpm add @haatlabs-core/services

Subscribe to the Haatlabs API on RapidAPI (the BASIC plan is free) and put the key in your app's environment as HAATLABS_API_KEY. Plans and limits: https://haatlabs.shop/docs/services/

Use

import { createHaatlabsApi } from '@haatlabs-core/services';

const api = createHaatlabsApi({ apiKey: process.env.HAATLABS_API_KEY! });
const page = await api.amazon.search({ q: 'desk lamp', market: 'US' });
const cutout = await api.images.removeBackground({ image: bytes }); // or { imageUrl }
const job = await api.jobs.start('find-clean', { query: 'desk lamp', limit: 5 });
const done = await api.jobs.wait(job.jobId);
  • amazon.search(query), amazon.product({ market, id })
  • images.search(q, { limit }), images.removeBackground({ image } | { imageUrl }): an image by its bytes (at most 5 MB, MAX_UPLOAD_BYTES) or a public https URL; the cut-out's URL is signed until expiresAt.
  • ai.describe({ product, tone, language, keywords }), ai.vision({ image } | { imageUrl }, expect, minMatch): the image with its verdict.
  • jobs.start(kind, body) for enrich, find-clean, listing, find-checked and pipeline; jobs.get(id); jobs.wait(id, { intervalMs, timeoutMs }).
  • verifyWebhook({ secret, headers, body }): whether a job's callback is really the API's (Standard Webhooks signatures, five minutes either way). Pass the raw body.

Options: host (the listing's RapidAPI host), baseUrl, fetch, timeoutMs (35 s).

Errors

Every failure is an AppError (@haatlabs-core/errors); a project spreads SERVICES_ERRORS into defineErrors. A ServiceError also carries the API's own serviceCode and requestId.

  • SERVICE_QUOTA_EXCEEDED (503): the plan's quota is used up; upgrade or wait for the period.
  • SERVICE_RATE_LIMITED (503, transient): too many requests a second.
  • SERVICE_KEY_REFUSED (503): a wrong key, or one not subscribed to the API.
  • SERVICE_REQUEST_REJECTED (422): the API refused what was sent (IMAGE_REJECTED, PIPELINE_INVALID); VALIDATION_FAILED (400) and NOT_FOUND (404) pass through.
  • SERVICE_UNAVAILABLE (503): the API or a service behind it is away or busy (transient), or answered something unusable (not transient).
  • SERVICE_JOB_TIMEOUT (503, transient): jobs.wait stopped before the job ended.

An image over 5 MB is refused with VALIDATION_FAILED before anything is sent.

Testing

@haatlabs-core/services/testing has startFakeApi(), a local stand-in that answers like the API and like RapidAPI's refusals (refuse('quota'), failNext(path, status, code), jobsNeverFinish()), and records every request. pnpm test:real makes one live call per method with HAATLABS_API_KEY.

版本与发布记录

@haatlabs-core/services 共发布 26 个版本,首次发布于 2026/11/07;过去 12 个月发布了 26 个版本。

版本发布日期距今
0.18.5latest2026/11/143 天前
0.18.42026/11/133 天前
0.18.32026/11/134 天前
0.18.22026/11/134 天前
0.18.12026/11/134 天前
0.18.02026/11/134 天前

关于 @haatlabs-core/services 的常见问题

@haatlabs-core/services 是什么?

The client for the Haatlabs API on RapidAPI: Amazon lookups, image search, background removal, AI and jobs.

如何安装 @haatlabs-core/services?

在项目目录运行 npm install @haatlabs-core/services,或使用 pnpm add / yarn add / bun add。

@haatlabs-core/services 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@haatlabs-core/services 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@haatlabs-core/services 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=24。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@haatlabs-core/services 可以商用吗?

@haatlabs-core/services 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@haatlabs-core/services 的下载量有多少?

根据 npm 官方下载统计,@haatlabs-core/services 在 2026/10/17 – 2026/11/15 这 30 天内被下载 5,694 次,日均约 190 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@haatlabs-core/services 还在维护吗?

最新版本 0.18.5 发布于 2026/11/14(3 天前);至今共发布 26 个版本,其中过去 12 个月发布了 26 个;首次发布于 2026/11/07。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。