@bloomreach/discovery-web-sdk

中文文档
2.0.2发布于 2025/12/10TypeScriptES Module零依赖近 30 天下载 2.6万

⚙️ SDK 参考 > > SDK的详细TSDoc和参考文献可供查阅 这里。 。 。 .

中文使用文档
文档目录12 节
  1. 开始
  2. 所需资源
  3. 安装
  4. 使用量
  5. 自动推荐 API
  6. 产品和类别搜索 API
  7. 内容搜索 API
  8. 建议和途径
  9. 畅销书 API
  10. 相关资源
  11. 捐款与发展
  12. 许可证

发现网络 SDK

⚙️ SDK 参考

详细的TSDOC和SDK的参考文献可供查阅 这里。 。 。 .

Bloomreach Discovery Web SDK是一款类型Script SDK,旨在与软件交互 Bloomreach 发现APIs。这个 SDK 提供了一个方便的方法,可以将发现数据集成和使用到您的网站或应用程序中.

SDK提供了一个接口,用于执行以下 Bloomreach Discovery API:

"发现"(Discovery Web SDK)完全开源并开放供稿.

开始

所需资源

SDK目前要求:

安装

npm add @bloomreach/discovery-web-sdk
pnpm add @bloomreach/discovery-web-sdk
yarn add @bloomreach/discovery-web-sdk

调试日志

添加中 debug: true 页:1 Configuration 您通过 API 的电话可以使用 [BR] 作为方便前缀.

使用量

下面是一些用法例子,这些用法说明如何在您的网站或应用程序中使用SDK调用和使用各种发现API.

自动推荐 API

import type { Configuration, AutosuggestOptions } from '@bloomreach/discovery-web-sdk';
import { autosuggest } from '@bloomreach/discovery-web-sdk';

// Set the account and catalog configuration
const config: Configuration = {
  account_id: 1234,
  domain_key: 'example_com',
};

// Set up the search parameters
const searchOptions: AutosuggestOptions = {
  catalog_views: 'product:store1,store2|recipe:premium|articles',
  q: 'Roses',
  url: 'http://example.com',
  _br_uid_2: 'someCookieId',
};

// Retrieve the suggestions with a search using the provided search parameters
const data = await autosuggest(config, searchOptions);

产品和类别搜索 API

import type { Configuration, ProductSearchOptions } from '@bloomreach/discovery-web-sdk';
import { productSearch } from '@bloomreach/discovery-web-sdk';

// Set the account and catalog configuration
const config: Configuration = {
  account_id: 1234,
  domain_key: 'example_com',
};

// Set up the search parameters
const searchOptions: ProductSearchOptions = {
  q: 'Generic Metal Pants',
  fl: 'pid,title,description,brand,price,thumb_image',
  start: 0,
  rows: 10,
  url: 'http://example.com',
  _br_uid_2: 'someCookieId',
};

// Retrieve the product data with a search using the provided search parameters
const data = await productSearch(config, searchOptions);



import type { Configuration, CategorySearchOptions } from '@bloomreach/discovery-web-sdk';
import { categorySearch } from '@bloomreach/discovery-web-sdk';

// Set the account and catalog configuration
const config: Configuration = {
  account_id: 1234,
  domain_key: 'example_com',
};

// Set up the search parameters
const searchOptions: CategorySearchOptions = {
  q: 'cat92082',
  fl: 'pid,title,description,brand,price,thumb_image',
  start: 0,
  rows: 10,
  url: 'http://example.com',
  _br_uid_2: 'someCookieId',
};

// Retrieve the product data with a search using the provided search parameters
const data = await categorySearch(config, searchOptions);

内容搜索 API

import type { Configuration, ContentSearchOptions } from '@bloomreach/discovery-web-sdk';
import { contentSearch } from '@bloomreach/discovery-web-sdk';

// Set the account and catalog configuration
const config: Configuration = {
  account_id: 1234,
  domain_key: 'example_com',
};

// Set up the search parameters
const searchOptions: ContentSearchOptions = {
  catalog_name: 'Flowers',
  q: 'Roses',
  fl: 'pid,title,description,brand,price,thumb_image',
  start: 0,
  rows: 10,
  url: 'http://example.com',
  _br_uid_2: 'someCookieId',
};

// Retrieve the Content data with a search using the provided search parameters
const data = await contentSearch(config, searchOptions);

建议和途径

import {
  CategoryWidgetOptions,
  Configuration,
  WidgetResponse,
  getCategoryWidget,
} from '@bloomreach/discovery-web-sdk';

// Set the account and catalog configuration
const config: Configuration = {
  account_id: 1234,
  domain_key: 'example_com',
};

// Set up the search parameters
const searchOptions: CategoryWidgetOptions = {
  cat_id: 'cat123959',
  start: 0,
  rows: 10,
  url: 'http://example.com',
  ref_url: 'http://google.com',
  request_id: 1234,
  _br_uid_2: 'test',
};

const widgetId = 'my_widget_id';

// Retrieve the widget using the widgetId and parameters
const widget = getCategoryWidget(widgetId, config, searchOptions);

所有部件类型都暴露出类似的功能和类型 :

  • getGlobalWidget
  • getKeywordWidget
  • getCategoryWidget
  • getItemWidget
  • getPersonalizedWidget
  • getRecentlyViewedWidget

畅销书 API

import type { Configuration, BestsellerOptions } from '@bloomreach/discovery-web-sdk';
import { bestseller } from '@bloomreach/discovery-web-sdk';

// Set the account and catalog configuration
const config: Configuration = {
  account_id: 1234,
  domain_key: 'example_com',
};

// Set up the search parameters
const searchOptions: BestsellerOptions = {
  q: 'Bolts',
  fl: 'pid,title,description,brand,price,thumb_image',
  start: 0,
  rows: 10,
  url: 'http://example.com',
  _br_uid_2: 'someCookieId',
};

// Retrieve the product data with a search using the provided search parameters
const data = await bestseller(config, searchOptions);

捐款与发展

Bloomreach Discovery SDK是开放源代码,我们欢迎外部贡献. 看我们的 贡献指南。 。 。 .

许可证

这个项目根据麻省理工学院的许可证获得许可。 见 自由主义 详细文件.

版本与发布记录

@bloomreach/discovery-web-sdk 共发布 16 个版本,首次发布于 2024/05/04;过去 12 个月发布了 1 个版本。

版本发布日期距今
2.0.2latest2025/12/1010 个月前
2.0.12024/11/261.9 年前
2.0.02024/11/012 年前
1.3.12024/09/112 年前
1.3.02024/09/062 年前
1.2.12024/08/282 年前

关于 @bloomreach/discovery-web-sdk 的常见问题

@bloomreach/discovery-web-sdk 是什么?

⚙️ SDK 参考 > > SDK的详细TSDoc和参考文献可供查阅 这里。 。 。 .

如何安装 @bloomreach/discovery-web-sdk?

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

@bloomreach/discovery-web-sdk 支持 TypeScript 吗?

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

@bloomreach/discovery-web-sdk 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@bloomreach/discovery-web-sdk 需要什么版本的 Node.js?

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

@bloomreach/discovery-web-sdk 可以商用吗?

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

@bloomreach/discovery-web-sdk 的下载量有多少?

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

@bloomreach/discovery-web-sdk 还在维护吗?

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