keepa.AsyncKeepa.category_lookup#

async AsyncKeepa.category_lookup(category_id: int, domain: str | Domain = 'US', include_parents: bool = False, wait: bool = True, typed: bool = False) dict[str, dict[str, Any]] | dict[str, Category]#

Return root categories given a categoryId.

Parameters:
category_idint

ID for specific category or 0 to return a list of root categories.

domainstr | keepa.Domain, default: ‘US’

A valid Amazon domain. See keepa.Domain.

include_parentsbool, default: False

Include parents.

waitbool, default: True

Wait for available tokens before querying the keepa backend.

typedbool, default: False

When True, return category values as keepa.models.backend.Category Pydantic models instead of dictionaries.

Returns:
dict[str, dict[str, Any]] | dict[str, Category]

Output format is the same as Keepa.search_for_categories().

Examples

Use 0 to return all root categories.

>>> import keepa
>>> key = "<REAL_KEEPA_KEY>"
>>> api = keepa.Keepa(key)
>>> categories = api.category_lookup(0)

Output the first category.

>>> list(categories.values())[0]
{'domainId': 1,
 'catId': 133140011,
 'name': 'Kindle Store',
 'children': [133141011,
  133143011,
  6766606011,
  7529231011,
  118656435011,
  2268072011,
  119757513011,
  358606011,
  3000677011,
  1293747011],
 'parent': 0,
 'highestRank': 6984155,
 'productCount': 6417325,
 'contextFreeName': 'Kindle Store',
 'lowestRank': 1,
 'matched': True}