bricktrack 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.
@@ -0,0 +1,14 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ .venv/
4
+ venv/
5
+ build/
6
+ dist/
7
+ *.egg-info/
8
+ .pytest_cache/
9
+ .mypy_cache/
10
+ .ruff_cache/
11
+ .coverage
12
+ htmlcov/
13
+ .env
14
+ .DS_Store
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 BrickTrack
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: bricktrack
3
+ Version: 0.1.0
4
+ Summary: Official Python SDK for the BrickTrack LEGO price tracking API.
5
+ Project-URL: Homepage, https://www.bricktrack.dev
6
+ Project-URL: Documentation, https://www.bricktrack.dev/docs
7
+ Project-URL: Repository, https://github.com/bricktrackdev/bricktrack-python
8
+ Project-URL: Issues, https://github.com/bricktrackdev/bricktrack-python/issues
9
+ Author-email: BrickTrack <contact@bricktrack.dev>
10
+ License-Expression: MIT
11
+ License-File: LICENSE
12
+ Keywords: api,bricktrack,lego,lego-sets,price-history,price-tracking,sdk
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
+ # BrickTrack Python SDK
33
+
34
+ The official Python SDK for the [BrickTrack](https://www.bricktrack.dev) LEGO price tracking API.
35
+
36
+ Track LEGO set prices 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 bricktrack
48
+ ```
49
+
50
+ ## Get your API key
51
+
52
+ [Sign up for BrickTrack](https://www.bricktrack.dev/signup) or sign in, then copy your API key from the [dashboard](https://www.bricktrack.dev/app). The client reads the `BRICKTRACK_API_KEY` environment variable when no key is passed.
53
+
54
+ ## Quick start
55
+
56
+ ```python
57
+ import os
58
+
59
+ from bricktrack import BrickTrackClient
60
+
61
+ with BrickTrackClient(os.environ["BRICKTRACK_API_KEY"]) as client:
62
+ response = client.search_sets(query="millennium falcon")
63
+ print(response.data)
64
+ ```
65
+
66
+ Keyword arguments mirror the [API reference](https://www.bricktrack.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 bricktrack import AsyncBrickTrackClient
74
+
75
+
76
+ async def main() -> None:
77
+ async with AsyncBrickTrackClient() as client:
78
+ response = await client.search_sets(query="millennium falcon")
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 bricktrack import BrickTrackAPIError
105
+
106
+ try:
107
+ client.search_sets(query="millennium falcon")
108
+ except BrickTrackAPIError as error:
109
+ print(error.status, error.error_code, error, error.response_body)
110
+ ```
111
+
112
+ | Error | When |
113
+ | --- | --- |
114
+ | `BrickTrackConfigurationError` | Missing API key, invalid options, unsupported method, closed client. |
115
+ | `BrickTrackSerializationError` | A required parameter is missing or a value can't be sent. |
116
+ | `BrickTrackTransportError` | Network failure or timeout. |
117
+ | `BrickTrackAPIError` | 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
+ | `BrickTrackResponseDecodingError` | A success response could not be decoded. |
119
+
120
+ All of them extend `BrickTrackError`.
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 = BrickTrackClient(max_retries=5, retry_delay=0.5)
128
+
129
+ # or for one request
130
+ client.search_sets(query="millennium falcon", 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. `AsyncBrickTrackClient.batch()` does the same with `asyncio`.
136
+
137
+ ```python
138
+ inputs = ["millennium falcon", "titanic", "botanical"]
139
+ results = client.batch(inputs, lambda query: client.search_sets(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 bricktrack import BrickTrackClient, RequestOptions
162
+
163
+ client = BrickTrackClient(timeout=60) # seconds, default 120, None disables
164
+ client.search_sets(query="millennium falcon", 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 = BrickTrackClient(http_client=http_client)
169
+ ```
170
+
171
+ ## Endpoints
172
+
173
+ 9 methods, generated from the [OpenAPI document](https://www.bricktrack.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 set number on this marke… |
182
+ | `get_set_history()` | GET `/history` | Every price BrickTrack read for a set number on a marketplace over the period, whoever tracks it, oldest first, with the lowest, highest an… |
183
+ | `list_products()` | GET `/products` | Your watchlist, newest first, with each product's latest state and its recent prices (trend). Filter with set_number (and marketplace) to k… |
184
+ | `search_sets()` | GET `/search` | 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,… |
185
+ | `track_product()` | POST `/products` | 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): po… |
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 BrickTrack SDKs
189
+
190
+ | SDK | Package | Install |
191
+ | --- | --- | --- |
192
+ | Node.js | [`@bricktrack/sdk`](https://www.npmjs.com/package/@bricktrack/sdk) | `npm install @bricktrack/sdk` |
193
+ | Python | [`bricktrack`](https://pypi.org/project/bricktrack/) | `pip install bricktrack` |
194
+ | Go | [`bricktrack-go`](https://pkg.go.dev/github.com/bricktrackdev/bricktrack-go) | `go get github.com/bricktrackdev/bricktrack-go` |
195
+ | .NET | [`BrickTrack`](https://www.nuget.org/packages/BrickTrack) | `dotnet add package BrickTrack` |
196
+ | Ruby | [`bricktrack`](https://rubygems.org/gems/bricktrack) | `gem install bricktrack` |
197
+ | PHP | [`bricktrack/sdk`](https://packagist.org/packages/bricktrack/sdk) | `composer require bricktrack/sdk` |
198
+ | Java | [`bricktrack-java`](https://github.com/bricktrackdev/bricktrack-java) | build from source, see its README |
199
+ | CLI | [`@bricktrack/cli`](https://www.npmjs.com/package/@bricktrack/cli) | `npm install -g @bricktrack/cli` |
200
+ | MCP server | [`@bricktrack/mcp`](https://www.npmjs.com/package/@bricktrack/mcp) | `npx -y @bricktrack/mcp` |
201
+
202
+ ## Trademarks
203
+
204
+ LEGO® is a trademark of the LEGO Group of companies which does not sponsor, authorize or endorse this software.
205
+
206
+ ## License
207
+
208
+ MIT — see [LICENSE](LICENSE).
@@ -0,0 +1,177 @@
1
+ # BrickTrack Python SDK
2
+
3
+ The official Python SDK for the [BrickTrack](https://www.bricktrack.dev) LEGO price tracking API.
4
+
5
+ Track LEGO set prices 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 bricktrack
17
+ ```
18
+
19
+ ## Get your API key
20
+
21
+ [Sign up for BrickTrack](https://www.bricktrack.dev/signup) or sign in, then copy your API key from the [dashboard](https://www.bricktrack.dev/app). The client reads the `BRICKTRACK_API_KEY` environment variable when no key is passed.
22
+
23
+ ## Quick start
24
+
25
+ ```python
26
+ import os
27
+
28
+ from bricktrack import BrickTrackClient
29
+
30
+ with BrickTrackClient(os.environ["BRICKTRACK_API_KEY"]) as client:
31
+ response = client.search_sets(query="millennium falcon")
32
+ print(response.data)
33
+ ```
34
+
35
+ Keyword arguments mirror the [API reference](https://www.bricktrack.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 bricktrack import AsyncBrickTrackClient
43
+
44
+
45
+ async def main() -> None:
46
+ async with AsyncBrickTrackClient() as client:
47
+ response = await client.search_sets(query="millennium falcon")
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 bricktrack import BrickTrackAPIError
74
+
75
+ try:
76
+ client.search_sets(query="millennium falcon")
77
+ except BrickTrackAPIError as error:
78
+ print(error.status, error.error_code, error, error.response_body)
79
+ ```
80
+
81
+ | Error | When |
82
+ | --- | --- |
83
+ | `BrickTrackConfigurationError` | Missing API key, invalid options, unsupported method, closed client. |
84
+ | `BrickTrackSerializationError` | A required parameter is missing or a value can't be sent. |
85
+ | `BrickTrackTransportError` | Network failure or timeout. |
86
+ | `BrickTrackAPIError` | 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
+ | `BrickTrackResponseDecodingError` | A success response could not be decoded. |
88
+
89
+ All of them extend `BrickTrackError`.
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 = BrickTrackClient(max_retries=5, retry_delay=0.5)
97
+
98
+ # or for one request
99
+ client.search_sets(query="millennium falcon", 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. `AsyncBrickTrackClient.batch()` does the same with `asyncio`.
105
+
106
+ ```python
107
+ inputs = ["millennium falcon", "titanic", "botanical"]
108
+ results = client.batch(inputs, lambda query: client.search_sets(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 bricktrack import BrickTrackClient, RequestOptions
131
+
132
+ client = BrickTrackClient(timeout=60) # seconds, default 120, None disables
133
+ client.search_sets(query="millennium falcon", 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 = BrickTrackClient(http_client=http_client)
138
+ ```
139
+
140
+ ## Endpoints
141
+
142
+ 9 methods, generated from the [OpenAPI document](https://www.bricktrack.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 set number on this marke… |
151
+ | `get_set_history()` | GET `/history` | Every price BrickTrack read for a set number on a marketplace over the period, whoever tracks it, oldest first, with the lowest, highest an… |
152
+ | `list_products()` | GET `/products` | Your watchlist, newest first, with each product's latest state and its recent prices (trend). Filter with set_number (and marketplace) to k… |
153
+ | `search_sets()` | GET `/search` | 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,… |
154
+ | `track_product()` | POST `/products` | 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): po… |
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 BrickTrack SDKs
158
+
159
+ | SDK | Package | Install |
160
+ | --- | --- | --- |
161
+ | Node.js | [`@bricktrack/sdk`](https://www.npmjs.com/package/@bricktrack/sdk) | `npm install @bricktrack/sdk` |
162
+ | Python | [`bricktrack`](https://pypi.org/project/bricktrack/) | `pip install bricktrack` |
163
+ | Go | [`bricktrack-go`](https://pkg.go.dev/github.com/bricktrackdev/bricktrack-go) | `go get github.com/bricktrackdev/bricktrack-go` |
164
+ | .NET | [`BrickTrack`](https://www.nuget.org/packages/BrickTrack) | `dotnet add package BrickTrack` |
165
+ | Ruby | [`bricktrack`](https://rubygems.org/gems/bricktrack) | `gem install bricktrack` |
166
+ | PHP | [`bricktrack/sdk`](https://packagist.org/packages/bricktrack/sdk) | `composer require bricktrack/sdk` |
167
+ | Java | [`bricktrack-java`](https://github.com/bricktrackdev/bricktrack-java) | build from source, see its README |
168
+ | CLI | [`@bricktrack/cli`](https://www.npmjs.com/package/@bricktrack/cli) | `npm install -g @bricktrack/cli` |
169
+ | MCP server | [`@bricktrack/mcp`](https://www.npmjs.com/package/@bricktrack/mcp) | `npx -y @bricktrack/mcp` |
170
+
171
+ ## Trademarks
172
+
173
+ LEGO® is a trademark of the LEGO Group of companies which does not sponsor, authorize or endorse this software.
174
+
175
+ ## License
176
+
177
+ MIT — see [LICENSE](LICENSE).
@@ -0,0 +1,11 @@
1
+ # Examples
2
+
3
+ ```sh
4
+ pip install bricktrack
5
+ export BRICKTRACK_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 `AsyncBrickTrackClient`.
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 bricktrack import BrickTrackAPIError, BrickTrackClient, JsonResponse
4
+
5
+ with BrickTrackClient() as client: # reads BRICKTRACK_API_KEY
6
+ try:
7
+ response = client.request("GET", "/account")
8
+ if isinstance(response, JsonResponse):
9
+ print(response.data)
10
+ except BrickTrackAPIError 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 bricktrack import AsyncBrickTrackClient
6
+
7
+
8
+ async def main() -> None:
9
+ async with AsyncBrickTrackClient() as client: # reads BRICKTRACK_API_KEY
10
+ response = await client.search_sets(query="millennium falcon")
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 bricktrack import BrickTrackClient
7
+
8
+ with BrickTrackClient(os.environ["BRICKTRACK_API_KEY"]) as client:
9
+ response = client.search_sets(query="millennium falcon")
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 = "bricktrack"
7
+ version = "0.1.0"
8
+ description = "Official Python SDK for the BrickTrack LEGO price tracking API."
9
+ readme = "README.md"
10
+ requires-python = ">=3.11"
11
+ license = "MIT"
12
+ license-files = ["LICENSE"]
13
+ authors = [
14
+ { name = "BrickTrack", email = "contact@bricktrack.dev" },
15
+ ]
16
+ keywords = [
17
+ "lego",
18
+ "price-tracking",
19
+ "price-history",
20
+ "lego-sets",
21
+ "api",
22
+ "sdk",
23
+ "bricktrack",
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.bricktrack.dev"
51
+ Documentation = "https://www.bricktrack.dev/docs"
52
+ Repository = "https://github.com/bricktrackdev/bricktrack-python"
53
+ Issues = "https://github.com/bricktrackdev/bricktrack-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/bricktrack"]
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 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
+ ]
@@ -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
+ }