zaltrack 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.
- zaltrack-0.1.0/.gitignore +14 -0
- zaltrack-0.1.0/LICENSE +21 -0
- zaltrack-0.1.0/PKG-INFO +208 -0
- zaltrack-0.1.0/README.md +177 -0
- zaltrack-0.1.0/examples/README.md +11 -0
- zaltrack-0.1.0/examples/any_endpoint.py +11 -0
- zaltrack-0.1.0/examples/async_client.py +14 -0
- zaltrack-0.1.0/examples/json_response.py +10 -0
- zaltrack-0.1.0/pyproject.toml +79 -0
- zaltrack-0.1.0/src/zaltrack/__init__.py +59 -0
- zaltrack-0.1.0/src/zaltrack/_endpoints.py +62 -0
- zaltrack-0.1.0/src/zaltrack/_operations.py +509 -0
- zaltrack-0.1.0/src/zaltrack/_response.py +91 -0
- zaltrack-0.1.0/src/zaltrack/_serialization.py +122 -0
- zaltrack-0.1.0/src/zaltrack/_version.py +1 -0
- zaltrack-0.1.0/src/zaltrack/client.py +452 -0
- zaltrack-0.1.0/src/zaltrack/errors.py +76 -0
- zaltrack-0.1.0/src/zaltrack/models.py +81 -0
- zaltrack-0.1.0/src/zaltrack/py.typed +1 -0
- zaltrack-0.1.0/tests/__init__.py +1 -0
- zaltrack-0.1.0/tests/test_client.py +416 -0
zaltrack-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ZalTrack
|
|
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.
|
zaltrack-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: zaltrack
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Official Python SDK for the ZalTrack Zalando price tracking API.
|
|
5
|
+
Project-URL: Homepage, https://www.zaltrack.dev
|
|
6
|
+
Project-URL: Documentation, https://www.zaltrack.dev/docs
|
|
7
|
+
Project-URL: Repository, https://github.com/zaltrackdev/zaltrack-python
|
|
8
|
+
Project-URL: Issues, https://github.com/zaltrackdev/zaltrack-python/issues
|
|
9
|
+
Author-email: ZalTrack <contact@zaltrack.dev>
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: api,fashion,price-history,price-tracking,sdk,zalando,zaltrack
|
|
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
|
+
# ZalTrack Python SDK
|
|
33
|
+
|
|
34
|
+
The official Python SDK for the [ZalTrack](https://www.zaltrack.dev) Zalando price tracking API.
|
|
35
|
+
|
|
36
|
+
Track Zalando 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 zaltrack
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Get your API key
|
|
51
|
+
|
|
52
|
+
[Sign up for ZalTrack](https://www.zaltrack.dev/signup) or sign in, then copy your API key from the [dashboard](https://www.zaltrack.dev/app). The client reads the `ZALTRACK_API_KEY` environment variable when no key is passed.
|
|
53
|
+
|
|
54
|
+
## Quick start
|
|
55
|
+
|
|
56
|
+
```python
|
|
57
|
+
import os
|
|
58
|
+
|
|
59
|
+
from zaltrack import ZalTrackClient
|
|
60
|
+
|
|
61
|
+
with ZalTrackClient(os.environ["ZALTRACK_API_KEY"]) as client:
|
|
62
|
+
response = client.search_zalando(query="nike trainers")
|
|
63
|
+
print(response.data)
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Keyword arguments mirror the [API reference](https://www.zaltrack.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 zaltrack import AsyncZalTrackClient
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
async def main() -> None:
|
|
77
|
+
async with AsyncZalTrackClient() as client:
|
|
78
|
+
response = await client.search_zalando(query="nike trainers")
|
|
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 zaltrack import ZalTrackAPIError
|
|
105
|
+
|
|
106
|
+
try:
|
|
107
|
+
client.search_zalando(query="nike trainers")
|
|
108
|
+
except ZalTrackAPIError as error:
|
|
109
|
+
print(error.status, error.error_code, error, error.response_body)
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
| Error | When |
|
|
113
|
+
| --- | --- |
|
|
114
|
+
| `ZalTrackConfigurationError` | Missing API key, invalid options, unsupported method, closed client. |
|
|
115
|
+
| `ZalTrackSerializationError` | A required parameter is missing or a value can't be sent. |
|
|
116
|
+
| `ZalTrackTransportError` | Network failure or timeout. |
|
|
117
|
+
| `ZalTrackAPIError` | 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
|
+
| `ZalTrackResponseDecodingError` | A success response could not be decoded. |
|
|
119
|
+
|
|
120
|
+
All of them extend `ZalTrackError`.
|
|
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 = ZalTrackClient(max_retries=5, retry_delay=0.5)
|
|
128
|
+
|
|
129
|
+
# or for one request
|
|
130
|
+
client.search_zalando(query="nike trainers", 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. `AsyncZalTrackClient.batch()` does the same with `asyncio`.
|
|
136
|
+
|
|
137
|
+
```python
|
|
138
|
+
inputs = ["nike trainers", "rain jacket", "leather boots"]
|
|
139
|
+
results = client.batch(inputs, lambda query: client.search_zalando(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 zaltrack import ZalTrackClient, RequestOptions
|
|
162
|
+
|
|
163
|
+
client = ZalTrackClient(timeout=60) # seconds, default 120, None disables
|
|
164
|
+
client.search_zalando(query="nike trainers", 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 = ZalTrackClient(http_client=http_client)
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## Endpoints
|
|
172
|
+
|
|
173
|
+
9 methods, generated from the [OpenAPI document](https://www.zaltrack.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_article_history()` | GET `/history` | Every price ZalTrack read for an article reference on a marketplace over the period, whoever tracks it, oldest first, with the lowest, high… |
|
|
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 article reference on thi… |
|
|
183
|
+
| `list_products()` | GET `/products` | Your watchlist, newest first, with each product's latest state and its recent prices (trend). Filter with article_id (and marketplace) to k… |
|
|
184
|
+
| `search_zalando()` | GET `/search` | Zalando search results (sponsored included), to find the article reference of a product. Free, limited to 30 searches per hour. |
|
|
185
|
+
| `track_product()` | POST `/products` | Adds an article reference or a Zalando link to your watchlist. The first check runs in the background within seconds (checking is true unti… |
|
|
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 ZalTrack SDKs
|
|
189
|
+
|
|
190
|
+
| SDK | Package | Install |
|
|
191
|
+
| --- | --- | --- |
|
|
192
|
+
| Node.js | [`@zaltrack/sdk`](https://www.npmjs.com/package/@zaltrack/sdk) | `npm install @zaltrack/sdk` |
|
|
193
|
+
| Python | [`zaltrack`](https://pypi.org/project/zaltrack/) | `pip install zaltrack` |
|
|
194
|
+
| Go | [`zaltrack-go`](https://pkg.go.dev/github.com/zaltrackdev/zaltrack-go) | `go get github.com/zaltrackdev/zaltrack-go` |
|
|
195
|
+
| .NET | [`ZalTrack`](https://www.nuget.org/packages/ZalTrack) | `dotnet add package ZalTrack` |
|
|
196
|
+
| Ruby | [`zaltrack`](https://rubygems.org/gems/zaltrack) | `gem install zaltrack` |
|
|
197
|
+
| PHP | [`zaltrack/sdk`](https://packagist.org/packages/zaltrack/sdk) | `composer require zaltrack/sdk` |
|
|
198
|
+
| Java | [`zaltrack-java`](https://github.com/zaltrackdev/zaltrack-java) | build from source, see its README |
|
|
199
|
+
| CLI | [`@zaltrack/cli`](https://www.npmjs.com/package/@zaltrack/cli) | `npm install -g @zaltrack/cli` |
|
|
200
|
+
| MCP server | [`@zaltrack/mcp`](https://www.npmjs.com/package/@zaltrack/mcp) | `npx -y @zaltrack/mcp` |
|
|
201
|
+
|
|
202
|
+
## Trademarks
|
|
203
|
+
|
|
204
|
+
ZALANDO® is a registered trademark of Zalando SE. ZalTrack is not affiliated with, endorsed or sponsored by Zalando.
|
|
205
|
+
|
|
206
|
+
## License
|
|
207
|
+
|
|
208
|
+
MIT — see [LICENSE](LICENSE).
|
zaltrack-0.1.0/README.md
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
# ZalTrack Python SDK
|
|
2
|
+
|
|
3
|
+
The official Python SDK for the [ZalTrack](https://www.zaltrack.dev) Zalando price tracking API.
|
|
4
|
+
|
|
5
|
+
Track Zalando 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 zaltrack
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Get your API key
|
|
20
|
+
|
|
21
|
+
[Sign up for ZalTrack](https://www.zaltrack.dev/signup) or sign in, then copy your API key from the [dashboard](https://www.zaltrack.dev/app). The client reads the `ZALTRACK_API_KEY` environment variable when no key is passed.
|
|
22
|
+
|
|
23
|
+
## Quick start
|
|
24
|
+
|
|
25
|
+
```python
|
|
26
|
+
import os
|
|
27
|
+
|
|
28
|
+
from zaltrack import ZalTrackClient
|
|
29
|
+
|
|
30
|
+
with ZalTrackClient(os.environ["ZALTRACK_API_KEY"]) as client:
|
|
31
|
+
response = client.search_zalando(query="nike trainers")
|
|
32
|
+
print(response.data)
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Keyword arguments mirror the [API reference](https://www.zaltrack.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 zaltrack import AsyncZalTrackClient
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
async def main() -> None:
|
|
46
|
+
async with AsyncZalTrackClient() as client:
|
|
47
|
+
response = await client.search_zalando(query="nike trainers")
|
|
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 zaltrack import ZalTrackAPIError
|
|
74
|
+
|
|
75
|
+
try:
|
|
76
|
+
client.search_zalando(query="nike trainers")
|
|
77
|
+
except ZalTrackAPIError as error:
|
|
78
|
+
print(error.status, error.error_code, error, error.response_body)
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
| Error | When |
|
|
82
|
+
| --- | --- |
|
|
83
|
+
| `ZalTrackConfigurationError` | Missing API key, invalid options, unsupported method, closed client. |
|
|
84
|
+
| `ZalTrackSerializationError` | A required parameter is missing or a value can't be sent. |
|
|
85
|
+
| `ZalTrackTransportError` | Network failure or timeout. |
|
|
86
|
+
| `ZalTrackAPIError` | 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
|
+
| `ZalTrackResponseDecodingError` | A success response could not be decoded. |
|
|
88
|
+
|
|
89
|
+
All of them extend `ZalTrackError`.
|
|
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 = ZalTrackClient(max_retries=5, retry_delay=0.5)
|
|
97
|
+
|
|
98
|
+
# or for one request
|
|
99
|
+
client.search_zalando(query="nike trainers", 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. `AsyncZalTrackClient.batch()` does the same with `asyncio`.
|
|
105
|
+
|
|
106
|
+
```python
|
|
107
|
+
inputs = ["nike trainers", "rain jacket", "leather boots"]
|
|
108
|
+
results = client.batch(inputs, lambda query: client.search_zalando(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 zaltrack import ZalTrackClient, RequestOptions
|
|
131
|
+
|
|
132
|
+
client = ZalTrackClient(timeout=60) # seconds, default 120, None disables
|
|
133
|
+
client.search_zalando(query="nike trainers", 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 = ZalTrackClient(http_client=http_client)
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## Endpoints
|
|
141
|
+
|
|
142
|
+
9 methods, generated from the [OpenAPI document](https://www.zaltrack.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_article_history()` | GET `/history` | Every price ZalTrack read for an article reference on a marketplace over the period, whoever tracks it, oldest first, with the lowest, high… |
|
|
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 article reference on thi… |
|
|
152
|
+
| `list_products()` | GET `/products` | Your watchlist, newest first, with each product's latest state and its recent prices (trend). Filter with article_id (and marketplace) to k… |
|
|
153
|
+
| `search_zalando()` | GET `/search` | Zalando search results (sponsored included), to find the article reference of a product. Free, limited to 30 searches per hour. |
|
|
154
|
+
| `track_product()` | POST `/products` | Adds an article reference or a Zalando link to your watchlist. The first check runs in the background within seconds (checking is true unti… |
|
|
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 ZalTrack SDKs
|
|
158
|
+
|
|
159
|
+
| SDK | Package | Install |
|
|
160
|
+
| --- | --- | --- |
|
|
161
|
+
| Node.js | [`@zaltrack/sdk`](https://www.npmjs.com/package/@zaltrack/sdk) | `npm install @zaltrack/sdk` |
|
|
162
|
+
| Python | [`zaltrack`](https://pypi.org/project/zaltrack/) | `pip install zaltrack` |
|
|
163
|
+
| Go | [`zaltrack-go`](https://pkg.go.dev/github.com/zaltrackdev/zaltrack-go) | `go get github.com/zaltrackdev/zaltrack-go` |
|
|
164
|
+
| .NET | [`ZalTrack`](https://www.nuget.org/packages/ZalTrack) | `dotnet add package ZalTrack` |
|
|
165
|
+
| Ruby | [`zaltrack`](https://rubygems.org/gems/zaltrack) | `gem install zaltrack` |
|
|
166
|
+
| PHP | [`zaltrack/sdk`](https://packagist.org/packages/zaltrack/sdk) | `composer require zaltrack/sdk` |
|
|
167
|
+
| Java | [`zaltrack-java`](https://github.com/zaltrackdev/zaltrack-java) | build from source, see its README |
|
|
168
|
+
| CLI | [`@zaltrack/cli`](https://www.npmjs.com/package/@zaltrack/cli) | `npm install -g @zaltrack/cli` |
|
|
169
|
+
| MCP server | [`@zaltrack/mcp`](https://www.npmjs.com/package/@zaltrack/mcp) | `npx -y @zaltrack/mcp` |
|
|
170
|
+
|
|
171
|
+
## Trademarks
|
|
172
|
+
|
|
173
|
+
ZALANDO® is a registered trademark of Zalando SE. ZalTrack is not affiliated with, endorsed or sponsored by Zalando.
|
|
174
|
+
|
|
175
|
+
## License
|
|
176
|
+
|
|
177
|
+
MIT — see [LICENSE](LICENSE).
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Examples
|
|
2
|
+
|
|
3
|
+
```sh
|
|
4
|
+
pip install zaltrack
|
|
5
|
+
export ZALTRACK_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 `AsyncZalTrackClient`.
|
|
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 zaltrack import JsonResponse, ZalTrackAPIError, ZalTrackClient
|
|
4
|
+
|
|
5
|
+
with ZalTrackClient() as client: # reads ZALTRACK_API_KEY
|
|
6
|
+
try:
|
|
7
|
+
response = client.request("GET", "/account")
|
|
8
|
+
if isinstance(response, JsonResponse):
|
|
9
|
+
print(response.data)
|
|
10
|
+
except ZalTrackAPIError 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 zaltrack import AsyncZalTrackClient
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
async def main() -> None:
|
|
9
|
+
async with AsyncZalTrackClient() as client: # reads ZALTRACK_API_KEY
|
|
10
|
+
response = await client.search_zalando(query="nike trainers")
|
|
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 zaltrack import ZalTrackClient
|
|
7
|
+
|
|
8
|
+
with ZalTrackClient(os.environ["ZALTRACK_API_KEY"]) as client:
|
|
9
|
+
response = client.search_zalando(query="nike trainers")
|
|
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 = "zaltrack"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Official Python SDK for the ZalTrack Zalando price tracking API."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.11"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
license-files = ["LICENSE"]
|
|
13
|
+
authors = [
|
|
14
|
+
{ name = "ZalTrack", email = "contact@zaltrack.dev" },
|
|
15
|
+
]
|
|
16
|
+
keywords = [
|
|
17
|
+
"zalando",
|
|
18
|
+
"price-tracking",
|
|
19
|
+
"price-history",
|
|
20
|
+
"fashion",
|
|
21
|
+
"api",
|
|
22
|
+
"sdk",
|
|
23
|
+
"zaltrack",
|
|
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.zaltrack.dev"
|
|
51
|
+
Documentation = "https://www.zaltrack.dev/docs"
|
|
52
|
+
Repository = "https://github.com/zaltrackdev/zaltrack-python"
|
|
53
|
+
Issues = "https://github.com/zaltrackdev/zaltrack-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/zaltrack"]
|
|
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 ZalTrack 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
|
+
AsyncZalTrackClient,
|
|
13
|
+
ZalTrackClient,
|
|
14
|
+
)
|
|
15
|
+
from .errors import (
|
|
16
|
+
ZalTrackAPIError,
|
|
17
|
+
ZalTrackConfigurationError,
|
|
18
|
+
ZalTrackError,
|
|
19
|
+
ZalTrackResponseDecodingError,
|
|
20
|
+
ZalTrackSerializationError,
|
|
21
|
+
ZalTrackTransportError,
|
|
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
|
+
"AsyncZalTrackClient",
|
|
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
|
+
"ZalTrackAPIError",
|
|
52
|
+
"ZalTrackClient",
|
|
53
|
+
"ZalTrackConfigurationError",
|
|
54
|
+
"ZalTrackError",
|
|
55
|
+
"ZalTrackResponseDecodingError",
|
|
56
|
+
"ZalTrackSerializationError",
|
|
57
|
+
"ZalTrackTransportError",
|
|
58
|
+
"__version__",
|
|
59
|
+
]
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"""Generated from the ZalTrack 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_article_history": EndpointDefinition(
|
|
27
|
+
path="/history",
|
|
28
|
+
methods=("GET",),
|
|
29
|
+
response="json",
|
|
30
|
+
required=("article_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_zalando": 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
|
+
}
|