watchlogdev 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.
- watchlogdev-0.1.0/.gitignore +14 -0
- watchlogdev-0.1.0/LICENSE +21 -0
- watchlogdev-0.1.0/PKG-INFO +208 -0
- watchlogdev-0.1.0/README.md +177 -0
- watchlogdev-0.1.0/examples/README.md +11 -0
- watchlogdev-0.1.0/examples/any_endpoint.py +11 -0
- watchlogdev-0.1.0/examples/async_client.py +14 -0
- watchlogdev-0.1.0/examples/json_response.py +10 -0
- watchlogdev-0.1.0/pyproject.toml +79 -0
- watchlogdev-0.1.0/src/watchlog/__init__.py +59 -0
- watchlogdev-0.1.0/src/watchlog/_endpoints.py +62 -0
- watchlogdev-0.1.0/src/watchlog/_operations.py +509 -0
- watchlogdev-0.1.0/src/watchlog/_response.py +91 -0
- watchlogdev-0.1.0/src/watchlog/_serialization.py +122 -0
- watchlogdev-0.1.0/src/watchlog/_version.py +1 -0
- watchlogdev-0.1.0/src/watchlog/client.py +452 -0
- watchlogdev-0.1.0/src/watchlog/errors.py +76 -0
- watchlogdev-0.1.0/src/watchlog/models.py +81 -0
- watchlogdev-0.1.0/src/watchlog/py.typed +1 -0
- watchlogdev-0.1.0/tests/__init__.py +1 -0
- watchlogdev-0.1.0/tests/test_client.py +416 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Watchlog
|
|
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.
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: watchlogdev
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Official Python SDK for the Watchlog watch price tracking API.
|
|
5
|
+
Project-URL: Homepage, https://www.watchlog.dev
|
|
6
|
+
Project-URL: Documentation, https://www.watchlog.dev/docs
|
|
7
|
+
Project-URL: Repository, https://github.com/watchlogdev/watchlog-python
|
|
8
|
+
Project-URL: Issues, https://github.com/watchlogdev/watchlog-python/issues
|
|
9
|
+
Author-email: Watchlog <contact@watchlog.dev>
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: api,luxury-watches,price-history,price-tracking,sdk,watch-prices,watchlog
|
|
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
|
+
# Watchlog Python SDK
|
|
33
|
+
|
|
34
|
+
The official Python SDK for the [Watchlog](https://www.watchlog.dev) watch price tracking API.
|
|
35
|
+
|
|
36
|
+
Track watch prices, by reference number or single listing, 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 watchlogdev
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Get your API key
|
|
51
|
+
|
|
52
|
+
[Sign up for Watchlog](https://www.watchlog.dev/signup) or sign in, then copy your API key from the [dashboard](https://www.watchlog.dev/app). The client reads the `WATCHLOG_API_KEY` environment variable when no key is passed.
|
|
53
|
+
|
|
54
|
+
## Quick start
|
|
55
|
+
|
|
56
|
+
```python
|
|
57
|
+
import os
|
|
58
|
+
|
|
59
|
+
from watchlog import WatchlogClient
|
|
60
|
+
|
|
61
|
+
with WatchlogClient(os.environ["WATCHLOG_API_KEY"]) as client:
|
|
62
|
+
response = client.search_watches(query="submariner")
|
|
63
|
+
print(response.data)
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Keyword arguments mirror the [API reference](https://www.watchlog.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 watchlog import AsyncWatchlogClient
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
async def main() -> None:
|
|
77
|
+
async with AsyncWatchlogClient() as client:
|
|
78
|
+
response = await client.search_watches(query="submariner")
|
|
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 watchlog import WatchlogAPIError
|
|
105
|
+
|
|
106
|
+
try:
|
|
107
|
+
client.search_watches(query="submariner")
|
|
108
|
+
except WatchlogAPIError as error:
|
|
109
|
+
print(error.status, error.error_code, error, error.response_body)
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
| Error | When |
|
|
113
|
+
| --- | --- |
|
|
114
|
+
| `WatchlogConfigurationError` | Missing API key, invalid options, unsupported method, closed client. |
|
|
115
|
+
| `WatchlogSerializationError` | A required parameter is missing or a value can't be sent. |
|
|
116
|
+
| `WatchlogTransportError` | Network failure or timeout. |
|
|
117
|
+
| `WatchlogAPIError` | 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
|
+
| `WatchlogResponseDecodingError` | A success response could not be decoded. |
|
|
119
|
+
|
|
120
|
+
All of them extend `WatchlogError`.
|
|
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 = WatchlogClient(max_retries=5, retry_delay=0.5)
|
|
128
|
+
|
|
129
|
+
# or for one request
|
|
130
|
+
client.search_watches(query="submariner", 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. `AsyncWatchlogClient.batch()` does the same with `asyncio`.
|
|
136
|
+
|
|
137
|
+
```python
|
|
138
|
+
inputs = ["submariner", "speedmaster", "royal oak"]
|
|
139
|
+
results = client.batch(inputs, lambda query: client.search_watches(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 watchlog import WatchlogClient, RequestOptions
|
|
162
|
+
|
|
163
|
+
client = WatchlogClient(timeout=60) # seconds, default 120, None disables
|
|
164
|
+
client.search_watches(query="submariner", 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 = WatchlogClient(http_client=http_client)
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## Endpoints
|
|
172
|
+
|
|
173
|
+
9 methods, generated from the [OpenAPI document](https://www.watchlog.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_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 reference on this market… |
|
|
182
|
+
| `get_watch_history()` | GET `/history` | Every price Watchlog read for a reference or listing id in a currency over the period, whoever tracks it, oldest first, with the lowest, hi… |
|
|
183
|
+
| `list_products()` | GET `/products` | Your watchlist, newest first, with each product's latest state and its recent prices (trend). Filter with watch_id (and marketplace) to kno… |
|
|
184
|
+
| `search_watches()` | GET `/search` | Watch models matching the keywords first (watch_id is their reference number, price the lowest asking price last seen across the whole mark… |
|
|
185
|
+
| `track_product()` | POST `/products` | Adds a watch to your watchlist: a model by its reference number (126610LN), priced at the lowest asking price among the current listings th… |
|
|
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 on the market, targ… |
|
|
187
|
+
|
|
188
|
+
## All Watchlog SDKs
|
|
189
|
+
|
|
190
|
+
| SDK | Package | Install |
|
|
191
|
+
| --- | --- | --- |
|
|
192
|
+
| Node.js | [`@watchlogdev/sdk`](https://www.npmjs.com/package/@watchlogdev/sdk) | `npm install @watchlogdev/sdk` |
|
|
193
|
+
| Python | [`watchlogdev`](https://pypi.org/project/watchlogdev/) | `pip install watchlogdev` |
|
|
194
|
+
| Go | [`watchlog-go`](https://pkg.go.dev/github.com/watchlogdev/watchlog-go) | `go get github.com/watchlogdev/watchlog-go` |
|
|
195
|
+
| .NET | [`Watchlog`](https://www.nuget.org/packages/Watchlog) | `dotnet add package Watchlog` |
|
|
196
|
+
| Ruby | [`watchlogdev`](https://rubygems.org/gems/watchlogdev) | `gem install watchlogdev` |
|
|
197
|
+
| PHP | [`watchlogdev/sdk`](https://packagist.org/packages/watchlogdev/sdk) | `composer require watchlogdev/sdk` |
|
|
198
|
+
| Java | [`watchlog-java`](https://github.com/watchlogdev/watchlog-java) | build from source, see its README |
|
|
199
|
+
| CLI | [`@watchlogdev/cli`](https://www.npmjs.com/package/@watchlogdev/cli) | `npm install -g @watchlogdev/cli` |
|
|
200
|
+
| MCP server | [`@watchlogdev/mcp`](https://www.npmjs.com/package/@watchlogdev/mcp) | `npx -y @watchlogdev/mcp` |
|
|
201
|
+
|
|
202
|
+
## Trademarks
|
|
203
|
+
|
|
204
|
+
Watch brand and model names are trademarks of their respective owners. Watchlog is an independent service, not affiliated with any watch brand, dealer or marketplace.
|
|
205
|
+
|
|
206
|
+
## License
|
|
207
|
+
|
|
208
|
+
MIT — see [LICENSE](LICENSE).
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
# Watchlog Python SDK
|
|
2
|
+
|
|
3
|
+
The official Python SDK for the [Watchlog](https://www.watchlog.dev) watch price tracking API.
|
|
4
|
+
|
|
5
|
+
Track watch prices, by reference number or single listing, 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 watchlogdev
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Get your API key
|
|
20
|
+
|
|
21
|
+
[Sign up for Watchlog](https://www.watchlog.dev/signup) or sign in, then copy your API key from the [dashboard](https://www.watchlog.dev/app). The client reads the `WATCHLOG_API_KEY` environment variable when no key is passed.
|
|
22
|
+
|
|
23
|
+
## Quick start
|
|
24
|
+
|
|
25
|
+
```python
|
|
26
|
+
import os
|
|
27
|
+
|
|
28
|
+
from watchlog import WatchlogClient
|
|
29
|
+
|
|
30
|
+
with WatchlogClient(os.environ["WATCHLOG_API_KEY"]) as client:
|
|
31
|
+
response = client.search_watches(query="submariner")
|
|
32
|
+
print(response.data)
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Keyword arguments mirror the [API reference](https://www.watchlog.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 watchlog import AsyncWatchlogClient
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
async def main() -> None:
|
|
46
|
+
async with AsyncWatchlogClient() as client:
|
|
47
|
+
response = await client.search_watches(query="submariner")
|
|
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 watchlog import WatchlogAPIError
|
|
74
|
+
|
|
75
|
+
try:
|
|
76
|
+
client.search_watches(query="submariner")
|
|
77
|
+
except WatchlogAPIError as error:
|
|
78
|
+
print(error.status, error.error_code, error, error.response_body)
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
| Error | When |
|
|
82
|
+
| --- | --- |
|
|
83
|
+
| `WatchlogConfigurationError` | Missing API key, invalid options, unsupported method, closed client. |
|
|
84
|
+
| `WatchlogSerializationError` | A required parameter is missing or a value can't be sent. |
|
|
85
|
+
| `WatchlogTransportError` | Network failure or timeout. |
|
|
86
|
+
| `WatchlogAPIError` | 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
|
+
| `WatchlogResponseDecodingError` | A success response could not be decoded. |
|
|
88
|
+
|
|
89
|
+
All of them extend `WatchlogError`.
|
|
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 = WatchlogClient(max_retries=5, retry_delay=0.5)
|
|
97
|
+
|
|
98
|
+
# or for one request
|
|
99
|
+
client.search_watches(query="submariner", 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. `AsyncWatchlogClient.batch()` does the same with `asyncio`.
|
|
105
|
+
|
|
106
|
+
```python
|
|
107
|
+
inputs = ["submariner", "speedmaster", "royal oak"]
|
|
108
|
+
results = client.batch(inputs, lambda query: client.search_watches(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 watchlog import WatchlogClient, RequestOptions
|
|
131
|
+
|
|
132
|
+
client = WatchlogClient(timeout=60) # seconds, default 120, None disables
|
|
133
|
+
client.search_watches(query="submariner", 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 = WatchlogClient(http_client=http_client)
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## Endpoints
|
|
141
|
+
|
|
142
|
+
9 methods, generated from the [OpenAPI document](https://www.watchlog.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_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 reference on this market… |
|
|
151
|
+
| `get_watch_history()` | GET `/history` | Every price Watchlog read for a reference or listing id in a currency over the period, whoever tracks it, oldest first, with the lowest, hi… |
|
|
152
|
+
| `list_products()` | GET `/products` | Your watchlist, newest first, with each product's latest state and its recent prices (trend). Filter with watch_id (and marketplace) to kno… |
|
|
153
|
+
| `search_watches()` | GET `/search` | Watch models matching the keywords first (watch_id is their reference number, price the lowest asking price last seen across the whole mark… |
|
|
154
|
+
| `track_product()` | POST `/products` | Adds a watch to your watchlist: a model by its reference number (126610LN), priced at the lowest asking price among the current listings th… |
|
|
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 on the market, targ… |
|
|
156
|
+
|
|
157
|
+
## All Watchlog SDKs
|
|
158
|
+
|
|
159
|
+
| SDK | Package | Install |
|
|
160
|
+
| --- | --- | --- |
|
|
161
|
+
| Node.js | [`@watchlogdev/sdk`](https://www.npmjs.com/package/@watchlogdev/sdk) | `npm install @watchlogdev/sdk` |
|
|
162
|
+
| Python | [`watchlogdev`](https://pypi.org/project/watchlogdev/) | `pip install watchlogdev` |
|
|
163
|
+
| Go | [`watchlog-go`](https://pkg.go.dev/github.com/watchlogdev/watchlog-go) | `go get github.com/watchlogdev/watchlog-go` |
|
|
164
|
+
| .NET | [`Watchlog`](https://www.nuget.org/packages/Watchlog) | `dotnet add package Watchlog` |
|
|
165
|
+
| Ruby | [`watchlogdev`](https://rubygems.org/gems/watchlogdev) | `gem install watchlogdev` |
|
|
166
|
+
| PHP | [`watchlogdev/sdk`](https://packagist.org/packages/watchlogdev/sdk) | `composer require watchlogdev/sdk` |
|
|
167
|
+
| Java | [`watchlog-java`](https://github.com/watchlogdev/watchlog-java) | build from source, see its README |
|
|
168
|
+
| CLI | [`@watchlogdev/cli`](https://www.npmjs.com/package/@watchlogdev/cli) | `npm install -g @watchlogdev/cli` |
|
|
169
|
+
| MCP server | [`@watchlogdev/mcp`](https://www.npmjs.com/package/@watchlogdev/mcp) | `npx -y @watchlogdev/mcp` |
|
|
170
|
+
|
|
171
|
+
## Trademarks
|
|
172
|
+
|
|
173
|
+
Watch brand and model names are trademarks of their respective owners. Watchlog is an independent service, not affiliated with any watch brand, dealer or marketplace.
|
|
174
|
+
|
|
175
|
+
## License
|
|
176
|
+
|
|
177
|
+
MIT — see [LICENSE](LICENSE).
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Examples
|
|
2
|
+
|
|
3
|
+
```sh
|
|
4
|
+
pip install watchlogdev
|
|
5
|
+
export WATCHLOG_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 `AsyncWatchlogClient`.
|
|
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 watchlog import JsonResponse, WatchlogAPIError, WatchlogClient
|
|
4
|
+
|
|
5
|
+
with WatchlogClient() as client: # reads WATCHLOG_API_KEY
|
|
6
|
+
try:
|
|
7
|
+
response = client.request("GET", "/account")
|
|
8
|
+
if isinstance(response, JsonResponse):
|
|
9
|
+
print(response.data)
|
|
10
|
+
except WatchlogAPIError 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 watchlog import AsyncWatchlogClient
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
async def main() -> None:
|
|
9
|
+
async with AsyncWatchlogClient() as client: # reads WATCHLOG_API_KEY
|
|
10
|
+
response = await client.search_watches(query="submariner")
|
|
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 watchlog import WatchlogClient
|
|
7
|
+
|
|
8
|
+
with WatchlogClient(os.environ["WATCHLOG_API_KEY"]) as client:
|
|
9
|
+
response = client.search_watches(query="submariner")
|
|
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 = "watchlogdev"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Official Python SDK for the Watchlog watch price tracking API."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.11"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
license-files = ["LICENSE"]
|
|
13
|
+
authors = [
|
|
14
|
+
{ name = "Watchlog", email = "contact@watchlog.dev" },
|
|
15
|
+
]
|
|
16
|
+
keywords = [
|
|
17
|
+
"watch-prices",
|
|
18
|
+
"price-tracking",
|
|
19
|
+
"price-history",
|
|
20
|
+
"luxury-watches",
|
|
21
|
+
"api",
|
|
22
|
+
"sdk",
|
|
23
|
+
"watchlog",
|
|
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.watchlog.dev"
|
|
51
|
+
Documentation = "https://www.watchlog.dev/docs"
|
|
52
|
+
Repository = "https://github.com/watchlogdev/watchlog-python"
|
|
53
|
+
Issues = "https://github.com/watchlogdev/watchlog-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/watchlog"]
|
|
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 Watchlog 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
|
+
AsyncWatchlogClient,
|
|
13
|
+
WatchlogClient,
|
|
14
|
+
)
|
|
15
|
+
from .errors import (
|
|
16
|
+
WatchlogAPIError,
|
|
17
|
+
WatchlogConfigurationError,
|
|
18
|
+
WatchlogError,
|
|
19
|
+
WatchlogResponseDecodingError,
|
|
20
|
+
WatchlogSerializationError,
|
|
21
|
+
WatchlogTransportError,
|
|
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
|
+
"AsyncWatchlogClient",
|
|
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
|
+
"WatchlogAPIError",
|
|
52
|
+
"WatchlogClient",
|
|
53
|
+
"WatchlogConfigurationError",
|
|
54
|
+
"WatchlogError",
|
|
55
|
+
"WatchlogResponseDecodingError",
|
|
56
|
+
"WatchlogSerializationError",
|
|
57
|
+
"WatchlogTransportError",
|
|
58
|
+
"__version__",
|
|
59
|
+
]
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"""Generated from the Watchlog 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_product": EndpointDefinition(
|
|
27
|
+
path="/products/{id}",
|
|
28
|
+
methods=("GET",),
|
|
29
|
+
response="json",
|
|
30
|
+
required=("id",),
|
|
31
|
+
),
|
|
32
|
+
"get_watch_history": EndpointDefinition(
|
|
33
|
+
path="/history",
|
|
34
|
+
methods=("GET",),
|
|
35
|
+
response="json",
|
|
36
|
+
required=("watch_id",),
|
|
37
|
+
),
|
|
38
|
+
"list_products": EndpointDefinition(
|
|
39
|
+
path="/products",
|
|
40
|
+
methods=("GET",),
|
|
41
|
+
response="json",
|
|
42
|
+
required=(),
|
|
43
|
+
),
|
|
44
|
+
"search_watches": 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
|
+
}
|