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 Run your code against the synced environment with
octogen-dev repository and is managed with uv. Clone the repository and sync the sdks/python project: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 You can also pass
OCTO_API_KEY environment variable automatically.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:
- The
api_keyconstructor argument, if provided. - The
OCTO_API_KEYenvironment variable.
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
Useasync with to ensure the underlying HTTP connection pool is closed when you are done:
await client.aclose() when finished.
Methods
lookup_product
resolution_mode="index_only" when your integration requires indexed identity and catalog context.
MerchantProductUrlLookupResponse
search_products
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
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:Faceted search
UseFacet objects to filter by brand, gender, color, category, and other attributes. Pass a list of facets to the facets parameter of search_products.
Facet instances — the SDK coerces them automatically:
Pagination
Whennext_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 fromOctogenError. HTTP errors inherit from OctogenAPIError, which exposes status_code, detail, and response attributes.
OctogenAuthenticationError — 401
OctogenAuthenticationError — 401
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.OctogenForbiddenError — 403
OctogenForbiddenError — 403
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.
OctogenNotFoundError — 404
OctogenNotFoundError — 404
Raised when a catalog or product URL cannot be found. For
lookup_product, verify the URL belongs to a catalog your key can access.OctogenValidationError — 422
OctogenValidationError — 422
Raised when the API rejects a request due to invalid parameters. The
detail attribute contains the validation error list from the API.OctogenConnectionError
OctogenConnectionError
Raised when the SDK cannot reach the API — for example, due to a network timeout or DNS failure. Does not have a
status_code.OctogenAPIError to handle all HTTP errors in one place:
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 yourOCTO_API_KEY — so it lives behind an optional bigquery extra. Sync it from the octogen-dev repository:
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
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.