keepa.Keepa.search_for_categories#
- Keepa.search_for_categories(searchterm: str, domain: str | Domain = 'US', wait: bool = True, typed: bool = False) dict[str, dict[str, Any]] | dict[str, Category]#
Search for categories from Amazon.
- Parameters:
- searchtermstr
Input search term.
- domainstr | keepa.Domain, default: ‘US’
A valid Amazon domain. See
keepa.Domain.- waitbool, default: True
Wait for available tokens before querying the keepa backend.
- typedbool, default: False
When
True, return category values askeepa.models.backend.CategoryPydantic models instead of dictionaries.
- Returns:
- dict[str, dict[str, Any]] | dict[str, Category]
Categories keyed by category ID. Values are dictionaries by default and
keepa.models.backend.Categorymodels whentyped=True.
Examples
Print all categories from science.
>>> import keepa >>> key = "<REAL_KEEPA_KEY>" >>> api = keepa.Keepa(key) >>> categories = api.search_for_categories("science") >>> for cat_id in categories: ... print(cat_id, categories[cat_id]["name"]) ... 9091159011 Behavioral Sciences 8407535011 Fantasy, Horror & Science Fiction 8407519011 Sciences & Technology 12805 Science & Religion 13445 Astrophysics & Space Science 12038 Science Fiction & Fantasy 3207 Science, Nature & How It Works 144 Science Fiction & Fantasy