bricktrack 0.1.0__py3-none-any.whl
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.
- bricktrack/__init__.py +59 -0
- bricktrack/_endpoints.py +62 -0
- bricktrack/_operations.py +509 -0
- bricktrack/_response.py +91 -0
- bricktrack/_serialization.py +122 -0
- bricktrack/_version.py +1 -0
- bricktrack/client.py +454 -0
- bricktrack/errors.py +76 -0
- bricktrack/models.py +81 -0
- bricktrack/py.typed +1 -0
- bricktrack-0.1.0.dist-info/METADATA +208 -0
- bricktrack-0.1.0.dist-info/RECORD +14 -0
- bricktrack-0.1.0.dist-info/WHEEL +4 -0
- bricktrack-0.1.0.dist-info/licenses/LICENSE +21 -0
bricktrack/__init__.py
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"""Official Python SDK for the BrickTrack 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
|
+
AsyncBrickTrackClient,
|
|
13
|
+
BrickTrackClient,
|
|
14
|
+
)
|
|
15
|
+
from .errors import (
|
|
16
|
+
BrickTrackAPIError,
|
|
17
|
+
BrickTrackConfigurationError,
|
|
18
|
+
BrickTrackError,
|
|
19
|
+
BrickTrackResponseDecodingError,
|
|
20
|
+
BrickTrackSerializationError,
|
|
21
|
+
BrickTrackTransportError,
|
|
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
|
+
"AsyncBrickTrackClient",
|
|
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
|
+
"BrickTrackAPIError",
|
|
52
|
+
"BrickTrackClient",
|
|
53
|
+
"BrickTrackConfigurationError",
|
|
54
|
+
"BrickTrackError",
|
|
55
|
+
"BrickTrackResponseDecodingError",
|
|
56
|
+
"BrickTrackSerializationError",
|
|
57
|
+
"BrickTrackTransportError",
|
|
58
|
+
"__version__",
|
|
59
|
+
]
|
bricktrack/_endpoints.py
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"""Generated from the BrickTrack 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_set_history": EndpointDefinition(
|
|
33
|
+
path="/history",
|
|
34
|
+
methods=("GET",),
|
|
35
|
+
response="json",
|
|
36
|
+
required=("set_number",),
|
|
37
|
+
),
|
|
38
|
+
"list_products": EndpointDefinition(
|
|
39
|
+
path="/products",
|
|
40
|
+
methods=("GET",),
|
|
41
|
+
response="json",
|
|
42
|
+
required=(),
|
|
43
|
+
),
|
|
44
|
+
"search_sets": 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
|
+
}
|
|
@@ -0,0 +1,509 @@
|
|
|
1
|
+
"""Generated from the BrickTrack OpenAPI document. Do not edit by hand."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any, Literal, cast
|
|
6
|
+
|
|
7
|
+
from ._serialization import JSON_NULL
|
|
8
|
+
from .models import APIResponse, JsonResponse, RequestOptions
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class _SyncOperations:
|
|
12
|
+
"""Generated BrickTrack endpoint methods."""
|
|
13
|
+
|
|
14
|
+
__slots__ = ()
|
|
15
|
+
|
|
16
|
+
def _call(
|
|
17
|
+
self, name: str, params: dict[str, Any], options: RequestOptions | None
|
|
18
|
+
) -> APIResponse:
|
|
19
|
+
raise NotImplementedError
|
|
20
|
+
|
|
21
|
+
def check_product(
|
|
22
|
+
self,
|
|
23
|
+
*,
|
|
24
|
+
id: str,
|
|
25
|
+
wait: bool | None = None,
|
|
26
|
+
request_options: RequestOptions | None = None,
|
|
27
|
+
) -> JsonResponse:
|
|
28
|
+
"""Check the price now. 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 resumed first. The check runs in the background; with wait=true the answer waits for it. Read last_e…
|
|
29
|
+
|
|
30
|
+
``POST /products/{id}/check``
|
|
31
|
+
|
|
32
|
+
Args:
|
|
33
|
+
id: product_id returned when the product was added
|
|
34
|
+
wait: Answer once the check is done (up to 45 seconds)
|
|
35
|
+
"""
|
|
36
|
+
return cast(
|
|
37
|
+
JsonResponse, self._call("check_product", {"id": id, "wait": wait}, request_options)
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
def delete_product(
|
|
41
|
+
self,
|
|
42
|
+
*,
|
|
43
|
+
id: str,
|
|
44
|
+
request_options: RequestOptions | None = None,
|
|
45
|
+
) -> JsonResponse:
|
|
46
|
+
"""Stop tracking a product. Removes the product and its price history.
|
|
47
|
+
|
|
48
|
+
``DELETE /products/{id}``
|
|
49
|
+
|
|
50
|
+
Args:
|
|
51
|
+
id: product_id returned when the product was added
|
|
52
|
+
"""
|
|
53
|
+
return cast(JsonResponse, self._call("delete_product", {"id": id}, request_options))
|
|
54
|
+
|
|
55
|
+
def get_account(
|
|
56
|
+
self,
|
|
57
|
+
*,
|
|
58
|
+
request_options: RequestOptions | None = None,
|
|
59
|
+
) -> JsonResponse:
|
|
60
|
+
"""Plan and remaining credits. Your plan, the credits left (monthly allowance and packs), how many products you track and the credits they use per month, the credits each alert email costs, the days of history you can read and, on the free plan, the API and MCP requests…
|
|
61
|
+
|
|
62
|
+
``GET /account``
|
|
63
|
+
"""
|
|
64
|
+
return cast(JsonResponse, self._call("get_account", {}, request_options))
|
|
65
|
+
|
|
66
|
+
def get_product(
|
|
67
|
+
self,
|
|
68
|
+
*,
|
|
69
|
+
id: str,
|
|
70
|
+
days: int | None = None,
|
|
71
|
+
request_options: RequestOptions | None = None,
|
|
72
|
+
) -> JsonResponse:
|
|
73
|
+
"""Get a product and its price history. The product's latest state and every price read of the period, oldest first. The history covers every read of this set number on this marketplace, including those made before you added it, so a product added today can come with months of p…
|
|
74
|
+
|
|
75
|
+
``GET /products/{id}``
|
|
76
|
+
|
|
77
|
+
Args:
|
|
78
|
+
id: product_id returned when the product was added
|
|
79
|
+
days: History period in days. The free plan reads the last 30: history_days says which period was returned.
|
|
80
|
+
"""
|
|
81
|
+
return cast(
|
|
82
|
+
JsonResponse, self._call("get_product", {"id": id, "days": days}, request_options)
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
def get_set_history(
|
|
86
|
+
self,
|
|
87
|
+
*,
|
|
88
|
+
set_number: str,
|
|
89
|
+
marketplace: Literal["com", "co.uk", "de", "fr"] | str | None = None,
|
|
90
|
+
days: int | None = None,
|
|
91
|
+
request_options: RequestOptions | None = None,
|
|
92
|
+
) -> JsonResponse:
|
|
93
|
+
"""Price history of any set number. Every price BrickTrack read for a set number on a marketplace over the period, whoever tracks it, oldest first, with the lowest, highest and average of those prices. A history of more than 5000 points is thinned evenly, keeping its first a…
|
|
94
|
+
|
|
95
|
+
``GET /history``
|
|
96
|
+
|
|
97
|
+
Args:
|
|
98
|
+
set_number: LEGO set number (4 to 7 digits, like 75192)
|
|
99
|
+
marketplace: LEGO store, e.g. com for lego.com/en-us
|
|
100
|
+
days: History period in days. The free plan reads the last 30: history_days says which period was returned.
|
|
101
|
+
"""
|
|
102
|
+
return cast(
|
|
103
|
+
JsonResponse,
|
|
104
|
+
self._call(
|
|
105
|
+
"get_set_history",
|
|
106
|
+
{"set_number": set_number, "marketplace": marketplace, "days": days},
|
|
107
|
+
request_options,
|
|
108
|
+
),
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
def list_products(
|
|
112
|
+
self,
|
|
113
|
+
*,
|
|
114
|
+
set_number: str | None = None,
|
|
115
|
+
marketplace: Literal["com", "co.uk", "de", "fr"] | str | None = None,
|
|
116
|
+
filter: Literal["all", "drops", "target", "out_of_stock", "attention", "paused"]
|
|
117
|
+
| str
|
|
118
|
+
| None = None,
|
|
119
|
+
page: int | None = None,
|
|
120
|
+
limit: int | None = None,
|
|
121
|
+
request_options: RequestOptions | None = None,
|
|
122
|
+
) -> JsonResponse:
|
|
123
|
+
"""List tracked products. Your watchlist, newest first, with each product's latest state and its recent prices (trend). Filter with set_number (and marketplace) to know if a product is tracked, or with filter to get the same lists as the app's tabs.
|
|
124
|
+
|
|
125
|
+
``GET /products``
|
|
126
|
+
|
|
127
|
+
Args:
|
|
128
|
+
set_number: Only this set number
|
|
129
|
+
marketplace: Only this LEGO store
|
|
130
|
+
filter: Only the products of one of the app's watchlist filters. all: Every tracked product (default). drops: Cheaper now than when the product was added. target: At or below its target price. out_of_stock:…
|
|
131
|
+
page: Page number
|
|
132
|
+
limit: Products per page
|
|
133
|
+
"""
|
|
134
|
+
return cast(
|
|
135
|
+
JsonResponse,
|
|
136
|
+
self._call(
|
|
137
|
+
"list_products",
|
|
138
|
+
{
|
|
139
|
+
"set_number": set_number,
|
|
140
|
+
"marketplace": marketplace,
|
|
141
|
+
"filter": filter,
|
|
142
|
+
"page": page,
|
|
143
|
+
"limit": limit,
|
|
144
|
+
},
|
|
145
|
+
request_options,
|
|
146
|
+
),
|
|
147
|
+
)
|
|
148
|
+
|
|
149
|
+
def search_sets(
|
|
150
|
+
self,
|
|
151
|
+
*,
|
|
152
|
+
query: str,
|
|
153
|
+
marketplace: Literal["com", "co.uk", "de", "fr"] | str | None = None,
|
|
154
|
+
request_options: RequestOptions | None = None,
|
|
155
|
+
) -> JsonResponse:
|
|
156
|
+
"""Search LEGO. LEGO sets matching a name, a theme or the start of a set number (up to 20, the biggest first), from BrickTrack's catalog of official sets, to find the set number to track. price is null: a set's price is read once it's tracked. Free, limit…
|
|
157
|
+
|
|
158
|
+
``GET /search``
|
|
159
|
+
|
|
160
|
+
Args:
|
|
161
|
+
query: Keywords
|
|
162
|
+
marketplace: LEGO store, e.g. com for lego.com/en-us
|
|
163
|
+
"""
|
|
164
|
+
return cast(
|
|
165
|
+
JsonResponse,
|
|
166
|
+
self._call(
|
|
167
|
+
"search_sets", {"query": query, "marketplace": marketplace}, request_options
|
|
168
|
+
),
|
|
169
|
+
)
|
|
170
|
+
|
|
171
|
+
def track_product(
|
|
172
|
+
self,
|
|
173
|
+
*,
|
|
174
|
+
product: str,
|
|
175
|
+
marketplace: Literal["com", "co.uk", "de", "fr"] | str | None = None,
|
|
176
|
+
target_price: int | float | None = None,
|
|
177
|
+
interval_minutes: int | None = None,
|
|
178
|
+
wait: bool | None = None,
|
|
179
|
+
request_options: RequestOptions | None = None,
|
|
180
|
+
) -> JsonResponse:
|
|
181
|
+
"""Track a product. Adds a set number or a LEGO link to your watchlist. The first check runs in the background within seconds (checking is true until then): poll GET /products/{id}, or send wait: true to get the answer once it's done (up to 45 seconds). Each…
|
|
182
|
+
|
|
183
|
+
``POST /products``
|
|
184
|
+
|
|
185
|
+
Args:
|
|
186
|
+
product: set number (75192) or LEGO product link
|
|
187
|
+
marketplace: LEGO store, e.g. com for lego.com/en-us. A product link sets it on its own.
|
|
188
|
+
target_price: Email the owner when the price goes at or below this amount (on the free plan, for the first 5 products with an alert). null removes it.
|
|
189
|
+
interval_minutes: Minutes between two checks (1440 = daily). Checks faster than daily need a plan or a credit pack: every 60 minutes with a pack or Starter, 30 with Pro, 5 with Business.
|
|
190
|
+
wait: Answer once the first check is done (up to 45 seconds)
|
|
191
|
+
"""
|
|
192
|
+
return cast(
|
|
193
|
+
JsonResponse,
|
|
194
|
+
self._call(
|
|
195
|
+
"track_product",
|
|
196
|
+
{
|
|
197
|
+
"product": product,
|
|
198
|
+
"marketplace": marketplace,
|
|
199
|
+
"target_price": target_price,
|
|
200
|
+
"interval_minutes": interval_minutes,
|
|
201
|
+
"wait": wait,
|
|
202
|
+
},
|
|
203
|
+
request_options,
|
|
204
|
+
),
|
|
205
|
+
)
|
|
206
|
+
|
|
207
|
+
def update_product(
|
|
208
|
+
self,
|
|
209
|
+
*,
|
|
210
|
+
id: str,
|
|
211
|
+
target_price: int | float | None = None,
|
|
212
|
+
interval_minutes: int | None = None,
|
|
213
|
+
alert_on_drop: bool | None = None,
|
|
214
|
+
paused: bool | None = None,
|
|
215
|
+
request_options: RequestOptions | None = None,
|
|
216
|
+
) -> JsonResponse:
|
|
217
|
+
"""Change alerts and checks. Target price, drop alerts, check interval, or pause. Send only what changes. On the free plan, alerts (price drop, back in stock, target price) email for the first 5 products added among the active ones with an alert set; the others stay t…
|
|
218
|
+
|
|
219
|
+
``PATCH /products/{id}``
|
|
220
|
+
|
|
221
|
+
Args:
|
|
222
|
+
id: product_id returned when the product was added
|
|
223
|
+
target_price: Email the owner when the price goes at or below this amount (on the free plan, for the first 5 products with an alert). null removes it.
|
|
224
|
+
interval_minutes: Minutes between two checks (1440 = daily). Checks faster than daily need a plan or a credit pack: every 60 minutes with a pack or Starter, 30 with Pro, 5 with Business.
|
|
225
|
+
alert_on_drop: Email when the price drops or the product is back in stock (on the free plan, for the first 5 products with an alert)
|
|
226
|
+
paused: Stop checking (and charging) for now; false resumes
|
|
227
|
+
"""
|
|
228
|
+
return cast(
|
|
229
|
+
JsonResponse,
|
|
230
|
+
self._call(
|
|
231
|
+
"update_product",
|
|
232
|
+
{
|
|
233
|
+
"id": id,
|
|
234
|
+
"target_price": target_price,
|
|
235
|
+
"interval_minutes": interval_minutes,
|
|
236
|
+
"alert_on_drop": alert_on_drop,
|
|
237
|
+
"paused": paused,
|
|
238
|
+
},
|
|
239
|
+
request_options,
|
|
240
|
+
),
|
|
241
|
+
)
|
|
242
|
+
|
|
243
|
+
def clear_target_price(
|
|
244
|
+
self, *, id: str, request_options: RequestOptions | None = None
|
|
245
|
+
) -> JsonResponse:
|
|
246
|
+
"""Remove the product's target price.
|
|
247
|
+
|
|
248
|
+
``PATCH /products/{id}`` with the body ``{"target_price": null}``. ``update_product(target_price=None)``
|
|
249
|
+
cannot do it, because ``None`` values are never sent.
|
|
250
|
+
|
|
251
|
+
Args:
|
|
252
|
+
id: product_id returned when the product was added
|
|
253
|
+
"""
|
|
254
|
+
return cast(
|
|
255
|
+
JsonResponse,
|
|
256
|
+
self._call("update_product", {"id": id, "target_price": JSON_NULL}, request_options),
|
|
257
|
+
)
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
class _AsyncOperations:
|
|
261
|
+
"""Generated BrickTrack endpoint methods."""
|
|
262
|
+
|
|
263
|
+
__slots__ = ()
|
|
264
|
+
|
|
265
|
+
async def _call(
|
|
266
|
+
self, name: str, params: dict[str, Any], options: RequestOptions | None
|
|
267
|
+
) -> APIResponse:
|
|
268
|
+
raise NotImplementedError
|
|
269
|
+
|
|
270
|
+
async def check_product(
|
|
271
|
+
self,
|
|
272
|
+
*,
|
|
273
|
+
id: str,
|
|
274
|
+
wait: bool | None = None,
|
|
275
|
+
request_options: RequestOptions | None = None,
|
|
276
|
+
) -> JsonResponse:
|
|
277
|
+
"""Check the price now. 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 resumed first. The check runs in the background; with wait=true the answer waits for it. Read last_e…
|
|
278
|
+
|
|
279
|
+
``POST /products/{id}/check``
|
|
280
|
+
|
|
281
|
+
Args:
|
|
282
|
+
id: product_id returned when the product was added
|
|
283
|
+
wait: Answer once the check is done (up to 45 seconds)
|
|
284
|
+
"""
|
|
285
|
+
return cast(
|
|
286
|
+
JsonResponse,
|
|
287
|
+
await self._call("check_product", {"id": id, "wait": wait}, request_options),
|
|
288
|
+
)
|
|
289
|
+
|
|
290
|
+
async def delete_product(
|
|
291
|
+
self,
|
|
292
|
+
*,
|
|
293
|
+
id: str,
|
|
294
|
+
request_options: RequestOptions | None = None,
|
|
295
|
+
) -> JsonResponse:
|
|
296
|
+
"""Stop tracking a product. Removes the product and its price history.
|
|
297
|
+
|
|
298
|
+
``DELETE /products/{id}``
|
|
299
|
+
|
|
300
|
+
Args:
|
|
301
|
+
id: product_id returned when the product was added
|
|
302
|
+
"""
|
|
303
|
+
return cast(JsonResponse, await self._call("delete_product", {"id": id}, request_options))
|
|
304
|
+
|
|
305
|
+
async def get_account(
|
|
306
|
+
self,
|
|
307
|
+
*,
|
|
308
|
+
request_options: RequestOptions | None = None,
|
|
309
|
+
) -> JsonResponse:
|
|
310
|
+
"""Plan and remaining credits. Your plan, the credits left (monthly allowance and packs), how many products you track and the credits they use per month, the credits each alert email costs, the days of history you can read and, on the free plan, the API and MCP requests…
|
|
311
|
+
|
|
312
|
+
``GET /account``
|
|
313
|
+
"""
|
|
314
|
+
return cast(JsonResponse, await self._call("get_account", {}, request_options))
|
|
315
|
+
|
|
316
|
+
async def get_product(
|
|
317
|
+
self,
|
|
318
|
+
*,
|
|
319
|
+
id: str,
|
|
320
|
+
days: int | None = None,
|
|
321
|
+
request_options: RequestOptions | None = None,
|
|
322
|
+
) -> JsonResponse:
|
|
323
|
+
"""Get a product and its price history. The product's latest state and every price read of the period, oldest first. The history covers every read of this set number on this marketplace, including those made before you added it, so a product added today can come with months of p…
|
|
324
|
+
|
|
325
|
+
``GET /products/{id}``
|
|
326
|
+
|
|
327
|
+
Args:
|
|
328
|
+
id: product_id returned when the product was added
|
|
329
|
+
days: History period in days. The free plan reads the last 30: history_days says which period was returned.
|
|
330
|
+
"""
|
|
331
|
+
return cast(
|
|
332
|
+
JsonResponse, await self._call("get_product", {"id": id, "days": days}, request_options)
|
|
333
|
+
)
|
|
334
|
+
|
|
335
|
+
async def get_set_history(
|
|
336
|
+
self,
|
|
337
|
+
*,
|
|
338
|
+
set_number: str,
|
|
339
|
+
marketplace: Literal["com", "co.uk", "de", "fr"] | str | None = None,
|
|
340
|
+
days: int | None = None,
|
|
341
|
+
request_options: RequestOptions | None = None,
|
|
342
|
+
) -> JsonResponse:
|
|
343
|
+
"""Price history of any set number. Every price BrickTrack read for a set number on a marketplace over the period, whoever tracks it, oldest first, with the lowest, highest and average of those prices. A history of more than 5000 points is thinned evenly, keeping its first a…
|
|
344
|
+
|
|
345
|
+
``GET /history``
|
|
346
|
+
|
|
347
|
+
Args:
|
|
348
|
+
set_number: LEGO set number (4 to 7 digits, like 75192)
|
|
349
|
+
marketplace: LEGO store, e.g. com for lego.com/en-us
|
|
350
|
+
days: History period in days. The free plan reads the last 30: history_days says which period was returned.
|
|
351
|
+
"""
|
|
352
|
+
return cast(
|
|
353
|
+
JsonResponse,
|
|
354
|
+
await self._call(
|
|
355
|
+
"get_set_history",
|
|
356
|
+
{"set_number": set_number, "marketplace": marketplace, "days": days},
|
|
357
|
+
request_options,
|
|
358
|
+
),
|
|
359
|
+
)
|
|
360
|
+
|
|
361
|
+
async def list_products(
|
|
362
|
+
self,
|
|
363
|
+
*,
|
|
364
|
+
set_number: str | None = None,
|
|
365
|
+
marketplace: Literal["com", "co.uk", "de", "fr"] | str | None = None,
|
|
366
|
+
filter: Literal["all", "drops", "target", "out_of_stock", "attention", "paused"]
|
|
367
|
+
| str
|
|
368
|
+
| None = None,
|
|
369
|
+
page: int | None = None,
|
|
370
|
+
limit: int | None = None,
|
|
371
|
+
request_options: RequestOptions | None = None,
|
|
372
|
+
) -> JsonResponse:
|
|
373
|
+
"""List tracked products. Your watchlist, newest first, with each product's latest state and its recent prices (trend). Filter with set_number (and marketplace) to know if a product is tracked, or with filter to get the same lists as the app's tabs.
|
|
374
|
+
|
|
375
|
+
``GET /products``
|
|
376
|
+
|
|
377
|
+
Args:
|
|
378
|
+
set_number: Only this set number
|
|
379
|
+
marketplace: Only this LEGO store
|
|
380
|
+
filter: Only the products of one of the app's watchlist filters. all: Every tracked product (default). drops: Cheaper now than when the product was added. target: At or below its target price. out_of_stock:…
|
|
381
|
+
page: Page number
|
|
382
|
+
limit: Products per page
|
|
383
|
+
"""
|
|
384
|
+
return cast(
|
|
385
|
+
JsonResponse,
|
|
386
|
+
await self._call(
|
|
387
|
+
"list_products",
|
|
388
|
+
{
|
|
389
|
+
"set_number": set_number,
|
|
390
|
+
"marketplace": marketplace,
|
|
391
|
+
"filter": filter,
|
|
392
|
+
"page": page,
|
|
393
|
+
"limit": limit,
|
|
394
|
+
},
|
|
395
|
+
request_options,
|
|
396
|
+
),
|
|
397
|
+
)
|
|
398
|
+
|
|
399
|
+
async def search_sets(
|
|
400
|
+
self,
|
|
401
|
+
*,
|
|
402
|
+
query: str,
|
|
403
|
+
marketplace: Literal["com", "co.uk", "de", "fr"] | str | None = None,
|
|
404
|
+
request_options: RequestOptions | None = None,
|
|
405
|
+
) -> JsonResponse:
|
|
406
|
+
"""Search LEGO. LEGO sets matching a name, a theme or the start of a set number (up to 20, the biggest first), from BrickTrack's catalog of official sets, to find the set number to track. price is null: a set's price is read once it's tracked. Free, limit…
|
|
407
|
+
|
|
408
|
+
``GET /search``
|
|
409
|
+
|
|
410
|
+
Args:
|
|
411
|
+
query: Keywords
|
|
412
|
+
marketplace: LEGO store, e.g. com for lego.com/en-us
|
|
413
|
+
"""
|
|
414
|
+
return cast(
|
|
415
|
+
JsonResponse,
|
|
416
|
+
await self._call(
|
|
417
|
+
"search_sets", {"query": query, "marketplace": marketplace}, request_options
|
|
418
|
+
),
|
|
419
|
+
)
|
|
420
|
+
|
|
421
|
+
async def track_product(
|
|
422
|
+
self,
|
|
423
|
+
*,
|
|
424
|
+
product: str,
|
|
425
|
+
marketplace: Literal["com", "co.uk", "de", "fr"] | str | None = None,
|
|
426
|
+
target_price: int | float | None = None,
|
|
427
|
+
interval_minutes: int | None = None,
|
|
428
|
+
wait: bool | None = None,
|
|
429
|
+
request_options: RequestOptions | None = None,
|
|
430
|
+
) -> JsonResponse:
|
|
431
|
+
"""Track a product. Adds a set number or a LEGO link to your watchlist. The first check runs in the background within seconds (checking is true until then): poll GET /products/{id}, or send wait: true to get the answer once it's done (up to 45 seconds). Each…
|
|
432
|
+
|
|
433
|
+
``POST /products``
|
|
434
|
+
|
|
435
|
+
Args:
|
|
436
|
+
product: set number (75192) or LEGO product link
|
|
437
|
+
marketplace: LEGO store, e.g. com for lego.com/en-us. A product link sets it on its own.
|
|
438
|
+
target_price: Email the owner when the price goes at or below this amount (on the free plan, for the first 5 products with an alert). null removes it.
|
|
439
|
+
interval_minutes: Minutes between two checks (1440 = daily). Checks faster than daily need a plan or a credit pack: every 60 minutes with a pack or Starter, 30 with Pro, 5 with Business.
|
|
440
|
+
wait: Answer once the first check is done (up to 45 seconds)
|
|
441
|
+
"""
|
|
442
|
+
return cast(
|
|
443
|
+
JsonResponse,
|
|
444
|
+
await self._call(
|
|
445
|
+
"track_product",
|
|
446
|
+
{
|
|
447
|
+
"product": product,
|
|
448
|
+
"marketplace": marketplace,
|
|
449
|
+
"target_price": target_price,
|
|
450
|
+
"interval_minutes": interval_minutes,
|
|
451
|
+
"wait": wait,
|
|
452
|
+
},
|
|
453
|
+
request_options,
|
|
454
|
+
),
|
|
455
|
+
)
|
|
456
|
+
|
|
457
|
+
async def update_product(
|
|
458
|
+
self,
|
|
459
|
+
*,
|
|
460
|
+
id: str,
|
|
461
|
+
target_price: int | float | None = None,
|
|
462
|
+
interval_minutes: int | None = None,
|
|
463
|
+
alert_on_drop: bool | None = None,
|
|
464
|
+
paused: bool | None = None,
|
|
465
|
+
request_options: RequestOptions | None = None,
|
|
466
|
+
) -> JsonResponse:
|
|
467
|
+
"""Change alerts and checks. Target price, drop alerts, check interval, or pause. Send only what changes. On the free plan, alerts (price drop, back in stock, target price) email for the first 5 products added among the active ones with an alert set; the others stay t…
|
|
468
|
+
|
|
469
|
+
``PATCH /products/{id}``
|
|
470
|
+
|
|
471
|
+
Args:
|
|
472
|
+
id: product_id returned when the product was added
|
|
473
|
+
target_price: Email the owner when the price goes at or below this amount (on the free plan, for the first 5 products with an alert). null removes it.
|
|
474
|
+
interval_minutes: Minutes between two checks (1440 = daily). Checks faster than daily need a plan or a credit pack: every 60 minutes with a pack or Starter, 30 with Pro, 5 with Business.
|
|
475
|
+
alert_on_drop: Email when the price drops or the product is back in stock (on the free plan, for the first 5 products with an alert)
|
|
476
|
+
paused: Stop checking (and charging) for now; false resumes
|
|
477
|
+
"""
|
|
478
|
+
return cast(
|
|
479
|
+
JsonResponse,
|
|
480
|
+
await self._call(
|
|
481
|
+
"update_product",
|
|
482
|
+
{
|
|
483
|
+
"id": id,
|
|
484
|
+
"target_price": target_price,
|
|
485
|
+
"interval_minutes": interval_minutes,
|
|
486
|
+
"alert_on_drop": alert_on_drop,
|
|
487
|
+
"paused": paused,
|
|
488
|
+
},
|
|
489
|
+
request_options,
|
|
490
|
+
),
|
|
491
|
+
)
|
|
492
|
+
|
|
493
|
+
async def clear_target_price(
|
|
494
|
+
self, *, id: str, request_options: RequestOptions | None = None
|
|
495
|
+
) -> JsonResponse:
|
|
496
|
+
"""Remove the product's target price.
|
|
497
|
+
|
|
498
|
+
``PATCH /products/{id}`` with the body ``{"target_price": null}``. ``update_product(target_price=None)``
|
|
499
|
+
cannot do it, because ``None`` values are never sent.
|
|
500
|
+
|
|
501
|
+
Args:
|
|
502
|
+
id: product_id returned when the product was added
|
|
503
|
+
"""
|
|
504
|
+
return cast(
|
|
505
|
+
JsonResponse,
|
|
506
|
+
await self._call(
|
|
507
|
+
"update_product", {"id": id, "target_price": JSON_NULL}, request_options
|
|
508
|
+
),
|
|
509
|
+
)
|