@coveo/push-api-client

中文文档
4.0.24发布于 2025/12/10Apache-2.0TypeScriptCommonJS构建来源已验证近 30 天下载 4870

Push API client

原始使用文档
文档目录8 节
  1. Installation
  2. Features
  3. Usage
  4. Proxy configuration
  5. Exponential backoff retry configuration
  6. Local development
  7. Commit
  8. Release

@coveo/push-api-client.js

Coveo Push API client

Installation

npm i @coveo/push-api-client

Features

  • Upload data to both Push and Catalog sources
  • Pre-push document validation
  • Automatic custom field creation
  • Full catalog upload and incremental document update
  • Optimized for large payload uploads

Usage

import {PushSource, DocumentBuilder} from '@coveo/push-api-client';

async function main() {
  const source = new PushSource('my_api_key', 'my_coveo_organization_id');

  const myDocument = new DocumentBuilder(
    'https://my.document.uri',
    'My document title'
  ).withData('these words will be searchable');

  await source.addOrUpdateDocument('my_source_id', myDocument);
}

main();

You can also upload your data into a catalog source

async function main() {
  const source = new CatalogSource('my_api_key', 'my_coveo_organization_id');
  await source
    .batchStreamDocumentsFromFiles('my_source_id', ['path/to/file_or_folder'])
    .batch();
}

main();

See more examples in the ./samples folder.

Proxy configuration

You can use the HTTPS_PROXY or https_proxy environment variable for proxy configuration. Read more about it here.

Exponential backoff retry configuration

By default, the SDK leverages an exponential backoff retry mechanism. Exponential backoff allows for the SDK to make multiple attempts to resolve throttled requests, increasing the amount of time to wait for each subsequent attempt. Outgoing requests will retry when a 429 status code is returned from the platform.

The exponential backoff parameters are as follows:

  • retryAfter - The amount of time, in milliseconds, to wait between throttled request attempts.

    Optional, will default to 5,000.

  • maxRetries - The maximum number of times to retry throttled requests.

    Optional, will default to 10.

  • timeMultiple - The multiple by which to increase the wait time between each throttled request attempt.

    Optional, will default to 2.

You may configure the exponential backoff that will be applied to all outgoing requests. To do so, specify a PlatformOptions object when creating either a CatalogSource or PushSource object:

const catalogSource = new CatalogSource(
  'my_api_key',
  'my_coveo_organization_id',
  {maxRetries: 10, retryAfter: 2000, timeMultiple: 3}
);
const pushSource = new PushSource(
  'my_other_api_key',
  'my_other_coveo_organization_id',
  {maxRetries: 3, retryAfter: 600000}
);

By default, requests will retry a maximum of 10 times, waiting 5 seconds after the first attempt, with a time multiple of 2 (which will equate to a maximum execution time of roughly 1.5 hours).

Local development

  • npm i
  • Copy env.sample to .env, and replace the variables with proper values.
  • npm run dev to compile and run ./src/localtest.ts.
  • npm run test for unit tests.

Commit

Use npm run commit to get a properly formatted commit message which will help control the versioning and CHANGELOG generation.

Release

Run Github action named release, which will bump version, tag and publish to npm.

版本与发布记录

@coveo/push-api-client 共发布 350 个版本,首次发布于 2021/05/13;过去 12 个月发布了 3 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
4.0.24latest2025/12/1011 个月前
4.0.232025/11/2911 个月前
4.0.222025/11/2811 个月前
4.0.212025/10/161.1 年前
4.0.192025/08/191.2 年前
4.0.172025/08/041.3 年前

关于 @coveo/push-api-client 的常见问题

@coveo/push-api-client 是什么?

Push API client

如何安装 @coveo/push-api-client?

在项目目录运行 npm install @coveo/push-api-client,或使用 pnpm add / yarn add / bun add。

@coveo/push-api-client 支持 TypeScript 吗?

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

@coveo/push-api-client 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@coveo/push-api-client 需要什么版本的 Node.js?

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

@coveo/push-api-client 可以商用吗?

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

@coveo/push-api-client 的下载量有多少?

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

@coveo/push-api-client 还在维护吗?

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