keepa 1.4.3__tar.gz → 1.4.4__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.4.3 → keepa-1.4.4}/PKG-INFO +3 -7
- {keepa-1.4.3 → keepa-1.4.4}/README.rst +2 -6
- {keepa-1.4.3 → keepa-1.4.4}/pyproject.toml +4 -4
- {keepa-1.4.3 → keepa-1.4.4}/src/keepa/keepa_async.py +1 -1
- {keepa-1.4.3 → keepa-1.4.4}/src/keepa/keepa_sync.py +41 -10
- {keepa-1.4.3 → keepa-1.4.4}/LICENSE +0 -0
- {keepa-1.4.3 → keepa-1.4.4}/src/keepa/__init__.py +0 -0
- {keepa-1.4.3 → keepa-1.4.4}/src/keepa/constants.py +0 -0
- {keepa-1.4.3 → keepa-1.4.4}/src/keepa/models/domain.py +0 -0
- {keepa-1.4.3 → keepa-1.4.4}/src/keepa/models/product_params.py +0 -0
- {keepa-1.4.3 → keepa-1.4.4}/src/keepa/models/status.py +0 -0
- {keepa-1.4.3 → keepa-1.4.4}/src/keepa/plotting.py +0 -0
- {keepa-1.4.3 → keepa-1.4.4}/src/keepa/py.typed +0 -0
- {keepa-1.4.3 → keepa-1.4.4}/src/keepa/query_keys.py +0 -0
- {keepa-1.4.3 → keepa-1.4.4}/src/keepa/utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: keepa
|
|
3
|
-
Version: 1.4.
|
|
3
|
+
Version: 1.4.4
|
|
4
4
|
Summary: Interfaces with keepa.com's API.
|
|
5
5
|
Keywords: keepa
|
|
6
6
|
Author-email: Alex Kaszynski <akascap@gmail.com>
|
|
@@ -52,14 +52,10 @@ Python keepa Client Library
|
|
|
52
52
|
.. image:: https://codecov.io/gh/akaszynski/keepa/branch/main/graph/badge.svg
|
|
53
53
|
:target: https://codecov.io/gh/akaszynski/keepa
|
|
54
54
|
|
|
55
|
-
.. image:: https://app.codacy.com/project/badge/Grade/9452f99f297c4a6eac14e2d21189ab6f
|
|
56
|
-
:target: https://www.codacy.com/gh/akaszynski/keepa/dashboard?utm_source=github.com&utm_medium=referral&utm_content=akaszynski/keepa&utm_campaign=Badge_Grade
|
|
57
|
-
|
|
58
55
|
|
|
59
56
|
This Python library allows you to interface with the API at `Keepa
|
|
60
|
-
<https://keepa.com/>`_ to query for Amazon product information and
|
|
61
|
-
|
|
62
|
-
a product.
|
|
57
|
+
<https://keepa.com/>`_ to query for Amazon product information and history. It
|
|
58
|
+
also contains a plotting module to allow for plotting of a product.
|
|
63
59
|
|
|
64
60
|
Sign up for `Keepa Data Access <https://get.keepa.com/d7vrq>`_.
|
|
65
61
|
|
|
@@ -14,14 +14,10 @@ Python keepa Client Library
|
|
|
14
14
|
.. image:: https://codecov.io/gh/akaszynski/keepa/branch/main/graph/badge.svg
|
|
15
15
|
:target: https://codecov.io/gh/akaszynski/keepa
|
|
16
16
|
|
|
17
|
-
.. image:: https://app.codacy.com/project/badge/Grade/9452f99f297c4a6eac14e2d21189ab6f
|
|
18
|
-
:target: https://www.codacy.com/gh/akaszynski/keepa/dashboard?utm_source=github.com&utm_medium=referral&utm_content=akaszynski/keepa&utm_campaign=Badge_Grade
|
|
19
|
-
|
|
20
17
|
|
|
21
18
|
This Python library allows you to interface with the API at `Keepa
|
|
22
|
-
<https://keepa.com/>`_ to query for Amazon product information and
|
|
23
|
-
|
|
24
|
-
a product.
|
|
19
|
+
<https://keepa.com/>`_ to query for Amazon product information and history. It
|
|
20
|
+
also contains a plotting module to allow for plotting of a product.
|
|
25
21
|
|
|
26
22
|
Sign up for `Keepa Data Access <https://get.keepa.com/d7vrq>`_.
|
|
27
23
|
|
|
@@ -2,9 +2,6 @@
|
|
|
2
2
|
build-backend = "flit_core.buildapi"
|
|
3
3
|
requires = ["flit_core >=3,<4"]
|
|
4
4
|
|
|
5
|
-
[mypy]
|
|
6
|
-
plugins = "pydantic.mypy"
|
|
7
|
-
|
|
8
5
|
[project]
|
|
9
6
|
authors = [
|
|
10
7
|
{name = "Alex Kaszynski", email = "akascap@gmail.com"}
|
|
@@ -33,7 +30,7 @@ keywords = ["keepa"]
|
|
|
33
30
|
name = "keepa"
|
|
34
31
|
readme = "README.rst"
|
|
35
32
|
requires-python = ">=3.10"
|
|
36
|
-
version = "1.4.
|
|
33
|
+
version = "1.4.4"
|
|
37
34
|
|
|
38
35
|
[project.optional-dependencies]
|
|
39
36
|
doc = [
|
|
@@ -54,6 +51,9 @@ test = [
|
|
|
54
51
|
Documentation = "https://keepaapi.readthedocs.io/en/latest/"
|
|
55
52
|
Source = "https://github.com/akaszynski/keepa"
|
|
56
53
|
|
|
54
|
+
[tool.mypy]
|
|
55
|
+
plugins = "pydantic.mypy"
|
|
56
|
+
|
|
57
57
|
[tool.pytest.ini_options]
|
|
58
58
|
addopts = "--cov=keepa --cov-fail-under=85"
|
|
59
59
|
asyncio_default_fixture_loop_scope = "function"
|
|
@@ -130,7 +130,7 @@ class AsyncKeepa:
|
|
|
130
130
|
|
|
131
131
|
async def update_status(self) -> None:
|
|
132
132
|
"""Update available tokens."""
|
|
133
|
-
|
|
133
|
+
await self._request("token", {"key": self.accesskey}, wait=False)
|
|
134
134
|
|
|
135
135
|
async def wait_for_tokens(self) -> None:
|
|
136
136
|
"""Check if there are any remaining tokens and waits if none are available."""
|
|
@@ -40,9 +40,14 @@ class Keepa:
|
|
|
40
40
|
server has not issued a response for timeout seconds. Setting this to
|
|
41
41
|
0.0 disables the timeout, but will cause any request to hang
|
|
42
42
|
indefiantly should keepa.com be down
|
|
43
|
-
logging_level:
|
|
43
|
+
logging_level: str, default: "DEBUG"
|
|
44
44
|
Logging level to use. Default is "DEBUG". Other options are "INFO",
|
|
45
45
|
"WARNING", "ERROR", and "CRITICAL".
|
|
46
|
+
check_key : bool, default: True
|
|
47
|
+
Check the keepa key on initialization and update the number of
|
|
48
|
+
available tokens. This is a free check and does not cost any tokens,
|
|
49
|
+
but does slow down the time to initialize. Disable this to speed up
|
|
50
|
+
init at the risk of using an invalid key when querying for a product.
|
|
46
51
|
|
|
47
52
|
Examples
|
|
48
53
|
--------
|
|
@@ -81,7 +86,13 @@ class Keepa:
|
|
|
81
86
|
status: Status
|
|
82
87
|
_timeout: float
|
|
83
88
|
|
|
84
|
-
def __init__(
|
|
89
|
+
def __init__(
|
|
90
|
+
self,
|
|
91
|
+
accesskey: str,
|
|
92
|
+
timeout: float = 10.0,
|
|
93
|
+
logging_level: str = "DEBUG",
|
|
94
|
+
check_key: bool = False,
|
|
95
|
+
) -> None:
|
|
85
96
|
"""Initialize server connection."""
|
|
86
97
|
self.accesskey = accesskey
|
|
87
98
|
self.tokens_left = 0
|
|
@@ -93,9 +104,11 @@ class Keepa:
|
|
|
93
104
|
raise TypeError("logging_level must be one of: " + ", ".join(levels))
|
|
94
105
|
log.setLevel(logging_level)
|
|
95
106
|
|
|
96
|
-
#
|
|
107
|
+
# Check available tokens on init
|
|
97
108
|
log.info("Using key ending in %s", accesskey[-6:])
|
|
98
109
|
self.status = Status()
|
|
110
|
+
if check_key:
|
|
111
|
+
self.update_status()
|
|
99
112
|
|
|
100
113
|
@property
|
|
101
114
|
def time_to_refill(self) -> float:
|
|
@@ -114,6 +127,20 @@ class Keepa:
|
|
|
114
127
|
0.0
|
|
115
128
|
|
|
116
129
|
"""
|
|
130
|
+
if (
|
|
131
|
+
self.status.refillRate is None
|
|
132
|
+
or self.status.refillIn is None
|
|
133
|
+
or self.status.timestamp is None
|
|
134
|
+
):
|
|
135
|
+
self.update_status()
|
|
136
|
+
|
|
137
|
+
if (
|
|
138
|
+
self.status.refillRate is None
|
|
139
|
+
or self.status.refillIn is None
|
|
140
|
+
or self.status.timestamp is None
|
|
141
|
+
):
|
|
142
|
+
raise RuntimeError("Failed to update status")
|
|
143
|
+
|
|
117
144
|
# Get current timestamp in milliseconds from UNIX epoch
|
|
118
145
|
now = int(time.time() * 1000)
|
|
119
146
|
time_at_refill = self.status.timestamp + self.status.refillIn
|
|
@@ -130,11 +157,10 @@ class Keepa:
|
|
|
130
157
|
# Return value in seconds
|
|
131
158
|
return time_to_refill / 1000.0
|
|
132
159
|
|
|
133
|
-
def update_status(self) ->
|
|
160
|
+
def update_status(self) -> None:
|
|
134
161
|
"""Update available tokens."""
|
|
135
|
-
|
|
136
|
-
self.
|
|
137
|
-
return status
|
|
162
|
+
# number of available tokens is always returned
|
|
163
|
+
self._request("token", {"key": self.accesskey}, wait=False)
|
|
138
164
|
|
|
139
165
|
def wait_for_tokens(self) -> None:
|
|
140
166
|
"""Check if there are any remaining tokens and waits if none are available."""
|
|
@@ -143,7 +169,7 @@ class Keepa:
|
|
|
143
169
|
# Wait if no tokens available
|
|
144
170
|
if self.tokens_left <= 0:
|
|
145
171
|
tdelay = self.time_to_refill
|
|
146
|
-
log.warning("Waiting %.0f seconds for additional tokens"
|
|
172
|
+
log.warning("Waiting %.0f seconds for additional tokens", tdelay)
|
|
147
173
|
time.sleep(tdelay)
|
|
148
174
|
self.update_status()
|
|
149
175
|
|
|
@@ -632,6 +658,11 @@ class Keepa:
|
|
|
632
658
|
if offers > 100 or offers < 20:
|
|
633
659
|
raise ValueError('Parameter "offers" must be between 20 and 100')
|
|
634
660
|
|
|
661
|
+
if self.status.refillRate is None or self.status.refillIn is None:
|
|
662
|
+
self.update_status()
|
|
663
|
+
if self.status.refillRate is None or self.status.refillIn is None:
|
|
664
|
+
raise RuntimeError("Failed to update status")
|
|
665
|
+
|
|
635
666
|
# Report time to completion
|
|
636
667
|
if self.status.refillRate is not None:
|
|
637
668
|
tcomplete = (
|
|
@@ -797,7 +828,7 @@ class Keepa:
|
|
|
797
828
|
to_datetime = kwargs.pop("to_datetime", True)
|
|
798
829
|
|
|
799
830
|
# Query and replace csv with parsed data if history enabled
|
|
800
|
-
wait = kwargs.get("wait")
|
|
831
|
+
wait = bool(kwargs.get("wait"))
|
|
801
832
|
kwargs.pop("wait", None)
|
|
802
833
|
raw_response = kwargs.pop("raw", False)
|
|
803
834
|
response = self._request("product", kwargs, wait=wait, raw_response=raw_response)
|
|
@@ -956,7 +987,7 @@ class Keepa:
|
|
|
956
987
|
|
|
957
988
|
def search_for_categories(
|
|
958
989
|
self, searchterm: str, domain: str | Domain = "US", wait: bool = True
|
|
959
|
-
) ->
|
|
990
|
+
) -> dict[str, Any]:
|
|
960
991
|
"""
|
|
961
992
|
Search for categories from Amazon.
|
|
962
993
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|