@channel3/sdk

中文文档
4.8.0发布于 2026/11/05TypeScriptESM + CJS零依赖近 30 天下载 3422

fern shield [![npm shield]

原始使用文档
文档目录21 节
  1. Documentation
  2. Runtime Compatibilities
  3. Installation
  4. Authentication
  5. Usage
  6. Search products
  7. Paginate through results
  8. Visual search by image
  9. Find similar products
  10. Look up a product by URL
  11. Browse brands and categories
  12. Track prices
  13. Type Intellisense
  14. Error Handling
  15. Advanced
  16. Retries
  17. Timeouts
  18. Abort Requests
  19. Raw Response Access
  20. Reference
  21. Contributing

Channel3 TypeScript SDK

fern shield npm shield

The official TypeScript SDK for the Channel3 API — a universal product database powering AI shopping apps and agents.

Documentation

Full API documentation and guides are available at channel3.docs.buildwithfern.com.

Runtime Compatibilities

RequirementVersion
Node.js>= 18.0.0
TypeScript>= 4.5 (optional — works in plain JS too)
Module systemESM and CommonJS (dual-package)
BrowsersAny environment with fetch (or pass a polyfill)
Edge runtimesCloudflare Workers, Vercel Edge, Deno
React NativeSupported

Installation

npm install @channel3/sdk
# or
yarn add @channel3/sdk
# or
pnpm add @channel3/sdk

Authentication

The SDK authenticates via an x-api-key header. Pass your key when initializing the client:

import { Channel3Client } from "@channel3/sdk";

const client = new Channel3Client({ apiKey: "YOUR_API_KEY" });

You can also supply a function for dynamic key resolution (useful for key rotation):

const client = new Channel3Client({
    apiKey: async () => getKeyFromVault(),
});

Usage

Search products

const response = await client.products.search({
    query: "organic cotton t-shirt",
    limit: 10,
});

for (const product of response.products) {
    console.log(product.title, product.offers?.[0]?.price);
}

Paginate through results

Search responses include a nextPageToken for cursor-based pagination:

let pageToken: string | undefined;

do {
    const response = await client.products.search({
        query: "sneakers",
        pageToken,
    });

    for (const product of response.products) {
        console.log(product.title);
    }

    pageToken = response.nextPageToken ?? undefined;
} while (pageToken);

Visual search by image

const response = await client.products.imageSearch({
    imageUrl: "https://example.com/photo.jpg",
});

Find similar products

const response = await client.products.similar({
    productId: "prod-12345",
});

Look up a product by URL

const product = await client.products.lookup({
    url: "https://example.com/product/abc",
});

Browse brands and categories

Cursor-paginated listing for brands and categories:

const brands = await client.brands.list({ limit: 50 });
console.log(brands.items);       // Brand[]
console.log(brands.nextCursor);  // pass as `cursor` for the next page

const categories = await client.categories.list({ pageSize: 50 });

Track prices

// Start tracking
await client.priceTracking.start({ canonicalProductId: "prod-12345" });

// Get price history
const history = await client.priceTracking.getHistory({ canonicalProductId: "prod-12345" });

// List active subscriptions
const subs = await client.priceTracking.listSubscriptions();

// Stop tracking
await client.priceTracking.stop({ canonicalProductId: "prod-12345" });

Type Intellisense

All request and response types are exported under the Channel3 namespace for easy discovery:

import { Channel3 } from "@channel3/sdk";

// Full autocomplete on request fields
const request: Channel3.SearchRequest = {
    query: "wireless headphones",
    limit: 20,
    filters: { gender: "female" },
    config: { country: "US", currency: "USD" },
};

// Response types are also typed
const response: Channel3.SearchResponse = await client.products.search(request);

Resource clients are accessible via dot notation — type client. in your editor to discover:

AccessorMethods
client.productssearch, imageSearch, similar, lookup, retrieve, enrich
client.brandslist, search, get
client.categorieslist, search
client.priceTrackingstart, stop, getHistory, listSubscriptions
client.websiteslist

Error Handling

The SDK throws typed errors per HTTP status code:

import { Channel3Error, Channel3TimeoutError } from "@channel3/sdk";

try {
    await client.products.search({ query: "test" });
} catch (err) {
    if (err instanceof Channel3Error) {
        console.log(err.statusCode); // 401, 402, 422, etc.
        console.log(err.message);
        console.log(err.body);
    }
}

Advanced

Retries

Automatic exponential backoff on 5xx and network errors (default: 2 retries):

const response = await client.products.search(
    { query: "shoes" },
    { maxRetries: 5 },
);

Timeouts

Default timeout is 60 seconds. Override per-client or per-request:

const client = new Channel3Client({
    apiKey: "YOUR_API_KEY",
    timeoutInSeconds: 30,
});

// Per-request
await client.products.search({ query: "shoes" }, { timeoutInSeconds: 10 });

Abort Requests

const controller = new AbortController();
await client.products.search({ query: "shoes" }, { abortSignal: controller.signal });

Raw Response Access

Access HTTP headers and status alongside parsed data:

const response = await client.products.search({ query: "shoes" });
console.log(response.rawResponse.status);
console.log(response.rawResponse.headers);

Reference

See the full API reference in reference.md.

Contributing

See CONTRIBUTING.md for development setup and guidelines.

版本与发布记录

@channel3/sdk 共发布 39 个版本,首次发布于 2025/09/17;过去 12 个月发布了 35 个版本。

版本发布日期距今
4.8.0latest2026/11/054 天前
4.7.02026/11/054 天前
4.6.02026/10/2911 天前
4.5.02026/10/2416 天前
4.4.12026/10/2119 天前
4.4.02026/10/2020 天前

其他发布通道:beta → 4.0.0-beta.4。

关于 @channel3/sdk 的常见问题

@channel3/sdk 是什么?

[![npm shield]

如何安装 @channel3/sdk?

在项目目录运行 npm install @channel3/sdk,或使用 pnpm add / yarn add / bun add。

@channel3/sdk 支持 TypeScript 吗?

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

@channel3/sdk 支持 ESM 还是 CommonJS?

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

@channel3/sdk 需要什么版本的 Node.js?

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

@channel3/sdk 可以商用吗?

@channel3/sdk 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@channel3/sdk 的下载量有多少?

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

@channel3/sdk 还在维护吗?

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