Security News
The Risks of Misguided Research in Supply Chain Security
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
@bloomreach/discovery-web-sdk
Advanced tools
> ⚙️ **SDK Reference** > > The detailed TSDoc and reference for the SDK are available [here](https://bloomreach.github.io/discovery-web-sdk/modules.html).
⚙️ SDK Reference
The detailed TSDoc and reference for the SDK are available here.
The Bloomreach Discovery Web SDK is a TypeScript SDK designed to interact with the Bloomreach Discovery APIs. This SDK provides a convenient way to integrate and use the Discovery data in your website or applications.
The SDK provides an interface to implement the following Bloomreach Discovery APIs:
The Discovery Web SDK is fully Open-Sourced and open to contributions.
The SDK currently requires:
npm add @bloomreach/discovery-web-sdk
pnpm add @bloomreach/discovery-web-sdk
yarn add @bloomreach/discovery-web-sdk
Adding debug: true
to the Configuration
you pass into the API calls will enable some minor debug logging with [BR]
as a prefix for your convenience.
Below are some usage examples that demonstrate how to call and use various Discovery APIs in your website or application using the SDK.
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);
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);
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);
Similar functions and types are exposed for all widget types:
getGlobalWidget
getKeywordWidget
getCategoryWidget
getItemWidget
getPersonalizedWidget
getRecentlyViewedWidget
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);
The Bloomreach Discovery SDK is Open-Source, and we welcome outside contributions. See our Contribution Guide.
This project is licensed under the MIT License. See the LICENSE file for details.
2.0.1 (2024-11-26)
types: Export all search response types (2817d35)
fix!: Search API functions how take query as a parameter (07e122e)
fix!: Remove invalid SearchOption type guard functions (2e40d50)
productSearch
, bestseller
, contentSearch
, categorySearch
and autoSuggest
parameters have changed.isBestsellerOptions
, isAutosuggestOptions
, isContentSearchOptions
,
isProductSearchOptions
, isCategorySearchOptions
functions from the API.FAQs
> ⚙️ **SDK Reference** > > The detailed TSDoc and reference for the SDK are available [here](https://bloomreach.github.io/discovery-web-sdk/modules.html).
We found that @bloomreach/discovery-web-sdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.