Skip to main content
The Octogen Python SDK gives you an async, type-safe client for the Octogen commerce API. Install it with uv, point it at 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 backed by Pydantic models so your IDE can autocomplete every field.

Installation

1

Install the package

Requires Python 3.11 or later. The SDK ships from the public octogen-dev repository and is managed with uv. Clone the repository and sync the sdks/python project:
Run your code against the synced environment with uv run --project sdks/python python your_script.py, or activate it with source sdks/python/.venv/bin/activate.
2

Set your API key

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

Authentication

OctogenClient resolves your API key in this order:
  1. The api_key constructor argument, if provided.
  2. The OCTO_API_KEY environment variable.
If neither is set, the constructor raises MissingAPIKeyError immediately — before any network request is made. Every request then sends the key as Authorization: Bearer <api-key>.

Client constructor

OctogenClient accepts the following keyword-only arguments:

Using the client as an async context manager

Use async with to ensure the underlying HTTP connection pool is closed when you are done:
If you manage the client’s lifetime yourself, call await client.aclose() when finished.

Methods

lookup_product

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

search_products

Searches products across all authorized catalogs by default. Pass catalog only when you want to restrict search to one catalog. Returns: MerchantProductListPage Each MerchantProductListItem includes uuid, catalog_key, product_url, title, brand, current_price, original_price, image_url, images, rating, is_active, optional match scores, and updated_at.

more_like_this_products

Finds products similar to a source product URL or UUID. Provide exactly one of source_url or source_uuid. Omit catalog to search all active crawled catalogs, or pass a catalog key to keep the results within one catalog.
Returns: ProgrammaticMoreLikeThisResponse

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 a list of facets to the facets parameter of search_products.
You can also pass plain dicts instead of Facet instances — the SDK coerces them automatically:
FacetName is a StrEnum with constants 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 next_cursor is not None in a response, pass it as cursor in your next call to retrieve the following page:

Error handling

All SDK errors inherit from OctogenError. HTTP errors inherit from OctogenAPIError, which exposes status_code, detail, and response attributes.
Raised 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.
Raised 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.
Raised when a catalog or product URL cannot be found. For lookup_product, verify the URL belongs to a catalog your key can access.
Raised when the API rejects a request due to invalid parameters. The detail attribute contains the validation error list from the API.
Raised when the SDK cannot reach the API — for example, due to a network timeout or DNS failure. Does not have a status_code.
Catch the base OctogenAPIError to handle all HTTP errors in one place:
MissingAPIKeyError is raised by the constructor, not by a network call. It will surface at client creation time if neither api_key nor OCTO_API_KEY is present.

BigQuery subscribe (optional)

If Octogen shares a catalog with you over BigQuery Analytics Hub, the SDK can subscribe to the listing and create a linked dataset in your own Google Cloud project, so you can query the catalog with SQL. See the Subscribe to a catalog in BigQuery guide for the full walkthrough. This helper uses your Google Cloud Application Default Credentials — not your OCTO_API_KEY — so it lives behind an optional bigquery extra. Sync it from the octogen-dev repository:
This installs the octogen-bq-subscribe CLI (dry-run by default; --apply to subscribe) and the octogen-bq-autosubscribe cron helper for keeping linked datasets current as new listings become available:

subscribe_to_listing

A synchronous function (unlike the async OctogenClient). Idempotent — an existing subscription to the same listing in destination_project is returned as-is. Returns: BigQuerySubscriptionResult with listing_resource, linked_project, linked_dataset, state, already_subscribed, subscription_name, and a ready-to-run sample_query.
Two BigQuery error types extend OctogenError: OctogenBigQueryError (base) and OctogenBigQueryAccessPendingError, raised when Octogen’s IAM grant on the listing hasn’t propagated yet. Because the grant is asynchronous, catch the access-pending error and retry after a few minutes.