Skip to content

catalog_ids: rank several catalogs together - #53

Merged
bruel-gabrielsson merged 3 commits into
devfrom
feat/multi-catalog
Oct 24, 2026
Merged

bruel-gabrielsson merged 3 commits into
devfrom
feat/multi-catalog

Conversation

@bruel-gabrielsson

@bruel-gabrielsson bruel-gabrielsson commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Ranks several catalogs together, on unbox-api's new x-catalog-ids (unbox-api#594).

complete, sections and similar_items, sync and async, take catalog_ids=[...] in place of catalog_id. The first catalog is the request's own.

items = client.complete(history, catalog_ids=["shop", "outlet"])
for item in items:
    print(item.catalog_id, item.id)
  • Item.catalog_id is always filled: the catalog the item comes from, also with a single catalog.
  • Events name their catalog: View("a0", catalog_id="outlet"), CartItem("a0", 1, catalog_id="outlet"). They also accept an Item, which brings its catalog along, so a result can go straight back into a history. An event without one is in the first catalog.
  • An order whose items span catalogs is sent as one order per catalog.
  • similar_items(item, catalog_id=..., catalog_ids=[...]) finds products like one catalog's item across all of them. similar_items also takes filters now.
  • A catalog_id filter picks one catalog's products.
  • CartItem is exported at the top level, so an order line can name its catalog.
  • UNBOXAI_CATALOG_ID sets the default catalog, so calls need no catalog_id. An explicit default_catalog_id= still wins, and without either it stays retail_catalog.

Passing both catalog_id and catalog_ids (except for similar_items), an empty list, or a plain string is a ValueError that says what to pass instead.

The README and docs/catalogs.md ("Several catalogs at once") document it. Tests: tests/test_multi_catalog.py, 14 tests; 188 passed in all. Ruff is clean and mypy is at its baseline.

Insights needs this released (behaviorgpt-insights-app#1); the version is not bumped here.

bruel-gabrielsson and others added 3 commits October 24, 2026 15:45
complete, sections and similar_items take catalog_ids instead of catalog_id
to rank up to 5 catalogs as one, e.g. your own next to retail_catalog. Every
Item now has catalog_id, from the response or the request's catalog, since
an id is unique only within its catalog.

History events name their item's catalog with catalog_id=, or take an Item
of a response, which knows its own; an order of items from several catalogs
is sent as one order per catalog. In filters, catalog_id is the item's
catalog. An item that names a catalog the request does not read is refused
before anything is sent.

Co-authored-by: Cursor <[email protected]>
@bruel-gabrielsson
bruel-gabrielsson merged commit 55cf0f8 into dev Oct 24, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant