Skip to main content
The Octogen TypeScript SDK gives you a fully typed, async client for the Octogen commerce API. Install it from npm, configure your OCTO_API_KEY, and you can search products by keyword and facet, find products similar to a source product, and look up any product by URL — all with complete TypeScript interfaces so your editor catches mistakes before they reach production.

Installation

1

Install the package

Requires Node.js 20 or later. The SDK ships as ESM only.
2

Set your API key

The client reads your key from the OCTO_API_KEY environment variable automatically.
You can also pass apiKey: in the constructor options if you prefer to manage secrets yourself (see Authentication below).

Authentication

OctogenClient resolves your API key in this order:
  1. The apiKey option passed to the constructor, if provided.
  2. The OCTO_API_KEY environment variable (process.env.OCTO_API_KEY).
If neither is set, the constructor throws MissingAPIKeyError immediately — before any network request is made. Every request then sends the key as Authorization: Bearer <api-key>.

Client options

OctogenClient accepts an optional OctogenClientOptions object:

Methods

lookupProduct

Resolves a product page URL from Octogen’s index or with on-demand product resolution. Set resolutionMode: "index_only" when your integration requires indexed identity and catalog context.
Returns: Promise<MerchantProductUrlLookupResponse>

searchProducts

Searches products across all authorized catalogs by default. Pass catalog only when you want to restrict search to one catalog. SearchProductsParams fields: Returns: Promise<MerchantProductListPage> Each MerchantProductListItem includes uuid, catalogKey, productUrl, title, brand, currentPrice, originalPrice, imageUrl, images, rating, isActive, optional match scores, and updatedAt.

moreLikeThisProducts

Finds products similar to a source product URL or UUID. Omit catalog to search all active crawled catalogs, or pass a catalog key to keep the results within one catalog.
MoreLikeThisProductsParams fields: Returns: Promise<MoreLikeThisProductsResponse>

Complete example

The following example searches all active crawled catalogs for women’s linen dresses and prints each result with its brand and price:
Use Facet objects to filter by brand, gender, color, category, and other attributes. Pass them in the facets field of SearchProductsParams.
FacetName is a const object with string values for all built-in facet fields: BRAND_NAME, GENDER, AGE_GROUPS, COLOR, COLOR_FAMILY, IS_ACTIVEWEAR, PRODUCT_TYPE, CATEGORY_PATH_DEPTH_0 through CATEGORY_PATH_DEPTH_6, and more. You can also pass any custom attribute facet name as a plain string.

Pagination

When nextCursor is not null in a response, pass it as cursor in your next call to retrieve the following page:

Error handling

All SDK errors extend OctogenError. HTTP errors extend OctogenAPIError, which exposes statusCode, detail, and response properties.
Thrown when your API key is missing, malformed, or has been revoked. Check that OCTO_API_KEY is set correctly and that the key is still active in Octogen Platform.
Thrown when a valid key attempts an action it is not authorized for — for example, accessing a catalog that has not been granted to your organization.
Thrown when a catalog or product URL cannot be found. For lookupProduct, verify the URL belongs to a catalog your key can access.
Thrown when the API rejects a request due to invalid parameters. The detail property contains the validation error list from the API.
Thrown when the SDK cannot reach the API — for example, due to a network timeout or DNS failure. Does not have a statusCode.
Catch the base OctogenAPIError to handle all HTTP errors in one place:
MissingAPIKeyError is thrown by the constructor, not by a network call. It will surface at client creation time if neither apiKey nor OCTO_API_KEY is present.