发现网络 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);
所有部件类型都暴露出类似的功能和类型 :
getGlobalWidgetgetKeywordWidgetgetCategoryWidgetgetItemWidgetgetPersonalizedWidgetgetRecentlyViewedWidget
畅销书 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是开放源代码,我们欢迎外部贡献. 看我们的 贡献指南。 。 。 .
许可证
这个项目根据麻省理工学院的许可证获得许可。 见 自由主义 详细文件.