waltrack 0.1.0__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.
- waltrack-0.1.0/.gitignore +14 -0
- waltrack-0.1.0/LICENSE +21 -0
- waltrack-0.1.0/PKG-INFO +208 -0
- waltrack-0.1.0/README.md +177 -0
- waltrack-0.1.0/examples/README.md +11 -0
- waltrack-0.1.0/examples/any_endpoint.py +11 -0
- waltrack-0.1.0/examples/async_client.py +14 -0
- waltrack-0.1.0/examples/json_response.py +10 -0
- waltrack-0.1.0/pyproject.toml +79 -0
- waltrack-0.1.0/src/waltrack/__init__.py +59 -0
- waltrack-0.1.0/src/waltrack/_endpoints.py +62 -0
- waltrack-0.1.0/src/waltrack/_operations.py +509 -0
- waltrack-0.1.0/src/waltrack/_response.py +91 -0
- waltrack-0.1.0/src/waltrack/_serialization.py +122 -0
- waltrack-0.1.0/src/waltrack/_version.py +1 -0
- waltrack-0.1.0/src/waltrack/client.py +452 -0
- waltrack-0.1.0/src/waltrack/errors.py +76 -0
- waltrack-0.1.0/src/waltrack/models.py +81 -0
- waltrack-0.1.0/src/waltrack/py.typed +1 -0
- waltrack-0.1.0/tests/__init__.py +1 -0
- waltrack-0.1.0/tests/test_client.py +416 -0
waltrack-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Waltrack
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
waltrack-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: waltrack
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Official Python SDK for the Waltrack Walmart price tracking API.
|
|
5
|
+
Project-URL: Homepage, https://www.waltrack.dev
|
|
6
|
+
Project-URL: Documentation, https://www.waltrack.dev/docs
|
|
7
|
+
Project-URL: Repository, https://github.com/waltrack/waltrack-python
|
|
8
|
+
Project-URL: Issues, https://github.com/waltrack/waltrack-python/issues
|
|
9
|
+
Author-email: Waltrack <contact@waltrack.dev>
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: api,price-history,price-tracking,sdk,walmart,walmart-price-tracker,waltrack
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
20
|
+
Classifier: Topic :: Internet :: WWW/HTTP
|
|
21
|
+
Classifier: Typing :: Typed
|
|
22
|
+
Requires-Python: >=3.11
|
|
23
|
+
Requires-Dist: httpx<1,>=0.27
|
|
24
|
+
Provides-Extra: dev
|
|
25
|
+
Requires-Dist: build<2,>=1.2; extra == 'dev'
|
|
26
|
+
Requires-Dist: mypy>=1.13; extra == 'dev'
|
|
27
|
+
Requires-Dist: pytest-asyncio>=0.24; extra == 'dev'
|
|
28
|
+
Requires-Dist: pytest>=8.3; extra == 'dev'
|
|
29
|
+
Requires-Dist: ruff<1,>=0.8; extra == 'dev'
|
|
30
|
+
Description-Content-Type: text/markdown
|
|
31
|
+
|
|
32
|
+
# Waltrack Python SDK
|
|
33
|
+
|
|
34
|
+
The official Python SDK for the [Waltrack](https://www.waltrack.dev) Walmart price tracking API.
|
|
35
|
+
|
|
36
|
+
Track Walmart prices and products with a scheduled watchlist, price history and alerts.
|
|
37
|
+
|
|
38
|
+
The SDK exposes **9 typed methods**, one per documented endpoint, with blocking and `asyncio` clients built on [HTTPX](https://www.python-httpx.org/), plus a generic `request()`.
|
|
39
|
+
|
|
40
|
+
## Requirements
|
|
41
|
+
|
|
42
|
+
- Python 3.11 or newer
|
|
43
|
+
|
|
44
|
+
## Installation
|
|
45
|
+
|
|
46
|
+
```sh
|
|
47
|
+
pip install waltrack
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Get your API key
|
|
51
|
+
|
|
52
|
+
[Sign up for Waltrack](https://www.waltrack.dev/signup) or sign in, then copy your API key from the [dashboard](https://www.waltrack.dev/app). The client reads the `WALTRACK_API_KEY` environment variable when no key is passed.
|
|
53
|
+
|
|
54
|
+
## Quick start
|
|
55
|
+
|
|
56
|
+
```python
|
|
57
|
+
import os
|
|
58
|
+
|
|
59
|
+
from waltrack import WaltrackClient
|
|
60
|
+
|
|
61
|
+
with WaltrackClient(os.environ["WALTRACK_API_KEY"]) as client:
|
|
62
|
+
response = client.search_walmart(query="air fryer")
|
|
63
|
+
print(response.data)
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Keyword arguments mirror the [API reference](https://www.waltrack.dev/docs). Python keywords get a trailing underscore (`from_=`), and the wire name is used on the request.
|
|
67
|
+
|
|
68
|
+
## Async I/O
|
|
69
|
+
|
|
70
|
+
```python
|
|
71
|
+
import asyncio
|
|
72
|
+
|
|
73
|
+
from waltrack import AsyncWaltrackClient
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
async def main() -> None:
|
|
77
|
+
async with AsyncWaltrackClient() as client:
|
|
78
|
+
response = await client.search_walmart(query="air fryer")
|
|
79
|
+
print(response.data)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
asyncio.run(main())
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## HTTP methods
|
|
86
|
+
|
|
87
|
+
Each method uses the HTTP verb of its endpoint. `GET` and `DELETE` send parameters in the query string; `POST` and `PATCH` send them as a JSON body, except `wait` on `/products/{id}/check`, which stays in the query string. `None` values are never sent, so `update_product(target_price=None)` leaves the target price as it is: `clear_target_price(id=...)` removes it (it sends `{"target_price": null}`).
|
|
88
|
+
|
|
89
|
+
```python
|
|
90
|
+
client.clear_target_price(id="p1")
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
`None` values are omitted, `False` and `0` are sent, and sequences repeat the parameter name.
|
|
94
|
+
|
|
95
|
+
## Any endpoint
|
|
96
|
+
|
|
97
|
+
```python
|
|
98
|
+
response = client.request("GET", "/account")
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Errors
|
|
102
|
+
|
|
103
|
+
```python
|
|
104
|
+
from waltrack import WaltrackAPIError
|
|
105
|
+
|
|
106
|
+
try:
|
|
107
|
+
client.search_walmart(query="air fryer")
|
|
108
|
+
except WaltrackAPIError as error:
|
|
109
|
+
print(error.status, error.error_code, error, error.response_body)
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
| Error | When |
|
|
113
|
+
| --- | --- |
|
|
114
|
+
| `WaltrackConfigurationError` | Missing API key, invalid options, unsupported method, closed client. |
|
|
115
|
+
| `WaltrackSerializationError` | A required parameter is missing or a value can't be sent. |
|
|
116
|
+
| `WaltrackTransportError` | Network failure or timeout. |
|
|
117
|
+
| `WaltrackAPIError` | Non-2xx status (`status`, `error_message`, `error_code`, `response_body`, `raw_response`). `error_code` is the API's `error.code`, such as `insufficient_credits` or `product_limit` (`None` when the body has none). |
|
|
118
|
+
| `WaltrackResponseDecodingError` | A success response could not be decoded. |
|
|
119
|
+
|
|
120
|
+
All of them extend `WaltrackError`.
|
|
121
|
+
|
|
122
|
+
## Retries
|
|
123
|
+
|
|
124
|
+
Requests are retried up to 3 times after a network error, a `408`, `500`, `502`, `503` or `504`. Other statuses, such as `400`, `401`, `402`, `404` or `429`, and client-side timeouts are not retried: the API's rate limits last until the hour (or the day) is over, and on the free plan every retry would count as a request. The delay starts at 1 second and grows 1.5× per retry (capped at 30 seconds); a `Retry-After` header wins.
|
|
125
|
+
|
|
126
|
+
```python
|
|
127
|
+
client = WaltrackClient(max_retries=5, retry_delay=0.5)
|
|
128
|
+
|
|
129
|
+
# or for one request
|
|
130
|
+
client.search_walmart(query="air fryer", request_options=RequestOptions(max_retries=0))
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## Batch requests
|
|
134
|
+
|
|
135
|
+
`batch()` runs a function per item on 10 threads (`concurrency`) and returns one `BatchResult` per item, in input order. A failing item never stops the others. `AsyncWaltrackClient.batch()` does the same with `asyncio`.
|
|
136
|
+
|
|
137
|
+
```python
|
|
138
|
+
inputs = ["air fryer", "wireless earbuds", "robot vacuum"]
|
|
139
|
+
results = client.batch(inputs, lambda query: client.search_walmart(query=query), concurrency=5)
|
|
140
|
+
|
|
141
|
+
for result in results:
|
|
142
|
+
if result.ok:
|
|
143
|
+
print(result.value.data)
|
|
144
|
+
else:
|
|
145
|
+
print(inputs[result.index], result.error)
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
| Constant | Default | Description |
|
|
149
|
+
| --- | --- | --- |
|
|
150
|
+
| `DEFAULT_CONCURRENCY` | `10` | Tasks run at the same time by batch |
|
|
151
|
+
| `DEFAULT_TIMEOUT` | `120.0` | Request timeout (seconds) |
|
|
152
|
+
| `MAX_RETRIES` | `3` | Retry attempts after a network error, a 408/5xx |
|
|
153
|
+
| `RETRY_BACKOFF_FACTOR` | `1.5` | Exponential backoff multiplier |
|
|
154
|
+
| `DEFAULT_RETRY_DELAY` | `1.0` | Delay before the first retry (seconds) |
|
|
155
|
+
|
|
156
|
+
## Timeouts and custom HTTPX clients
|
|
157
|
+
|
|
158
|
+
```python
|
|
159
|
+
import httpx
|
|
160
|
+
|
|
161
|
+
from waltrack import WaltrackClient, RequestOptions
|
|
162
|
+
|
|
163
|
+
client = WaltrackClient(timeout=60) # seconds, default 120, None disables
|
|
164
|
+
client.search_walmart(query="air fryer", request_options=RequestOptions(timeout=30))
|
|
165
|
+
|
|
166
|
+
# Bring your own HTTPX client (proxies, limits, event hooks…). You keep ownership of it.
|
|
167
|
+
http_client = httpx.Client(proxy="http://localhost:8080")
|
|
168
|
+
client = WaltrackClient(http_client=http_client)
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## Endpoints
|
|
172
|
+
|
|
173
|
+
9 methods, generated from the [OpenAPI document](https://www.waltrack.dev/openapi.json), plus `clear_target_price()`.
|
|
174
|
+
|
|
175
|
+
| Method | HTTP | Description |
|
|
176
|
+
| --- | --- | --- |
|
|
177
|
+
| `check_product()` | POST `/products/{id}/check` | Asks for a check right away (1 credit), at most once per 5 minutes; earlier calls return the product unchanged. A paused product has to be… |
|
|
178
|
+
| `clear_target_price()` | PATCH `/products/{id}` | Removes the target price: sends `{"target_price": null}`. |
|
|
179
|
+
| `delete_product()` | DELETE `/products/{id}` | Removes the product and its price history. |
|
|
180
|
+
| `get_account()` | GET `/account` | Your plan, the credits left (monthly allowance and packs), how many products you track and the credits they use per month, the credits each… |
|
|
181
|
+
| `get_item_history()` | GET `/history` | Every price Waltrack read for an item ID on a marketplace over the period, whoever tracks it, oldest first, with the lowest, highest and av… |
|
|
182
|
+
| `get_product()` | GET `/products/{id}` | The product's latest state and every price read of the period, oldest first. The history covers every read of this item ID on this marketpl… |
|
|
183
|
+
| `list_products()` | GET `/products` | Your watchlist, newest first, with each product's latest state and its recent prices (trend). Filter with item_id (and marketplace) to know… |
|
|
184
|
+
| `search_walmart()` | GET `/search` | Walmart search results (sponsored included), to find the item ID of a product. Free, limited to 30 searches per hour. |
|
|
185
|
+
| `track_product()` | POST `/products` | Adds an item ID, a Walmart link or a short link (walmrt.us) to your watchlist. The first check runs in the background within seconds (check… |
|
|
186
|
+
| `update_product()` | PATCH `/products/{id}` | Target price, drop alerts, check interval, or pause. Send only what changes. On the free plan, alerts (price drop, back in stock, target pr… |
|
|
187
|
+
|
|
188
|
+
## All Waltrack SDKs
|
|
189
|
+
|
|
190
|
+
| SDK | Package | Install |
|
|
191
|
+
| --- | --- | --- |
|
|
192
|
+
| Node.js | [`@waltrack/sdk`](https://www.npmjs.com/package/@waltrack/sdk) | `npm install @waltrack/sdk` |
|
|
193
|
+
| Python | [`waltrack`](https://pypi.org/project/waltrack/) | `pip install waltrack` |
|
|
194
|
+
| Go | [`waltrack-go`](https://pkg.go.dev/github.com/waltrack/waltrack-go) | `go get github.com/waltrack/waltrack-go` |
|
|
195
|
+
| .NET | [`Waltrack`](https://www.nuget.org/packages/Waltrack) | `dotnet add package Waltrack` |
|
|
196
|
+
| Ruby | [`waltrack`](https://rubygems.org/gems/waltrack) | `gem install waltrack` |
|
|
197
|
+
| PHP | [`waltrack/sdk`](https://packagist.org/packages/waltrack/sdk) | `composer require waltrack/sdk` |
|
|
198
|
+
| Java | [`waltrack-java`](https://github.com/waltrack/waltrack-java) | build from source, see its README |
|
|
199
|
+
| CLI | [`@waltrack/cli`](https://www.npmjs.com/package/@waltrack/cli) | `npm install -g @waltrack/cli` |
|
|
200
|
+
| MCP server | [`@waltrack/mcp`](https://www.npmjs.com/package/@waltrack/mcp) | `npx -y @waltrack/mcp` |
|
|
201
|
+
|
|
202
|
+
## Trademarks
|
|
203
|
+
|
|
204
|
+
Walmart® is a registered trademark of Walmart Apollo, LLC. Waltrack is not affiliated with, endorsed or sponsored by Walmart.
|
|
205
|
+
|
|
206
|
+
## License
|
|
207
|
+
|
|
208
|
+
MIT — see [LICENSE](LICENSE).
|
waltrack-0.1.0/README.md
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
# Waltrack Python SDK
|
|
2
|
+
|
|
3
|
+
The official Python SDK for the [Waltrack](https://www.waltrack.dev) Walmart price tracking API.
|
|
4
|
+
|
|
5
|
+
Track Walmart prices and products with a scheduled watchlist, price history and alerts.
|
|
6
|
+
|
|
7
|
+
The SDK exposes **9 typed methods**, one per documented endpoint, with blocking and `asyncio` clients built on [HTTPX](https://www.python-httpx.org/), plus a generic `request()`.
|
|
8
|
+
|
|
9
|
+
## Requirements
|
|
10
|
+
|
|
11
|
+
- Python 3.11 or newer
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
pip install waltrack
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Get your API key
|
|
20
|
+
|
|
21
|
+
[Sign up for Waltrack](https://www.waltrack.dev/signup) or sign in, then copy your API key from the [dashboard](https://www.waltrack.dev/app). The client reads the `WALTRACK_API_KEY` environment variable when no key is passed.
|
|
22
|
+
|
|
23
|
+
## Quick start
|
|
24
|
+
|
|
25
|
+
```python
|
|
26
|
+
import os
|
|
27
|
+
|
|
28
|
+
from waltrack import WaltrackClient
|
|
29
|
+
|
|
30
|
+
with WaltrackClient(os.environ["WALTRACK_API_KEY"]) as client:
|
|
31
|
+
response = client.search_walmart(query="air fryer")
|
|
32
|
+
print(response.data)
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Keyword arguments mirror the [API reference](https://www.waltrack.dev/docs). Python keywords get a trailing underscore (`from_=`), and the wire name is used on the request.
|
|
36
|
+
|
|
37
|
+
## Async I/O
|
|
38
|
+
|
|
39
|
+
```python
|
|
40
|
+
import asyncio
|
|
41
|
+
|
|
42
|
+
from waltrack import AsyncWaltrackClient
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
async def main() -> None:
|
|
46
|
+
async with AsyncWaltrackClient() as client:
|
|
47
|
+
response = await client.search_walmart(query="air fryer")
|
|
48
|
+
print(response.data)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
asyncio.run(main())
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## HTTP methods
|
|
55
|
+
|
|
56
|
+
Each method uses the HTTP verb of its endpoint. `GET` and `DELETE` send parameters in the query string; `POST` and `PATCH` send them as a JSON body, except `wait` on `/products/{id}/check`, which stays in the query string. `None` values are never sent, so `update_product(target_price=None)` leaves the target price as it is: `clear_target_price(id=...)` removes it (it sends `{"target_price": null}`).
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
client.clear_target_price(id="p1")
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
`None` values are omitted, `False` and `0` are sent, and sequences repeat the parameter name.
|
|
63
|
+
|
|
64
|
+
## Any endpoint
|
|
65
|
+
|
|
66
|
+
```python
|
|
67
|
+
response = client.request("GET", "/account")
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Errors
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
from waltrack import WaltrackAPIError
|
|
74
|
+
|
|
75
|
+
try:
|
|
76
|
+
client.search_walmart(query="air fryer")
|
|
77
|
+
except WaltrackAPIError as error:
|
|
78
|
+
print(error.status, error.error_code, error, error.response_body)
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
| Error | When |
|
|
82
|
+
| --- | --- |
|
|
83
|
+
| `WaltrackConfigurationError` | Missing API key, invalid options, unsupported method, closed client. |
|
|
84
|
+
| `WaltrackSerializationError` | A required parameter is missing or a value can't be sent. |
|
|
85
|
+
| `WaltrackTransportError` | Network failure or timeout. |
|
|
86
|
+
| `WaltrackAPIError` | Non-2xx status (`status`, `error_message`, `error_code`, `response_body`, `raw_response`). `error_code` is the API's `error.code`, such as `insufficient_credits` or `product_limit` (`None` when the body has none). |
|
|
87
|
+
| `WaltrackResponseDecodingError` | A success response could not be decoded. |
|
|
88
|
+
|
|
89
|
+
All of them extend `WaltrackError`.
|
|
90
|
+
|
|
91
|
+
## Retries
|
|
92
|
+
|
|
93
|
+
Requests are retried up to 3 times after a network error, a `408`, `500`, `502`, `503` or `504`. Other statuses, such as `400`, `401`, `402`, `404` or `429`, and client-side timeouts are not retried: the API's rate limits last until the hour (or the day) is over, and on the free plan every retry would count as a request. The delay starts at 1 second and grows 1.5× per retry (capped at 30 seconds); a `Retry-After` header wins.
|
|
94
|
+
|
|
95
|
+
```python
|
|
96
|
+
client = WaltrackClient(max_retries=5, retry_delay=0.5)
|
|
97
|
+
|
|
98
|
+
# or for one request
|
|
99
|
+
client.search_walmart(query="air fryer", request_options=RequestOptions(max_retries=0))
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Batch requests
|
|
103
|
+
|
|
104
|
+
`batch()` runs a function per item on 10 threads (`concurrency`) and returns one `BatchResult` per item, in input order. A failing item never stops the others. `AsyncWaltrackClient.batch()` does the same with `asyncio`.
|
|
105
|
+
|
|
106
|
+
```python
|
|
107
|
+
inputs = ["air fryer", "wireless earbuds", "robot vacuum"]
|
|
108
|
+
results = client.batch(inputs, lambda query: client.search_walmart(query=query), concurrency=5)
|
|
109
|
+
|
|
110
|
+
for result in results:
|
|
111
|
+
if result.ok:
|
|
112
|
+
print(result.value.data)
|
|
113
|
+
else:
|
|
114
|
+
print(inputs[result.index], result.error)
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
| Constant | Default | Description |
|
|
118
|
+
| --- | --- | --- |
|
|
119
|
+
| `DEFAULT_CONCURRENCY` | `10` | Tasks run at the same time by batch |
|
|
120
|
+
| `DEFAULT_TIMEOUT` | `120.0` | Request timeout (seconds) |
|
|
121
|
+
| `MAX_RETRIES` | `3` | Retry attempts after a network error, a 408/5xx |
|
|
122
|
+
| `RETRY_BACKOFF_FACTOR` | `1.5` | Exponential backoff multiplier |
|
|
123
|
+
| `DEFAULT_RETRY_DELAY` | `1.0` | Delay before the first retry (seconds) |
|
|
124
|
+
|
|
125
|
+
## Timeouts and custom HTTPX clients
|
|
126
|
+
|
|
127
|
+
```python
|
|
128
|
+
import httpx
|
|
129
|
+
|
|
130
|
+
from waltrack import WaltrackClient, RequestOptions
|
|
131
|
+
|
|
132
|
+
client = WaltrackClient(timeout=60) # seconds, default 120, None disables
|
|
133
|
+
client.search_walmart(query="air fryer", request_options=RequestOptions(timeout=30))
|
|
134
|
+
|
|
135
|
+
# Bring your own HTTPX client (proxies, limits, event hooks…). You keep ownership of it.
|
|
136
|
+
http_client = httpx.Client(proxy="http://localhost:8080")
|
|
137
|
+
client = WaltrackClient(http_client=http_client)
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## Endpoints
|
|
141
|
+
|
|
142
|
+
9 methods, generated from the [OpenAPI document](https://www.waltrack.dev/openapi.json), plus `clear_target_price()`.
|
|
143
|
+
|
|
144
|
+
| Method | HTTP | Description |
|
|
145
|
+
| --- | --- | --- |
|
|
146
|
+
| `check_product()` | POST `/products/{id}/check` | Asks for a check right away (1 credit), at most once per 5 minutes; earlier calls return the product unchanged. A paused product has to be… |
|
|
147
|
+
| `clear_target_price()` | PATCH `/products/{id}` | Removes the target price: sends `{"target_price": null}`. |
|
|
148
|
+
| `delete_product()` | DELETE `/products/{id}` | Removes the product and its price history. |
|
|
149
|
+
| `get_account()` | GET `/account` | Your plan, the credits left (monthly allowance and packs), how many products you track and the credits they use per month, the credits each… |
|
|
150
|
+
| `get_item_history()` | GET `/history` | Every price Waltrack read for an item ID on a marketplace over the period, whoever tracks it, oldest first, with the lowest, highest and av… |
|
|
151
|
+
| `get_product()` | GET `/products/{id}` | The product's latest state and every price read of the period, oldest first. The history covers every read of this item ID on this marketpl… |
|
|
152
|
+
| `list_products()` | GET `/products` | Your watchlist, newest first, with each product's latest state and its recent prices (trend). Filter with item_id (and marketplace) to know… |
|
|
153
|
+
| `search_walmart()` | GET `/search` | Walmart search results (sponsored included), to find the item ID of a product. Free, limited to 30 searches per hour. |
|
|
154
|
+
| `track_product()` | POST `/products` | Adds an item ID, a Walmart link or a short link (walmrt.us) to your watchlist. The first check runs in the background within seconds (check… |
|
|
155
|
+
| `update_product()` | PATCH `/products/{id}` | Target price, drop alerts, check interval, or pause. Send only what changes. On the free plan, alerts (price drop, back in stock, target pr… |
|
|
156
|
+
|
|
157
|
+
## All Waltrack SDKs
|
|
158
|
+
|
|
159
|
+
| SDK | Package | Install |
|
|
160
|
+
| --- | --- | --- |
|
|
161
|
+
| Node.js | [`@waltrack/sdk`](https://www.npmjs.com/package/@waltrack/sdk) | `npm install @waltrack/sdk` |
|
|
162
|
+
| Python | [`waltrack`](https://pypi.org/project/waltrack/) | `pip install waltrack` |
|
|
163
|
+
| Go | [`waltrack-go`](https://pkg.go.dev/github.com/waltrack/waltrack-go) | `go get github.com/waltrack/waltrack-go` |
|
|
164
|
+
| .NET | [`Waltrack`](https://www.nuget.org/packages/Waltrack) | `dotnet add package Waltrack` |
|
|
165
|
+
| Ruby | [`waltrack`](https://rubygems.org/gems/waltrack) | `gem install waltrack` |
|
|
166
|
+
| PHP | [`waltrack/sdk`](https://packagist.org/packages/waltrack/sdk) | `composer require waltrack/sdk` |
|
|
167
|
+
| Java | [`waltrack-java`](https://github.com/waltrack/waltrack-java) | build from source, see its README |
|
|
168
|
+
| CLI | [`@waltrack/cli`](https://www.npmjs.com/package/@waltrack/cli) | `npm install -g @waltrack/cli` |
|
|
169
|
+
| MCP server | [`@waltrack/mcp`](https://www.npmjs.com/package/@waltrack/mcp) | `npx -y @waltrack/mcp` |
|
|
170
|
+
|
|
171
|
+
## Trademarks
|
|
172
|
+
|
|
173
|
+
Walmart® is a registered trademark of Walmart Apollo, LLC. Waltrack is not affiliated with, endorsed or sponsored by Walmart.
|
|
174
|
+
|
|
175
|
+
## License
|
|
176
|
+
|
|
177
|
+
MIT — see [LICENSE](LICENSE).
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Examples
|
|
2
|
+
|
|
3
|
+
```sh
|
|
4
|
+
pip install waltrack
|
|
5
|
+
export WALTRACK_API_KEY="YOUR_API_KEY"
|
|
6
|
+
python examples/json_response.py
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
- `json_response.py` — call the featured endpoint and print the JSON result.
|
|
10
|
+
- `async_client.py` — use `AsyncWaltrackClient`.
|
|
11
|
+
- `any_endpoint.py` — call any path with `request()` and handle API errors.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"""Call any path with request() and handle API errors."""
|
|
2
|
+
|
|
3
|
+
from waltrack import JsonResponse, WaltrackAPIError, WaltrackClient
|
|
4
|
+
|
|
5
|
+
with WaltrackClient() as client: # reads WALTRACK_API_KEY
|
|
6
|
+
try:
|
|
7
|
+
response = client.request("GET", "/account")
|
|
8
|
+
if isinstance(response, JsonResponse):
|
|
9
|
+
print(response.data)
|
|
10
|
+
except WaltrackAPIError as error:
|
|
11
|
+
print(f"HTTP {error.status}: {error}")
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"""Use the asyncio client."""
|
|
2
|
+
|
|
3
|
+
import asyncio
|
|
4
|
+
|
|
5
|
+
from waltrack import AsyncWaltrackClient
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
async def main() -> None:
|
|
9
|
+
async with AsyncWaltrackClient() as client: # reads WALTRACK_API_KEY
|
|
10
|
+
response = await client.search_walmart(query="air fryer")
|
|
11
|
+
print(response.data)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
asyncio.run(main())
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"""Call the featured endpoint and print the JSON result."""
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
import os
|
|
5
|
+
|
|
6
|
+
from waltrack import WaltrackClient
|
|
7
|
+
|
|
8
|
+
with WaltrackClient(os.environ["WALTRACK_API_KEY"]) as client:
|
|
9
|
+
response = client.search_walmart(query="air fryer")
|
|
10
|
+
print(json.dumps(response.data, indent=2))
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling>=1.26,<2"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "waltrack"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Official Python SDK for the Waltrack Walmart price tracking API."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.11"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
license-files = ["LICENSE"]
|
|
13
|
+
authors = [
|
|
14
|
+
{ name = "Waltrack", email = "contact@waltrack.dev" },
|
|
15
|
+
]
|
|
16
|
+
keywords = [
|
|
17
|
+
"walmart",
|
|
18
|
+
"price-tracking",
|
|
19
|
+
"price-history",
|
|
20
|
+
"walmart-price-tracker",
|
|
21
|
+
"api",
|
|
22
|
+
"sdk",
|
|
23
|
+
"waltrack",
|
|
24
|
+
]
|
|
25
|
+
classifiers = [
|
|
26
|
+
"Intended Audience :: Developers",
|
|
27
|
+
"Operating System :: OS Independent",
|
|
28
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
29
|
+
"Programming Language :: Python :: 3.11",
|
|
30
|
+
"Programming Language :: Python :: 3.12",
|
|
31
|
+
"Programming Language :: Python :: 3.13",
|
|
32
|
+
"Programming Language :: Python :: 3.14",
|
|
33
|
+
"Topic :: Internet :: WWW/HTTP",
|
|
34
|
+
"Typing :: Typed",
|
|
35
|
+
]
|
|
36
|
+
dependencies = [
|
|
37
|
+
"httpx>=0.27,<1",
|
|
38
|
+
]
|
|
39
|
+
|
|
40
|
+
[project.optional-dependencies]
|
|
41
|
+
dev = [
|
|
42
|
+
"build>=1.2,<2",
|
|
43
|
+
"mypy>=1.13",
|
|
44
|
+
"pytest>=8.3",
|
|
45
|
+
"pytest-asyncio>=0.24",
|
|
46
|
+
"ruff>=0.8,<1",
|
|
47
|
+
]
|
|
48
|
+
|
|
49
|
+
[project.urls]
|
|
50
|
+
Homepage = "https://www.waltrack.dev"
|
|
51
|
+
Documentation = "https://www.waltrack.dev/docs"
|
|
52
|
+
Repository = "https://github.com/waltrack/waltrack-python"
|
|
53
|
+
Issues = "https://github.com/waltrack/waltrack-python/issues"
|
|
54
|
+
|
|
55
|
+
[tool.hatch.build.targets.sdist]
|
|
56
|
+
include = ["/examples", "/src", "/tests", "/LICENSE", "/README.md", "/pyproject.toml"]
|
|
57
|
+
|
|
58
|
+
[tool.hatch.build.targets.wheel]
|
|
59
|
+
packages = ["src/waltrack"]
|
|
60
|
+
|
|
61
|
+
[tool.mypy]
|
|
62
|
+
python_version = "3.11"
|
|
63
|
+
strict = true
|
|
64
|
+
files = ["src", "tests", "examples"]
|
|
65
|
+
|
|
66
|
+
[tool.pytest.ini_options]
|
|
67
|
+
addopts = "-ra"
|
|
68
|
+
asyncio_mode = "strict"
|
|
69
|
+
asyncio_default_fixture_loop_scope = "function"
|
|
70
|
+
testpaths = ["tests"]
|
|
71
|
+
|
|
72
|
+
[tool.ruff]
|
|
73
|
+
target-version = "py311"
|
|
74
|
+
line-length = 100
|
|
75
|
+
src = ["src", "tests", "examples"]
|
|
76
|
+
extend-exclude = ["*.md"]
|
|
77
|
+
|
|
78
|
+
[tool.ruff.lint]
|
|
79
|
+
select = ["E4", "E7", "E9", "F", "I", "UP", "B"]
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"""Official Python SDK for the Waltrack API."""
|
|
2
|
+
|
|
3
|
+
from ._endpoints import ENDPOINTS
|
|
4
|
+
from ._version import __version__
|
|
5
|
+
from .client import (
|
|
6
|
+
DEFAULT_BASE_URL,
|
|
7
|
+
DEFAULT_CONCURRENCY,
|
|
8
|
+
DEFAULT_RETRY_DELAY,
|
|
9
|
+
DEFAULT_TIMEOUT,
|
|
10
|
+
MAX_RETRIES,
|
|
11
|
+
RETRY_BACKOFF_FACTOR,
|
|
12
|
+
AsyncWaltrackClient,
|
|
13
|
+
WaltrackClient,
|
|
14
|
+
)
|
|
15
|
+
from .errors import (
|
|
16
|
+
WaltrackAPIError,
|
|
17
|
+
WaltrackConfigurationError,
|
|
18
|
+
WaltrackError,
|
|
19
|
+
WaltrackResponseDecodingError,
|
|
20
|
+
WaltrackSerializationError,
|
|
21
|
+
WaltrackTransportError,
|
|
22
|
+
)
|
|
23
|
+
from .models import (
|
|
24
|
+
APIResponse,
|
|
25
|
+
BatchResult,
|
|
26
|
+
BinaryResponse,
|
|
27
|
+
EndpointDefinition,
|
|
28
|
+
HTTPMethod,
|
|
29
|
+
JsonResponse,
|
|
30
|
+
RawResponse,
|
|
31
|
+
RequestOptions,
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
__all__ = [
|
|
35
|
+
"APIResponse",
|
|
36
|
+
"AsyncWaltrackClient",
|
|
37
|
+
"BatchResult",
|
|
38
|
+
"BinaryResponse",
|
|
39
|
+
"DEFAULT_BASE_URL",
|
|
40
|
+
"DEFAULT_CONCURRENCY",
|
|
41
|
+
"DEFAULT_RETRY_DELAY",
|
|
42
|
+
"DEFAULT_TIMEOUT",
|
|
43
|
+
"MAX_RETRIES",
|
|
44
|
+
"RETRY_BACKOFF_FACTOR",
|
|
45
|
+
"ENDPOINTS",
|
|
46
|
+
"EndpointDefinition",
|
|
47
|
+
"HTTPMethod",
|
|
48
|
+
"JsonResponse",
|
|
49
|
+
"RawResponse",
|
|
50
|
+
"RequestOptions",
|
|
51
|
+
"WaltrackAPIError",
|
|
52
|
+
"WaltrackClient",
|
|
53
|
+
"WaltrackConfigurationError",
|
|
54
|
+
"WaltrackError",
|
|
55
|
+
"WaltrackResponseDecodingError",
|
|
56
|
+
"WaltrackSerializationError",
|
|
57
|
+
"WaltrackTransportError",
|
|
58
|
+
"__version__",
|
|
59
|
+
]
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"""Generated from the Waltrack OpenAPI document. Do not edit by hand."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from .models import EndpointDefinition
|
|
6
|
+
|
|
7
|
+
ENDPOINTS: dict[str, EndpointDefinition] = {
|
|
8
|
+
"check_product": EndpointDefinition(
|
|
9
|
+
path="/products/{id}/check",
|
|
10
|
+
methods=("POST",),
|
|
11
|
+
response="json",
|
|
12
|
+
required=("id",),
|
|
13
|
+
),
|
|
14
|
+
"delete_product": EndpointDefinition(
|
|
15
|
+
path="/products/{id}",
|
|
16
|
+
methods=("DELETE",),
|
|
17
|
+
response="json",
|
|
18
|
+
required=("id",),
|
|
19
|
+
),
|
|
20
|
+
"get_account": EndpointDefinition(
|
|
21
|
+
path="/account",
|
|
22
|
+
methods=("GET",),
|
|
23
|
+
response="json",
|
|
24
|
+
required=(),
|
|
25
|
+
),
|
|
26
|
+
"get_item_history": EndpointDefinition(
|
|
27
|
+
path="/history",
|
|
28
|
+
methods=("GET",),
|
|
29
|
+
response="json",
|
|
30
|
+
required=("item_id",),
|
|
31
|
+
),
|
|
32
|
+
"get_product": EndpointDefinition(
|
|
33
|
+
path="/products/{id}",
|
|
34
|
+
methods=("GET",),
|
|
35
|
+
response="json",
|
|
36
|
+
required=("id",),
|
|
37
|
+
),
|
|
38
|
+
"list_products": EndpointDefinition(
|
|
39
|
+
path="/products",
|
|
40
|
+
methods=("GET",),
|
|
41
|
+
response="json",
|
|
42
|
+
required=(),
|
|
43
|
+
),
|
|
44
|
+
"search_walmart": EndpointDefinition(
|
|
45
|
+
path="/search",
|
|
46
|
+
methods=("GET",),
|
|
47
|
+
response="json",
|
|
48
|
+
required=("query",),
|
|
49
|
+
),
|
|
50
|
+
"track_product": EndpointDefinition(
|
|
51
|
+
path="/products",
|
|
52
|
+
methods=("POST",),
|
|
53
|
+
response="json",
|
|
54
|
+
required=("product",),
|
|
55
|
+
),
|
|
56
|
+
"update_product": EndpointDefinition(
|
|
57
|
+
path="/products/{id}",
|
|
58
|
+
methods=("PATCH",),
|
|
59
|
+
response="json",
|
|
60
|
+
required=("id",),
|
|
61
|
+
),
|
|
62
|
+
}
|