keepa.Keepa#
- class keepa.Keepa(accesskey: str, timeout: float = 10.0, logging_level: str = 'DEBUG', check_key: bool = False)#
Synchronous Python interface to keepa data backend.
Initializes API with access key. Access key can be obtained by signing up for a recurring or one-time plan. To obtain a key, sign up for one at Keepa Data.
- Parameters:
- accesskeystr
64 character access key string.
- timeoutfloat, default: 10.0
Default timeout when issuing any request. This is not a time limit on the entire response download; rather, an exception is raised if the server has not issued a response for timeout seconds. Setting this to 0.0 disables the timeout, but will cause any request to hang indefinitely should keepa.com be down
- logging_level: str, default: “DEBUG”
Logging level to use. Default is “DEBUG”. Other options are “INFO”, “WARNING”, “ERROR”, and “CRITICAL”.
- check_keybool, default: True
Check the keepa key on initialization and update the number of available tokens. This is a free check and does not cost any tokens, but does slow down the time to initialize. Disable this to speed up init at the risk of using an invalid key when querying for a product.
Examples
Create the api object.
>>> import keepa >>> key = "<REAL_KEEPA_KEY>" >>> api = keepa.Keepa(key)
Request data from two ASINs.
>>> products = api.query(["0439064872", "1426208081"])
Print item details.
>>> print("Item 1") >>> print("\t ASIN: {:s}".format(products[0]["asin"])) >>> print("\t Title: {:s}".format(products[0]["title"])) Item 1 ASIN: 0439064872 Title: Harry Potter and the Chamber of Secrets (2)
Print item price.
>>> usedprice = products[0]["data"]["USED"] >>> usedtimes = products[0]["data"]["USED_time"] >>> print("\t Used price: ${:.2f}".format(usedprice[-1])) >>> print("\t as of: {:s}".format(str(usedtimes[-1]))) Used price: $0.52 as of: 2023-01-03 04:46:00
- __init__(accesskey: str, timeout: float = 10.0, logging_level: str = 'DEBUG', check_key: bool = False) None#
Initialize server connection.
Methods
__init__(accesskey[, timeout, ...])Initialize server connection.
best_sellers_query(category[, ...])Retrieve an ASIN list of the most popular products.
category_lookup(category_id[, domain, ...])Return root categories given a categoryId.
deals(deal_parms[, domain, wait, typed])Query the Keepa API for product deals.
download_graph_image(asin, filename[, ...])Download the graph image of an ASIN from keepa.
product_finder(product_parms[, domain, ...])Query the keepa product database to find products matching criteria.
query(items[, stats, domain, history, ...])Perform a product query of a list, array, or single ASIN.
search_for_categories(searchterm[, domain, ...])Search for categories from Amazon.
seller_query(seller_id[, domain, ...])Receive seller information for a given seller id or ids.
Update available tokens.
Check if there are any remaining tokens and waits if none are available.
Attributes
Return the time to refill in seconds.
accesskeytokens_leftstatus