Interfaces with keepa.com's API.


Keywords
keepa
License
Apache-2.0
Install
pip install keepa==1.3.9

Documentation

Python keepa Client Library

image

image

Documentation Status

image

image

This Python library allows you to interface with the API at Keepa to query for Amazon product information and history. It also contains a plotting module to allow for plotting of a product.

See API pricing at Keepa API.

Documentation can be found on readthedocs at keepa Documentation.

Requirements

This library is compatible with Python >= 3.8 and requires:

  • numpy
  • aiohttp
  • matplotlib
  • tqdm

Product history can be plotted from the raw data when matplotlib is installed.

Interfacing with the keepa requires an access key and a monthly subscription from Keepa API.

Installation

Module can be installed from PyPi with:

pip install keepa

Source code can also be downloaded from GitHub and installed using:

cd keepa
pip install .

Brief Example

Product Price Plot

Product Price Plot

Product Offers Plot

Product Offers Plot

Brief Example using async

Here's an example of obtaining a product and plotting its price and offer history using the keepa.AsyncKeepa class:

Query for product with ASIN 'B0088PUEPK' using the asynchronous keepa interface.

Detailed Examples

Import interface and establish connection to server

Single ASIN query

You can use keepa witch async / await too

Single ASIN query (async)

Multiple ASIN query from List

Multiple ASIN query from numpy array

Products is a list of product data with one entry per successful result from the Keepa server. Each entry is a dictionary containing the same product data available from Amazon.

The raw data is contained within each product result. Raw data is stored as a dictionary with each key paired with its associated time history.

The product history can also be plotted from the module if matplotlib is installed

You can obtain the offers history for an ASIN (or multiple ASINs) using the offers parameter. See the documentation at Request Products for further details.

If you plan to do a lot of simulatneous query, you might want to speedup query using wait=False arguments.

Buy Box Statistics

To load used buy box statistics, you have to enable offers. This example loads in product offers and converts the buy box data into a pandas.DataFrame.

>>> import keepa
>>> key = '<REAL_KEEPA_KEY>'
>>> api = keepa.Keepa(key)
>>> response = api.query('B0088PUEPK', offers=20)
>>> product = response[0]
>>> buybox_info = product['buyBoxUsedHistory']
>>> df = keepa.process_used_buybox(buybox_info)
               datetime         user_id         condition  isFBA
0   2022-11-02 16:46:00  A1QUAC68EAM09F   Used - Like New   True
1   2022-11-13 10:36:00  A18WXU4I7YR6UA  Used - Very Good  False
2   2022-11-15 23:50:00   AYUGEV9WZ4X5O   Used - Like New  False
3   2022-11-17 06:16:00  A18WXU4I7YR6UA  Used - Very Good  False
4   2022-11-17 10:56:00   AYUGEV9WZ4X5O   Used - Like New  False
..                  ...             ...               ...    ...
115 2023-10-23 10:00:00   AYUGEV9WZ4X5O   Used - Like New  False
116 2023-10-25 21:14:00  A1U9HDFCZO1A84   Used - Like New  False
117 2023-10-26 04:08:00   AYUGEV9WZ4X5O   Used - Like New  False
118 2023-10-27 08:14:00  A1U9HDFCZO1A84   Used - Like New  False
119 2023-10-27 12:34:00   AYUGEV9WZ4X5O   Used - Like New  False

Contributing

Contribute to this repository by forking this repository and installing in development mode with:

git clone https://github.com/<USERNAME>/keepa
pip install -e .[test]

You can then add your feature or commit your bug fix and then run your unit testing with:

pytest

Unit testing will automatically enforce minimum code coverage standards.

Next, to ensure your code meets minimum code styling standards, run:

pre-commit run --all-files

Finally, create a pull request from your fork and I'll be sure to review it.

Credits

This Python module, written by Alex Kaszynski and several contribitors, is based on Java code written by Marius Johann, CEO Keepa. Java source is can be found at keepacom/api_backend.

License

Apache License, please see license file. Work is credited to both Alex Kaszynski and Marius Johann.