keepa 1.3.7__tar.gz → 1.3.9__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.7 → keepa-1.3.9}/PKG-INFO +3 -5
- {keepa-1.3.7 → keepa-1.3.9}/README.rst +0 -1
- {keepa-1.3.7 → keepa-1.3.9}/pyproject.toml +5 -7
- {keepa-1.3.7 → keepa-1.3.9}/src/keepa/__init__.py +6 -1
- {keepa-1.3.7 → keepa-1.3.9}/src/keepa/interface.py +86 -71
- {keepa-1.3.7 → keepa-1.3.9}/src/keepa/plotting.py +1 -0
- {keepa-1.3.7 → keepa-1.3.9}/src/keepa/query_keys.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: keepa
|
|
3
|
-
Version: 1.3.
|
|
3
|
+
Version: 1.3.9
|
|
4
4
|
Summary: Interfaces with keepa.com's API.
|
|
5
5
|
Keywords: keepa
|
|
6
6
|
Author-email: Alex Kaszynski <akascap@gmail.com>
|
|
@@ -17,9 +17,8 @@ Classifier: Programming Language :: Python :: 3.12
|
|
|
17
17
|
Requires-Dist: numpy >=1.9.3
|
|
18
18
|
Requires-Dist: requests >=2.2
|
|
19
19
|
Requires-Dist: tqdm
|
|
20
|
-
Requires-Dist: aiohttp
|
|
21
|
-
Requires-Dist:
|
|
22
|
-
Requires-Dist: pandas
|
|
20
|
+
Requires-Dist: aiohttp
|
|
21
|
+
Requires-Dist: pandas <= 3.0
|
|
23
22
|
Requires-Dist: sphinx==6.1.2 ; extra == "doc"
|
|
24
23
|
Requires-Dist: pydata-sphinx-theme==0.14.2 ; extra == "doc"
|
|
25
24
|
Requires-Dist: matplotlib ; extra == "test"
|
|
@@ -328,7 +327,6 @@ Unit testing will automatically enforce minimum code coverage standards.
|
|
|
328
327
|
|
|
329
328
|
Next, to ensure your code meets minimum code styling standards, run::
|
|
330
329
|
|
|
331
|
-
pip install pre-commit
|
|
332
330
|
pre-commit run --all-files
|
|
333
331
|
|
|
334
332
|
Finally, `create a pull request`_ from your fork and I'll be sure to review it.
|
|
@@ -294,7 +294,6 @@ Unit testing will automatically enforce minimum code coverage standards.
|
|
|
294
294
|
|
|
295
295
|
Next, to ensure your code meets minimum code styling standards, run::
|
|
296
296
|
|
|
297
|
-
pip install pre-commit
|
|
298
297
|
pre-commit run --all-files
|
|
299
298
|
|
|
300
299
|
Finally, `create a pull request`_ from your fork and I'll be sure to review it.
|
|
@@ -26,9 +26,8 @@ dependencies = [
|
|
|
26
26
|
"numpy >=1.9.3",
|
|
27
27
|
"requests >=2.2",
|
|
28
28
|
"tqdm",
|
|
29
|
-
"aiohttp
|
|
30
|
-
"
|
|
31
|
-
"pandas",
|
|
29
|
+
"aiohttp",
|
|
30
|
+
"pandas <= 3.0",
|
|
32
31
|
]
|
|
33
32
|
|
|
34
33
|
[project.urls]
|
|
@@ -59,8 +58,7 @@ force_sort_within_sections = true
|
|
|
59
58
|
# Combines "as" imports on the same line
|
|
60
59
|
combine_as_imports = true
|
|
61
60
|
|
|
62
|
-
[tool.
|
|
61
|
+
[tool.ruff]
|
|
63
62
|
line-length = 100
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
exclude='\.eggs|\.git|\.mypy_cache|\.tox|\.venv|_build|buck-out|build|dist|node_modules'
|
|
63
|
+
select = ["E", "F", "W", "I001"] # pyflakes, pycodestyle, isort
|
|
64
|
+
ignore = []
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
"""Keepaapi module."""
|
|
2
2
|
|
|
3
|
-
__version__ = "1.3.
|
|
3
|
+
__version__ = "1.3.9"
|
|
4
4
|
from keepa.interface import ( # noqa: F401
|
|
5
|
+
DCODES,
|
|
6
|
+
KEEPA_ST_ORDINAL,
|
|
7
|
+
SCODES,
|
|
5
8
|
AsyncKeepa,
|
|
6
9
|
Keepa,
|
|
7
10
|
convert_offer_history,
|
|
11
|
+
csv_indices,
|
|
8
12
|
format_items,
|
|
9
13
|
keepa_minutes_to_time,
|
|
14
|
+
parse_csv,
|
|
10
15
|
process_used_buybox,
|
|
11
16
|
run_and_get,
|
|
12
17
|
)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"""Interface module to download Amazon product and history data from keepa.com."""
|
|
2
|
+
|
|
2
3
|
import asyncio
|
|
3
4
|
import datetime
|
|
4
5
|
import json
|
|
@@ -43,8 +44,8 @@ SCODES = {
|
|
|
43
44
|
|
|
44
45
|
# domain codes
|
|
45
46
|
# Valid values: [ 1: com | 2: co.uk | 3: de | 4: fr | 5:
|
|
46
|
-
# co.jp | 6: ca | 7: cn | 8: it | 9: es | 10: in | 11: com.mx ]
|
|
47
|
-
DCODES = ["RESERVED", "US", "GB", "DE", "FR", "JP", "CA", "CN", "IT", "ES", "IN", "MX"]
|
|
47
|
+
# co.jp | 6: ca | 7: cn | 8: it | 9: es | 10: in | 11: com.mx | 12: com.br ]
|
|
48
|
+
DCODES = ["RESERVED", "US", "GB", "DE", "FR", "JP", "CA", "CN", "IT", "ES", "IN", "MX", "BR"]
|
|
48
49
|
|
|
49
50
|
# csv indices. used when parsing csv and stats fields.
|
|
50
51
|
# https://github.com/keepacom/api_backend
|
|
@@ -364,28 +365,28 @@ class Keepa:
|
|
|
364
365
|
Create the api object.
|
|
365
366
|
|
|
366
367
|
>>> import keepa
|
|
367
|
-
>>> key =
|
|
368
|
+
>>> key = "<REAL_KEEPA_KEY>"
|
|
368
369
|
>>> api = keepa.Keepa(key)
|
|
369
370
|
|
|
370
371
|
Request data from two ASINs.
|
|
371
372
|
|
|
372
|
-
>>> products = api.query([
|
|
373
|
+
>>> products = api.query(["0439064872", "1426208081"])
|
|
373
374
|
|
|
374
375
|
Print item details.
|
|
375
376
|
|
|
376
|
-
>>> print(
|
|
377
|
-
>>> print(
|
|
378
|
-
>>> print(
|
|
377
|
+
>>> print("Item 1")
|
|
378
|
+
>>> print("\t ASIN: {:s}".format(products[0]["asin"]))
|
|
379
|
+
>>> print("\t Title: {:s}".format(products[0]["title"]))
|
|
379
380
|
Item 1
|
|
380
381
|
ASIN: 0439064872
|
|
381
382
|
Title: Harry Potter and the Chamber of Secrets (2)
|
|
382
383
|
|
|
383
384
|
Print item price.
|
|
384
385
|
|
|
385
|
-
>>> usedprice = products[0][
|
|
386
|
-
>>> usedtimes = products[0][
|
|
387
|
-
>>> print(
|
|
388
|
-
>>> print(
|
|
386
|
+
>>> usedprice = products[0]["data"]["USED"]
|
|
387
|
+
>>> usedtimes = products[0]["data"]["USED_time"]
|
|
388
|
+
>>> print("\t Used price: ${:.2f}".format(usedprice[-1]))
|
|
389
|
+
>>> print("\t as of: {:s}".format(str(usedtimes[-1])))
|
|
389
390
|
Used price: $0.52
|
|
390
391
|
as of: 2023-01-03 04:46:00
|
|
391
392
|
|
|
@@ -418,7 +419,7 @@ class Keepa:
|
|
|
418
419
|
should be 0.0 seconds.
|
|
419
420
|
|
|
420
421
|
>>> import keepa
|
|
421
|
-
>>> key =
|
|
422
|
+
>>> key = "<REAL_KEEPA_KEY>"
|
|
422
423
|
>>> api = keepa.Keepa(key)
|
|
423
424
|
>>> api.time_to_refill
|
|
424
425
|
0.0
|
|
@@ -505,9 +506,9 @@ class Keepa:
|
|
|
505
506
|
timestamps (unix epoch time milliseconds) or two date
|
|
506
507
|
strings (ISO8601, with or without time in UTC).
|
|
507
508
|
|
|
508
|
-
domain : str,
|
|
509
|
+
domain : str, default: "US"
|
|
509
510
|
One of the following Amazon domains: RESERVED, US, GB, DE,
|
|
510
|
-
FR, JP, CA, CN, IT, ES, IN, MX
|
|
511
|
+
FR, JP, CA, CN, IT, ES, IN, MX, BR.
|
|
511
512
|
|
|
512
513
|
offers : int, optional
|
|
513
514
|
Adds available offers to product data. Default 0. Must be between
|
|
@@ -738,10 +739,10 @@ class Keepa:
|
|
|
738
739
|
keepa interface.
|
|
739
740
|
|
|
740
741
|
>>> import keepa
|
|
741
|
-
>>> key =
|
|
742
|
+
>>> key = "<REAL_KEEPA_KEY>"
|
|
742
743
|
>>> api = keepa.Keepa(key)
|
|
743
|
-
>>> response = api.query(
|
|
744
|
-
>>> response[0][
|
|
744
|
+
>>> response = api.query("B0088PUEPK")
|
|
745
|
+
>>> response[0]["title"]
|
|
745
746
|
'Western Digital 1TB WD Blue PC Internal Hard Drive HDD - 7200 RPM,
|
|
746
747
|
SATA 6 Gb/s, 64 MB Cache, 3.5" - WD10EZEX'
|
|
747
748
|
|
|
@@ -751,12 +752,12 @@ class Keepa:
|
|
|
751
752
|
>>> import asyncio
|
|
752
753
|
>>> import keepa
|
|
753
754
|
>>> async def main():
|
|
754
|
-
... key =
|
|
755
|
+
... key = "<REAL_KEEPA_KEY>"
|
|
755
756
|
... api = await keepa.AsyncKeepa().create(key)
|
|
756
|
-
... return await api.query(
|
|
757
|
+
... return await api.query("B0088PUEPK")
|
|
757
758
|
...
|
|
758
759
|
>>> response = asyncio.run(main())
|
|
759
|
-
>>> response[0][
|
|
760
|
+
>>> response[0]["title"]
|
|
760
761
|
'Western Digital 1TB WD Blue PC Internal Hard Drive HDD - 7200 RPM,
|
|
761
762
|
SATA 6 Gb/s, 64 MB Cache, 3.5" - WD10EZEX'
|
|
762
763
|
|
|
@@ -764,11 +765,11 @@ class Keepa:
|
|
|
764
765
|
``pandas.DataFrame``.
|
|
765
766
|
|
|
766
767
|
>>> import keepa
|
|
767
|
-
>>> key =
|
|
768
|
+
>>> key = "<REAL_KEEPA_KEY>"
|
|
768
769
|
>>> api = keepa.Keepa(key)
|
|
769
|
-
>>> response = api.query(
|
|
770
|
+
>>> response = api.query("B0088PUEPK", offers=20)
|
|
770
771
|
>>> product = response[0]
|
|
771
|
-
>>> buybox_info = product[
|
|
772
|
+
>>> buybox_info = product["buyBoxUsedHistory"]
|
|
772
773
|
>>> df = keepa.process_used_buybox(buybox_info)
|
|
773
774
|
datetime user_id condition isFBA
|
|
774
775
|
0 2022-11-02 16:46:00 A1QUAC68EAM09F Used - Like New True
|
|
@@ -885,7 +886,7 @@ class Keepa:
|
|
|
885
886
|
|
|
886
887
|
domain : str
|
|
887
888
|
One of the following Amazon domains:
|
|
888
|
-
RESERVED, US, GB, DE, FR, JP, CA, CN, IT, ES, IN, MX
|
|
889
|
+
RESERVED, US, GB, DE, FR, JP, CA, CN, IT, ES, IN, MX, BR.
|
|
889
890
|
|
|
890
891
|
offers : bool, optional
|
|
891
892
|
Adds product offers to product data.
|
|
@@ -1021,10 +1022,9 @@ class Keepa:
|
|
|
1021
1022
|
the best sellers list for. You can find category node ids
|
|
1022
1023
|
via the category search "search_for_categories".
|
|
1023
1024
|
|
|
1024
|
-
domain : str
|
|
1025
|
-
Amazon locale you want to access. Must be one of the following
|
|
1026
|
-
RESERVED, US, GB, DE, FR, JP, CA, CN, IT, ES, IN, MX
|
|
1027
|
-
Default US.
|
|
1025
|
+
domain : str, default: "US"
|
|
1026
|
+
Amazon locale you want to access. Must be one of the following:
|
|
1027
|
+
RESERVED, US, GB, DE, FR, JP, CA, CN, IT, ES, IN, MX, BR.
|
|
1028
1028
|
|
|
1029
1029
|
wait : bool, optional
|
|
1030
1030
|
Wait available token before doing effective query.
|
|
@@ -1040,7 +1040,7 @@ class Keepa:
|
|
|
1040
1040
|
Query for the best sellers among the ``"movies"`` category.
|
|
1041
1041
|
|
|
1042
1042
|
>>> import keepa
|
|
1043
|
-
>>> key =
|
|
1043
|
+
>>> key = "<REAL_KEEPA_KEY>"
|
|
1044
1044
|
>>> api = keepa.Keepa(key)
|
|
1045
1045
|
>>> categories = api.search_for_categories("movies")
|
|
1046
1046
|
>>> category = list(categories.items())[0][0]
|
|
@@ -1060,7 +1060,7 @@ class Keepa:
|
|
|
1060
1060
|
>>> import asyncio
|
|
1061
1061
|
>>> import keepa
|
|
1062
1062
|
>>> async def main():
|
|
1063
|
-
... key =
|
|
1063
|
+
... key = "<REAL_KEEPA_KEY>"
|
|
1064
1064
|
... api = await keepa.AsyncKeepa().create(key)
|
|
1065
1065
|
... categories = await api.search_for_categories("movies")
|
|
1066
1066
|
... category = list(categories.items())[0][0]
|
|
@@ -1077,7 +1077,10 @@ class Keepa:
|
|
|
1077
1077
|
...
|
|
1078
1078
|
|
|
1079
1079
|
"""
|
|
1080
|
-
|
|
1080
|
+
if domain not in DCODES:
|
|
1081
|
+
raise ValueError(
|
|
1082
|
+
f"Invalid domain code {domain}. Should be one of the following:\n{DCODES}"
|
|
1083
|
+
)
|
|
1081
1084
|
|
|
1082
1085
|
payload = {
|
|
1083
1086
|
"key": self.accesskey,
|
|
@@ -1100,10 +1103,9 @@ class Keepa:
|
|
|
1100
1103
|
searchterm : str
|
|
1101
1104
|
Input search term.
|
|
1102
1105
|
|
|
1103
|
-
domain : str, default:
|
|
1104
|
-
Amazon locale you want to access. Must be one of the following
|
|
1105
|
-
RESERVED, US, GB, DE, FR, JP, CA, CN, IT, ES, IN, MX
|
|
1106
|
-
Default US.
|
|
1106
|
+
domain : str, default: "US"
|
|
1107
|
+
Amazon locale you want to access. Must be one of the following:
|
|
1108
|
+
RESERVED, US, GB, DE, FR, JP, CA, CN, IT, ES, IN, MX, BR.
|
|
1107
1109
|
|
|
1108
1110
|
wait : bool, default: True
|
|
1109
1111
|
Wait available token before doing effective query.
|
|
@@ -1120,11 +1122,11 @@ class Keepa:
|
|
|
1120
1122
|
Print all categories from science.
|
|
1121
1123
|
|
|
1122
1124
|
>>> import keepa
|
|
1123
|
-
>>> key =
|
|
1125
|
+
>>> key = "<REAL_KEEPA_KEY>"
|
|
1124
1126
|
>>> api = keepa.Keepa(key)
|
|
1125
|
-
>>> categories = api.search_for_categories(
|
|
1127
|
+
>>> categories = api.search_for_categories("science")
|
|
1126
1128
|
>>> for cat_id in categories:
|
|
1127
|
-
... print(cat_id, categories[cat_id][
|
|
1129
|
+
... print(cat_id, categories[cat_id]["name"])
|
|
1128
1130
|
...
|
|
1129
1131
|
9091159011 Behavioral Sciences
|
|
1130
1132
|
8407535011 Fantasy, Horror & Science Fiction
|
|
@@ -1136,7 +1138,10 @@ class Keepa:
|
|
|
1136
1138
|
144 Science Fiction & Fantasy
|
|
1137
1139
|
|
|
1138
1140
|
"""
|
|
1139
|
-
|
|
1141
|
+
if domain not in DCODES:
|
|
1142
|
+
raise ValueError(
|
|
1143
|
+
f"Invalid domain code {domain}. Should be one of the following:\n{DCODES}"
|
|
1144
|
+
)
|
|
1140
1145
|
|
|
1141
1146
|
payload = {
|
|
1142
1147
|
"key": self.accesskey,
|
|
@@ -1162,9 +1167,8 @@ class Keepa:
|
|
|
1162
1167
|
categories.
|
|
1163
1168
|
|
|
1164
1169
|
domain : str, default: "US"
|
|
1165
|
-
Amazon locale you want to access. Must be one of the following
|
|
1166
|
-
RESERVED, US, GB, DE, FR, JP, CA, CN, IT, ES, IN, MX
|
|
1167
|
-
Default US
|
|
1170
|
+
Amazon locale you want to access. Must be one of the following:
|
|
1171
|
+
RESERVED, US, GB, DE, FR, JP, CA, CN, IT, ES, IN, MX, BR.
|
|
1168
1172
|
|
|
1169
1173
|
include_parents : bool, default: False
|
|
1170
1174
|
Include parents.
|
|
@@ -1182,7 +1186,7 @@ class Keepa:
|
|
|
1182
1186
|
Use 0 to return all root categories.
|
|
1183
1187
|
|
|
1184
1188
|
>>> import keepa
|
|
1185
|
-
>>> key =
|
|
1189
|
+
>>> key = "<REAL_KEEPA_KEY>"
|
|
1186
1190
|
>>> api = keepa.Keepa(key)
|
|
1187
1191
|
>>> categories = api.category_lookup(0)
|
|
1188
1192
|
|
|
@@ -1211,7 +1215,9 @@ class Keepa:
|
|
|
1211
1215
|
|
|
1212
1216
|
"""
|
|
1213
1217
|
if domain not in DCODES:
|
|
1214
|
-
raise ValueError(
|
|
1218
|
+
raise ValueError(
|
|
1219
|
+
f"Invalid domain code {domain}. Should be one of the following:\n{DCODES}"
|
|
1220
|
+
)
|
|
1215
1221
|
|
|
1216
1222
|
payload = {
|
|
1217
1223
|
"key": self.accesskey,
|
|
@@ -1300,10 +1306,10 @@ class Keepa:
|
|
|
1300
1306
|
Return the information from seller ``'A2L77EE7U53NWQ'``.
|
|
1301
1307
|
|
|
1302
1308
|
>>> import keepa
|
|
1303
|
-
>>> key =
|
|
1309
|
+
>>> key = "<REAL_KEEPA_KEY>"
|
|
1304
1310
|
>>> api = keepa.Keepa(key)
|
|
1305
|
-
>>> seller_info = api.seller_query(
|
|
1306
|
-
>>> seller_info[
|
|
1311
|
+
>>> seller_info = api.seller_query("A2L77EE7U53NWQ", "US")
|
|
1312
|
+
>>> seller_info["A2L77EE7U53NWQ"]["sellerName"]
|
|
1307
1313
|
'Amazon Warehouse'
|
|
1308
1314
|
|
|
1309
1315
|
Notes
|
|
@@ -2376,10 +2382,10 @@ class Keepa:
|
|
|
2376
2382
|
``keepa.Keepa`` class. Sort by current sales.
|
|
2377
2383
|
|
|
2378
2384
|
>>> import keepa
|
|
2379
|
-
>>> api = keepa.Keepa(
|
|
2385
|
+
>>> api = keepa.Keepa("<ENTER_ACTUAL_KEY_HERE>")
|
|
2380
2386
|
>>> product_parms = {
|
|
2381
|
-
...
|
|
2382
|
-
...
|
|
2387
|
+
... "author": "jim butcher",
|
|
2388
|
+
... "sort": ["current_SALES", "asc"],
|
|
2383
2389
|
... }
|
|
2384
2390
|
>>> asins = api.product_finder(product_parms, n_products=100)
|
|
2385
2391
|
>>> asins
|
|
@@ -2396,9 +2402,9 @@ class Keepa:
|
|
|
2396
2402
|
|
|
2397
2403
|
>>> import asyncio
|
|
2398
2404
|
>>> import keepa
|
|
2399
|
-
>>> product_parms = {
|
|
2405
|
+
>>> product_parms = {"author": "jim butcher"}
|
|
2400
2406
|
>>> async def main():
|
|
2401
|
-
... key =
|
|
2407
|
+
... key = "<REAL_KEEPA_KEY>"
|
|
2402
2408
|
... api = await keepa.AsyncKeepa().create(key)
|
|
2403
2409
|
... return await api.product_finder(product_parms)
|
|
2404
2410
|
...
|
|
@@ -2425,7 +2431,7 @@ class Keepa:
|
|
|
2425
2431
|
payload = {
|
|
2426
2432
|
"key": self.accesskey,
|
|
2427
2433
|
"domain": DCODES.index(domain),
|
|
2428
|
-
"selection": json.dumps({**product_parms, **{
|
|
2434
|
+
"selection": json.dumps({**product_parms, **{"perPage": n_products}}),
|
|
2429
2435
|
}
|
|
2430
2436
|
|
|
2431
2437
|
response = self._request("query", payload, wait=wait)
|
|
@@ -2496,7 +2502,7 @@ class Keepa:
|
|
|
2496
2502
|
``keepa.Keepa`` class
|
|
2497
2503
|
|
|
2498
2504
|
>>> import keepa
|
|
2499
|
-
>>> key =
|
|
2505
|
+
>>> key = "<REAL_KEEPA_KEY>"
|
|
2500
2506
|
>>> api = keepa.Keepa(key)
|
|
2501
2507
|
>>> deal_parms = {
|
|
2502
2508
|
... "page": 0,
|
|
@@ -2508,7 +2514,7 @@ class Keepa:
|
|
|
2508
2514
|
|
|
2509
2515
|
Get the title of the first deal.
|
|
2510
2516
|
|
|
2511
|
-
>>> deals[
|
|
2517
|
+
>>> deals["dr"][0]["title"]
|
|
2512
2518
|
'Orange Cream Rooibos, Tea Bags - Vanilla, Orange | Caffeine-Free,
|
|
2513
2519
|
Antioxidant-rich, Hot & Iced | The Spice Hut, First Sip Of Tea'
|
|
2514
2520
|
|
|
@@ -2524,7 +2530,7 @@ class Keepa:
|
|
|
2524
2530
|
... "includeCategories": [16310101],
|
|
2525
2531
|
... }
|
|
2526
2532
|
>>> async def main():
|
|
2527
|
-
... key =
|
|
2533
|
+
... key = "<REAL_KEEPA_KEY>"
|
|
2528
2534
|
... api = await keepa.AsyncKeepa().create(key)
|
|
2529
2535
|
... categories = await api.search_for_categories("movies")
|
|
2530
2536
|
... return await api.deals(deal_parms)
|
|
@@ -2630,9 +2636,9 @@ class AsyncKeepa:
|
|
|
2630
2636
|
|
|
2631
2637
|
>>> import asyncio
|
|
2632
2638
|
>>> import keepa
|
|
2633
|
-
>>> product_parms = {
|
|
2639
|
+
>>> product_parms = {"author": "jim butcher"}
|
|
2634
2640
|
>>> async def main():
|
|
2635
|
-
... key =
|
|
2641
|
+
... key = "<REAL_KEEPA_KEY>"
|
|
2636
2642
|
... api = await keepa.AsyncKeepa().create(key)
|
|
2637
2643
|
... return await api.product_finder(product_parms)
|
|
2638
2644
|
...
|
|
@@ -2652,12 +2658,12 @@ class AsyncKeepa:
|
|
|
2652
2658
|
>>> import asyncio
|
|
2653
2659
|
>>> import keepa
|
|
2654
2660
|
>>> async def main():
|
|
2655
|
-
... key =
|
|
2661
|
+
... key = "<REAL_KEEPA_KEY>"
|
|
2656
2662
|
... api = await keepa.AsyncKeepa().create(key)
|
|
2657
|
-
... return await api.query(
|
|
2663
|
+
... return await api.query("B0088PUEPK")
|
|
2658
2664
|
...
|
|
2659
2665
|
>>> response = asyncio.run(main())
|
|
2660
|
-
>>> response[0][
|
|
2666
|
+
>>> response[0]["title"]
|
|
2661
2667
|
'Western Digital 1TB WD Blue PC Internal Hard Drive HDD - 7200 RPM,
|
|
2662
2668
|
SATA 6 Gb/s, 64 MB Cache, 3.5" - WD10EZEX'
|
|
2663
2669
|
|
|
@@ -2884,7 +2890,10 @@ class AsyncKeepa:
|
|
|
2884
2890
|
@is_documented_by(Keepa.best_sellers_query)
|
|
2885
2891
|
async def best_sellers_query(self, category, rank_avg_range=0, domain="US", wait=True):
|
|
2886
2892
|
"""Documented by Keepa.best_sellers_query."""
|
|
2887
|
-
|
|
2893
|
+
if domain not in DCODES:
|
|
2894
|
+
raise ValueError(
|
|
2895
|
+
f"Invalid domain code {domain}. Should be one of the following:\n{DCODES}"
|
|
2896
|
+
)
|
|
2888
2897
|
|
|
2889
2898
|
payload = {
|
|
2890
2899
|
"key": self.accesskey,
|
|
@@ -2902,7 +2911,10 @@ class AsyncKeepa:
|
|
|
2902
2911
|
@is_documented_by(Keepa.search_for_categories)
|
|
2903
2912
|
async def search_for_categories(self, searchterm, domain="US", wait=True):
|
|
2904
2913
|
"""Documented by Keepa.search_for_categories."""
|
|
2905
|
-
|
|
2914
|
+
if domain not in DCODES:
|
|
2915
|
+
raise ValueError(
|
|
2916
|
+
f"Invalid domain code {domain}. Should be one of the following:\n{DCODES}"
|
|
2917
|
+
)
|
|
2906
2918
|
|
|
2907
2919
|
payload = {
|
|
2908
2920
|
"key": self.accesskey,
|
|
@@ -2922,7 +2934,10 @@ class AsyncKeepa:
|
|
|
2922
2934
|
@is_documented_by(Keepa.category_lookup)
|
|
2923
2935
|
async def category_lookup(self, category_id, domain="US", include_parents=0, wait=True):
|
|
2924
2936
|
"""Documented by Keepa.category_lookup."""
|
|
2925
|
-
|
|
2937
|
+
if domain not in DCODES:
|
|
2938
|
+
raise ValueError(
|
|
2939
|
+
f"Invalid domain code {domain}. Should be one of the following:\n{DCODES}"
|
|
2940
|
+
)
|
|
2926
2941
|
|
|
2927
2942
|
payload = {
|
|
2928
2943
|
"key": self.accesskey,
|
|
@@ -3115,11 +3130,11 @@ def process_used_buybox(buybox_info: List[str]) -> pd.DataFrame:
|
|
|
3115
3130
|
``pandas.DataFrame``.
|
|
3116
3131
|
|
|
3117
3132
|
>>> import keepa
|
|
3118
|
-
>>> key =
|
|
3133
|
+
>>> key = "<REAL_KEEPA_KEY>"
|
|
3119
3134
|
>>> api = keepa.Keepa(key)
|
|
3120
|
-
>>> response = api.query(
|
|
3135
|
+
>>> response = api.query("B0088PUEPK", offers=20)
|
|
3121
3136
|
>>> product = response[0]
|
|
3122
|
-
>>> buybox_info = product[
|
|
3137
|
+
>>> buybox_info = product["buyBoxUsedHistory"]
|
|
3123
3138
|
>>> df = keepa.process_used_buybox(buybox_info)
|
|
3124
3139
|
datetime user_id condition isFBA
|
|
3125
3140
|
0 2022-11-02 16:46:00 A1QUAC68EAM09F Used - Like New True
|
|
@@ -3156,10 +3171,10 @@ def process_used_buybox(buybox_info: List[str]) -> pd.DataFrame:
|
|
|
3156
3171
|
|
|
3157
3172
|
df = pd.DataFrame(
|
|
3158
3173
|
{
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3174
|
+
"datetime": datetime_arr,
|
|
3175
|
+
"user_id": user_id_arr,
|
|
3176
|
+
"condition": condition_arr,
|
|
3177
|
+
"isFBA": isFBA_arr,
|
|
3163
3178
|
}
|
|
3164
3179
|
)
|
|
3165
3180
|
|
|
File without changes
|