keepa 1.3.6__tar.gz → 1.3.8__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
keepa-1.3.8/PKG-INFO ADDED
@@ -0,0 +1,351 @@
1
+ Metadata-Version: 2.1
2
+ Name: keepa
3
+ Version: 1.3.8
4
+ Summary: Interfaces with keepa.com's API.
5
+ Keywords: keepa
6
+ Author-email: Alex Kaszynski <akascap@gmail.com>
7
+ Description-Content-Type: text/x-rst
8
+ Classifier: Development Status :: 5 - Production/Stable
9
+ Classifier: Intended Audience :: End Users/Desktop
10
+ Classifier: Topic :: Database :: Front-Ends
11
+ Classifier: License :: OSI Approved :: Apache Software License
12
+ Classifier: Programming Language :: Python :: 3.8
13
+ Classifier: Programming Language :: Python :: 3.9
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Requires-Dist: numpy >=1.9.3
18
+ Requires-Dist: requests >=2.2
19
+ Requires-Dist: tqdm
20
+ Requires-Dist: aiohttp; python_version!='3.12.*'
21
+ Requires-Dist: aiohttp==3.9.0b0; python_version=='3.12.*'
22
+ Requires-Dist: pandas
23
+ Requires-Dist: sphinx==6.1.2 ; extra == "doc"
24
+ Requires-Dist: pydata-sphinx-theme==0.14.2 ; extra == "doc"
25
+ Requires-Dist: matplotlib ; extra == "test"
26
+ Requires-Dist: pandas ; extra == "test"
27
+ Requires-Dist: pytest-asyncio ; extra == "test"
28
+ Requires-Dist: pytest-cov ; extra == "test"
29
+ Requires-Dist: pytest ; extra == "test"
30
+ Project-URL: Documentation, https://keepaapi.readthedocs.io/en/latest/
31
+ Project-URL: Source, https://github.com/akaszynski/keepa
32
+ Provides-Extra: doc
33
+ Provides-Extra: test
34
+
35
+ Python keepa Client Library
36
+ ===========================
37
+
38
+ .. image:: https://img.shields.io/pypi/v/keepa.svg?logo=python&logoColor=white
39
+ :target: https://pypi.org/project/keepa/
40
+
41
+ .. image:: https://github.com/akaszynski/keepa/actions/workflows/testing-and-deployment.yml/badge.svg
42
+ :target: https://github.com/akaszynski/keepa/actions/workflows/testing-and-deployment.yml
43
+
44
+ .. image:: https://readthedocs.org/projects/keepaapi/badge/?version=latest
45
+ :target: https://keepaapi.readthedocs.io/en/latest/?badge=latest
46
+ :alt: Documentation Status
47
+
48
+ .. image:: https://codecov.io/gh/akaszynski/keepa/branch/main/graph/badge.svg
49
+ :target: https://codecov.io/gh/akaszynski/keepa
50
+
51
+ .. image:: https://app.codacy.com/project/badge/Grade/9452f99f297c4a6eac14e2d21189ab6f
52
+ :target: https://www.codacy.com/gh/akaszynski/keepa/dashboard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=akaszynski/keepa&amp;utm_campaign=Badge_Grade
53
+
54
+
55
+ This Python library allows you to interface with the API at `Keepa
56
+ <https://keepa.com/>`_ to query for Amazon product information and
57
+ history. It also contains a plotting module to allow for plotting of
58
+ a product.
59
+
60
+ See API pricing at `Keepa API <https://keepa.com/#!api>`_.
61
+
62
+ Documentation can be found on readthedocs at `keepa Documentation <https://keepaapi.readthedocs.io/en/latest/>`_.
63
+
64
+
65
+ Requirements
66
+ ------------
67
+ This library is compatible with Python >= 3.8 and requires:
68
+
69
+ - ``numpy``
70
+ - ``aiohttp``
71
+ - ``matplotlib``
72
+ - ``tqdm``
73
+
74
+ Product history can be plotted from the raw data when ``matplotlib``
75
+ is installed.
76
+
77
+ Interfacing with the ``keepa`` requires an access key and a monthly
78
+ subscription from `Keepa API <https://keepa.com/#!api>`_.
79
+
80
+ Installation
81
+ ------------
82
+ Module can be installed from `PyPi <https://pypi.org/project/keepa/>`_ with:
83
+
84
+ .. code::
85
+
86
+ pip install keepa
87
+
88
+
89
+ Source code can also be downloaded from `GitHub
90
+ <https://github.com/akaszynski/keepa>`_ and installed using::
91
+
92
+ cd keepa
93
+ pip install .
94
+
95
+
96
+ Brief Example
97
+ -------------
98
+ .. code:: python
99
+
100
+ import keepa
101
+ accesskey = 'XXXXXXXXXXXXXXXX' # enter real access key here
102
+ api = keepa.Keepa(accesskey)
103
+
104
+ # Single ASIN query
105
+ products = api.query('B0088PUEPK') # returns list of product data
106
+
107
+ # Plot result (requires matplotlib)
108
+ keepa.plot_product(products[0])
109
+
110
+ .. figure:: https://github.com/akaszynski/keepa/raw/main/docs/source/images/Product_Price_Plot.png
111
+ :width: 500pt
112
+
113
+ Product Price Plot
114
+
115
+ .. figure:: https://github.com/akaszynski/keepa/raw/main/docs/source/images/Product_Offer_Plot.png
116
+ :width: 500pt
117
+
118
+ Product Offers Plot
119
+
120
+
121
+ Brief Example using async
122
+ -------------------------
123
+ Here's an example of obtaining a product and plotting its price and
124
+ offer history using the ``keepa.AsyncKeepa`` class:
125
+
126
+ .. code:: python
127
+
128
+ >>> import asyncio
129
+ >>> import keepa
130
+ >>> product_parms = {'author': 'jim butcher'}
131
+ >>> async def main():
132
+ ... key = '<REAL_KEEPA_KEY>'
133
+ ... api = await keepa.AsyncKeepa().create(key)
134
+ ... return await api.product_finder(product_parms)
135
+ >>> asins = asyncio.run(main())
136
+ >>> asins
137
+ ['B000HRMAR2',
138
+ '0578799790',
139
+ 'B07PW1SVHM',
140
+ ...
141
+ 'B003MXM744',
142
+ '0133235750',
143
+ 'B01MXXLJPZ']
144
+
145
+ Query for product with ASIN ``'B0088PUEPK'`` using the asynchronous
146
+ keepa interface.
147
+
148
+ .. code:: python
149
+
150
+ >>> import asyncio
151
+ >>> import keepa
152
+ >>> async def main():
153
+ ... key = '<REAL_KEEPA_KEY>'
154
+ ... api = await keepa.AsyncKeepa().create(key)
155
+ ... return await api.query('B0088PUEPK')
156
+ >>> response = asyncio.run(main())
157
+ >>> response[0]['title']
158
+ 'Western Digital 1TB WD Blue PC Internal Hard Drive HDD - 7200 RPM,
159
+ SATA 6 Gb/s, 64 MB Cache, 3.5" - WD10EZEX'
160
+
161
+
162
+ Detailed Examples
163
+ -----------------
164
+ Import interface and establish connection to server
165
+
166
+ .. code:: python
167
+
168
+ import keepa
169
+ accesskey = 'XXXXXXXXXXXXXXXX' # enter real access key here
170
+ api = keepa.Keepa(accesskey)
171
+
172
+
173
+ Single ASIN query
174
+
175
+ .. code:: python
176
+
177
+ products = api.query('059035342X')
178
+
179
+ # See help(api.query) for available options when querying the API
180
+
181
+
182
+ You can use keepa witch async / await too
183
+
184
+ .. code:: python
185
+
186
+ import keepa
187
+ accesskey = 'XXXXXXXXXXXXXXXX' # enter real access key here
188
+ api = await keepa.AsyncKeepa.create(accesskey)
189
+
190
+
191
+ Single ASIN query (async)
192
+
193
+ .. code:: python
194
+
195
+ products = await api.query('059035342X')
196
+
197
+
198
+ Multiple ASIN query from List
199
+
200
+ .. code:: python
201
+
202
+ asins = ['0022841350', '0022841369', '0022841369', '0022841369']
203
+ products = api.query(asins)
204
+
205
+ Multiple ASIN query from numpy array
206
+
207
+ .. code:: python
208
+
209
+ asins = np.asarray(['0022841350', '0022841369', '0022841369', '0022841369'])
210
+ products = api.query(asins)
211
+
212
+ 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 <http://www.amazon.com>`_.
213
+
214
+ .. code:: python
215
+
216
+ # Available keys
217
+ print(products[0].keys())
218
+
219
+ # Print ASIN and title
220
+ print('ASIN is ' + products[0]['asin'])
221
+ print('Title is ' + products[0]['title'])
222
+
223
+ 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.
224
+
225
+ .. code:: python
226
+
227
+ # Access new price history and associated time data
228
+ newprice = products[0]['data']['NEW']
229
+ newpricetime = products[0]['data']['NEW_time']
230
+
231
+ # Can be plotted with matplotlib using:
232
+ import matplotlib.pyplot as plt
233
+ plt.step(newpricetime, newprice, where='pre')
234
+
235
+ # Keys can be listed by
236
+ print(products[0]['data'].keys())
237
+
238
+ The product history can also be plotted from the module if ``matplotlib`` is installed
239
+
240
+ .. code:: python
241
+
242
+ keepa.plot_product(products[0])
243
+
244
+ You can obtain the offers history for an ASIN (or multiple ASINs) using the ``offers`` parameter. See the documentation at `Request Products <https://keepa.com/#!discuss/t/request-products/110/1>`_ for further details.
245
+
246
+ .. code:: python
247
+
248
+ products = api.query(asins, offers=20)
249
+ product = products[0]
250
+ offers = product['offers']
251
+
252
+ # each offer contains the price history of each offer
253
+ offer = offers[0]
254
+ csv = offer['offerCSV']
255
+
256
+ # convert these values to numpy arrays
257
+ times, prices = keepa.convert_offer_history(csv)
258
+
259
+ # for a list of active offers, see
260
+ indices = product['liveOffersOrder']
261
+
262
+ # with this you can loop through active offers:
263
+ indices = product['liveOffersOrder']
264
+ offer_times = []
265
+ offer_prices = []
266
+ for index in indices:
267
+ csv = offers[index]['offerCSV']
268
+ times, prices = keepa.convert_offer_history(csv)
269
+ offer_times.append(times)
270
+ offer_prices.append(prices)
271
+
272
+ # you can aggregate these using np.hstack or plot at the history individually
273
+ import matplotlib.pyplot as plt
274
+ for i in range(len(offer_prices)):
275
+ plt.step(offer_times[i], offer_prices[i])
276
+ plt.show()
277
+
278
+ If you plan to do a lot of simulatneous query, you might want to speedup query using
279
+ ``wait=False`` arguments.
280
+
281
+ .. code:: python
282
+
283
+ products = await api.query('059035342X', wait=False)
284
+
285
+
286
+ Buy Box Statistics
287
+ ~~~~~~~~~~~~~~~~~~
288
+ To load used buy box statistics, you have to enable ``offers``. This example
289
+ loads in product offers and converts the buy box data into a
290
+ ``pandas.DataFrame``.
291
+
292
+ .. code:: pycon
293
+
294
+ >>> import keepa
295
+ >>> key = '<REAL_KEEPA_KEY>'
296
+ >>> api = keepa.Keepa(key)
297
+ >>> response = api.query('B0088PUEPK', offers=20)
298
+ >>> product = response[0]
299
+ >>> buybox_info = product['buyBoxUsedHistory']
300
+ >>> df = keepa.process_used_buybox(buybox_info)
301
+ datetime user_id condition isFBA
302
+ 0 2022-11-02 16:46:00 A1QUAC68EAM09F Used - Like New True
303
+ 1 2022-11-13 10:36:00 A18WXU4I7YR6UA Used - Very Good False
304
+ 2 2022-11-15 23:50:00 AYUGEV9WZ4X5O Used - Like New False
305
+ 3 2022-11-17 06:16:00 A18WXU4I7YR6UA Used - Very Good False
306
+ 4 2022-11-17 10:56:00 AYUGEV9WZ4X5O Used - Like New False
307
+ .. ... ... ... ...
308
+ 115 2023-10-23 10:00:00 AYUGEV9WZ4X5O Used - Like New False
309
+ 116 2023-10-25 21:14:00 A1U9HDFCZO1A84 Used - Like New False
310
+ 117 2023-10-26 04:08:00 AYUGEV9WZ4X5O Used - Like New False
311
+ 118 2023-10-27 08:14:00 A1U9HDFCZO1A84 Used - Like New False
312
+ 119 2023-10-27 12:34:00 AYUGEV9WZ4X5O Used - Like New False
313
+
314
+ Contributing
315
+ ------------
316
+ Contribute to this repository by forking this repository and installing in
317
+ development mode with::
318
+
319
+ git clone https://github.com/<USERNAME>/keepa
320
+ pip install -e .[test]
321
+
322
+ You can then add your feature or commit your bug fix and then run your unit
323
+ testing with::
324
+
325
+ pytest
326
+
327
+ Unit testing will automatically enforce minimum code coverage standards.
328
+
329
+ Next, to ensure your code meets minimum code styling standards, run::
330
+
331
+ pip install pre-commit
332
+ pre-commit run --all-files
333
+
334
+ Finally, `create a pull request`_ from your fork and I'll be sure to review it.
335
+
336
+
337
+ Credits
338
+ -------
339
+ This Python module, written by Alex Kaszynski and several contribitors, is
340
+ based on Java code written by Marius Johann, CEO Keepa. Java source is can be
341
+ found at `keepacom/api_backend <https://github.com/keepacom/api_backend/>`_.
342
+
343
+
344
+ License
345
+ -------
346
+ Apache License, please see license file. Work is credited to both Alex
347
+ Kaszynski and Marius Johann.
348
+
349
+
350
+ .. _create a pull request: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request
351
+
@@ -30,7 +30,7 @@ Documentation can be found on readthedocs at `keepa Documentation <https://keepa
30
30
 
31
31
  Requirements
32
32
  ------------
33
- This library is compatible with Python >= 3.7 and requires:
33
+ This library is compatible with Python >= 3.8 and requires:
34
34
 
35
35
  - ``numpy``
36
36
  - ``aiohttp``
@@ -41,7 +41,7 @@ Product history can be plotted from the raw data when ``matplotlib``
41
41
  is installed.
42
42
 
43
43
  Interfacing with the ``keepa`` requires an access key and a monthly
44
- subscription from `Keepa API <https://keepa.com/#!api>`_
44
+ subscription from `Keepa API <https://keepa.com/#!api>`_.
45
45
 
46
46
  Installation
47
47
  ------------
@@ -53,8 +53,10 @@ Module can be installed from `PyPi <https://pypi.org/project/keepa/>`_ with:
53
53
 
54
54
 
55
55
  Source code can also be downloaded from `GitHub
56
- <https://github.com/akaszynski/keepa>`_ and installed using:
57
- ``python setup.py install`` or ``pip install .``
56
+ <https://github.com/akaszynski/keepa>`_ and installed using::
57
+
58
+ cd keepa
59
+ pip install .
58
60
 
59
61
 
60
62
  Brief Example
@@ -247,18 +249,45 @@ If you plan to do a lot of simulatneous query, you might want to speedup query u
247
249
  products = await api.query('059035342X', wait=False)
248
250
 
249
251
 
252
+ Buy Box Statistics
253
+ ~~~~~~~~~~~~~~~~~~
254
+ To load used buy box statistics, you have to enable ``offers``. This example
255
+ loads in product offers and converts the buy box data into a
256
+ ``pandas.DataFrame``.
257
+
258
+ .. code:: pycon
259
+
260
+ >>> import keepa
261
+ >>> key = '<REAL_KEEPA_KEY>'
262
+ >>> api = keepa.Keepa(key)
263
+ >>> response = api.query('B0088PUEPK', offers=20)
264
+ >>> product = response[0]
265
+ >>> buybox_info = product['buyBoxUsedHistory']
266
+ >>> df = keepa.process_used_buybox(buybox_info)
267
+ datetime user_id condition isFBA
268
+ 0 2022-11-02 16:46:00 A1QUAC68EAM09F Used - Like New True
269
+ 1 2022-11-13 10:36:00 A18WXU4I7YR6UA Used - Very Good False
270
+ 2 2022-11-15 23:50:00 AYUGEV9WZ4X5O Used - Like New False
271
+ 3 2022-11-17 06:16:00 A18WXU4I7YR6UA Used - Very Good False
272
+ 4 2022-11-17 10:56:00 AYUGEV9WZ4X5O Used - Like New False
273
+ .. ... ... ... ...
274
+ 115 2023-10-23 10:00:00 AYUGEV9WZ4X5O Used - Like New False
275
+ 116 2023-10-25 21:14:00 A1U9HDFCZO1A84 Used - Like New False
276
+ 117 2023-10-26 04:08:00 AYUGEV9WZ4X5O Used - Like New False
277
+ 118 2023-10-27 08:14:00 A1U9HDFCZO1A84 Used - Like New False
278
+ 119 2023-10-27 12:34:00 AYUGEV9WZ4X5O Used - Like New False
279
+
250
280
  Contributing
251
281
  ------------
252
282
  Contribute to this repository by forking this repository and installing in
253
283
  development mode with::
254
284
 
255
285
  git clone https://github.com/<USERNAME>/keepa
256
- pip install -e .
286
+ pip install -e .[test]
257
287
 
258
288
  You can then add your feature or commit your bug fix and then run your unit
259
289
  testing with::
260
290
 
261
- pip install requirements_test.txt
262
291
  pytest
263
292
 
264
293
  Unit testing will automatically enforce minimum code coverage standards.
@@ -0,0 +1,70 @@
1
+ [build-system]
2
+ requires = ["flit_core >=3,<4"]
3
+ build-backend = "flit_core.buildapi"
4
+
5
+ [project]
6
+ name = "keepa"
7
+ dynamic = ["version"]
8
+ description = "Interfaces with keepa.com's API."
9
+ readme = "README.rst"
10
+ authors = [
11
+ {name = "Alex Kaszynski", email = "akascap@gmail.com"}
12
+ ]
13
+ classifiers = [
14
+ "Development Status :: 5 - Production/Stable",
15
+ "Intended Audience :: End Users/Desktop",
16
+ "Topic :: Database :: Front-Ends",
17
+ "License :: OSI Approved :: Apache Software License",
18
+ "Programming Language :: Python :: 3.8",
19
+ "Programming Language :: Python :: 3.9",
20
+ "Programming Language :: Python :: 3.10",
21
+ "Programming Language :: Python :: 3.11",
22
+ "Programming Language :: Python :: 3.12",
23
+ ]
24
+ keywords = ["keepa"]
25
+ dependencies = [
26
+ "numpy >=1.9.3",
27
+ "requests >=2.2",
28
+ "tqdm",
29
+ "aiohttp; python_version!='3.12.*'",
30
+ "aiohttp==3.9.0b0; python_version=='3.12.*'", # until aiohttp gets upgraded
31
+ "pandas",
32
+ ]
33
+
34
+ [project.urls]
35
+ Documentation = "https://keepaapi.readthedocs.io/en/latest/"
36
+ Source = "https://github.com/akaszynski/keepa"
37
+
38
+ [project.optional-dependencies]
39
+ test = [
40
+ "matplotlib",
41
+ "pandas",
42
+ "pytest-asyncio",
43
+ "pytest-cov",
44
+ "pytest",
45
+ ]
46
+ doc = [
47
+ "sphinx==6.1.2",
48
+ "pydata-sphinx-theme==0.14.2",
49
+ ]
50
+
51
+ [tool.pytest.ini_options]
52
+ addopts = "--cov=keepa --cov-fail-under=85"
53
+
54
+ [tool.isort]
55
+ profile = 'black'
56
+ line_length = 100
57
+ # Sort by name, don't cluster "from" vs "import"
58
+ force_sort_within_sections = true
59
+ # Combines "as" imports on the same line
60
+ combine_as_imports = true
61
+
62
+ [tool.ruff]
63
+ line-length = 100
64
+
65
+ [tool.ruff.lint]
66
+ # Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default.
67
+ # Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or
68
+ # McCabe complexity (`C901`) by default.
69
+ select = ["E4", "E7", "E9", "F"]
70
+ ignore = []
@@ -0,0 +1,18 @@
1
+ """Keepaapi module."""
2
+
3
+ __version__ = "1.3.8"
4
+ from keepa.interface import ( # noqa: F401
5
+ DCODES,
6
+ KEEPA_ST_ORDINAL,
7
+ SCODES,
8
+ AsyncKeepa,
9
+ Keepa,
10
+ convert_offer_history,
11
+ csv_indices,
12
+ format_items,
13
+ keepa_minutes_to_time,
14
+ parse_csv,
15
+ process_used_buybox,
16
+ run_and_get,
17
+ )
18
+ from keepa.plotting import plot_product # noqa: F401