discogs-sdk 0.7.0__tar.gz → 0.8.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.
Files changed (80) hide show
  1. discogs_sdk-0.8.0/PKG-INFO +257 -0
  2. discogs_sdk-0.8.0/README.md +227 -0
  3. {discogs_sdk-0.7.0 → discogs_sdk-0.8.0}/pyproject.toml +3 -1
  4. {discogs_sdk-0.7.0 → discogs_sdk-0.8.0}/pyproject.toml.orig +8 -1
  5. discogs_sdk-0.8.0/src/discogs_sdk/.agents/skills/discogs-sdk/SKILL.md +123 -0
  6. discogs_sdk-0.8.0/src/discogs_sdk/.agents/skills/discogs-sdk/references/caching.md +189 -0
  7. discogs_sdk-0.8.0/src/discogs_sdk/.agents/skills/discogs-sdk/references/endpoints.md +108 -0
  8. discogs_sdk-0.8.0/src/discogs_sdk/.agents/skills/discogs-sdk/references/errors-and-retries.md +195 -0
  9. discogs_sdk-0.8.0/src/discogs_sdk/.agents/skills/discogs-sdk/references/migrating-from-python3-discogs-client.md +163 -0
  10. discogs_sdk-0.8.0/src/discogs_sdk/.agents/skills/discogs-sdk/references/pagination.md +105 -0
  11. {discogs_sdk-0.7.0 → discogs_sdk-0.8.0}/src/discogs_sdk/__init__.py +6 -1
  12. {discogs_sdk-0.7.0 → discogs_sdk-0.8.0}/src/discogs_sdk/_async/_client.py +161 -42
  13. discogs_sdk-0.8.0/src/discogs_sdk/_async/_experimental.py +184 -0
  14. {discogs_sdk-0.7.0 → discogs_sdk-0.8.0}/src/discogs_sdk/_async/_lazy.py +8 -3
  15. {discogs_sdk-0.7.0 → discogs_sdk-0.8.0}/src/discogs_sdk/_async/_oauth.py +3 -2
  16. {discogs_sdk-0.7.0 → discogs_sdk-0.8.0}/src/discogs_sdk/_async/_paginator.py +58 -28
  17. {discogs_sdk-0.7.0 → discogs_sdk-0.8.0}/src/discogs_sdk/_async/_resource.py +15 -13
  18. {discogs_sdk-0.7.0 → discogs_sdk-0.8.0}/src/discogs_sdk/_async/resources/collection.py +5 -5
  19. {discogs_sdk-0.7.0 → discogs_sdk-0.8.0}/src/discogs_sdk/_async/resources/users.py +4 -3
  20. {discogs_sdk-0.7.0 → discogs_sdk-0.8.0}/src/discogs_sdk/_base_client.py +70 -16
  21. {discogs_sdk-0.7.0 → discogs_sdk-0.8.0}/src/discogs_sdk/_cache.py +121 -32
  22. {discogs_sdk-0.7.0 → discogs_sdk-0.8.0}/src/discogs_sdk/_events.py +26 -9
  23. {discogs_sdk-0.7.0 → discogs_sdk-0.8.0}/src/discogs_sdk/_exceptions.py +66 -1
  24. discogs_sdk-0.8.0/src/discogs_sdk/_experimental_types.py +33 -0
  25. discogs_sdk-0.8.0/src/discogs_sdk/_page_result.py +40 -0
  26. {discogs_sdk-0.7.0 → discogs_sdk-0.8.0}/src/discogs_sdk/_sync/_client.py +156 -44
  27. discogs_sdk-0.8.0/src/discogs_sdk/_sync/_experimental.py +176 -0
  28. {discogs_sdk-0.7.0 → discogs_sdk-0.8.0}/src/discogs_sdk/_sync/_lazy.py +8 -3
  29. {discogs_sdk-0.7.0 → discogs_sdk-0.8.0}/src/discogs_sdk/_sync/_oauth.py +3 -2
  30. {discogs_sdk-0.7.0 → discogs_sdk-0.8.0}/src/discogs_sdk/_sync/_paginator.py +58 -25
  31. {discogs_sdk-0.7.0 → discogs_sdk-0.8.0}/src/discogs_sdk/_sync/_resource.py +12 -14
  32. {discogs_sdk-0.7.0 → discogs_sdk-0.8.0}/src/discogs_sdk/_sync/resources/collection.py +6 -4
  33. {discogs_sdk-0.7.0 → discogs_sdk-0.8.0}/src/discogs_sdk/_sync/resources/users.py +5 -2
  34. discogs_sdk-0.8.0/src/discogs_sdk/experimental.py +23 -0
  35. {discogs_sdk-0.7.0 → discogs_sdk-0.8.0}/src/discogs_sdk/models/_common.py +1 -1
  36. {discogs_sdk-0.7.0 → discogs_sdk-0.8.0}/src/discogs_sdk/models/search.py +15 -1
  37. discogs_sdk-0.7.0/PKG-INFO +0 -741
  38. discogs_sdk-0.7.0/README.md +0 -711
  39. {discogs_sdk-0.7.0 → discogs_sdk-0.8.0}/LICENSE.txt +0 -0
  40. {discogs_sdk-0.7.0 → discogs_sdk-0.8.0}/src/discogs_sdk/_async/__init__.py +0 -0
  41. {discogs_sdk-0.7.0 → discogs_sdk-0.8.0}/src/discogs_sdk/_async/resources/__init__.py +0 -0
  42. {discogs_sdk-0.7.0 → discogs_sdk-0.8.0}/src/discogs_sdk/_async/resources/artists.py +0 -0
  43. {discogs_sdk-0.7.0 → discogs_sdk-0.8.0}/src/discogs_sdk/_async/resources/exports.py +0 -0
  44. {discogs_sdk-0.7.0 → discogs_sdk-0.8.0}/src/discogs_sdk/_async/resources/labels.py +0 -0
  45. {discogs_sdk-0.7.0 → discogs_sdk-0.8.0}/src/discogs_sdk/_async/resources/lists.py +0 -0
  46. {discogs_sdk-0.7.0 → discogs_sdk-0.8.0}/src/discogs_sdk/_async/resources/marketplace.py +0 -0
  47. {discogs_sdk-0.7.0 → discogs_sdk-0.8.0}/src/discogs_sdk/_async/resources/masters.py +0 -0
  48. {discogs_sdk-0.7.0 → discogs_sdk-0.8.0}/src/discogs_sdk/_async/resources/releases.py +0 -0
  49. {discogs_sdk-0.7.0 → discogs_sdk-0.8.0}/src/discogs_sdk/_async/resources/search.py +0 -0
  50. {discogs_sdk-0.7.0 → discogs_sdk-0.8.0}/src/discogs_sdk/_async/resources/uploads.py +0 -0
  51. {discogs_sdk-0.7.0 → discogs_sdk-0.8.0}/src/discogs_sdk/_async/resources/wantlist.py +0 -0
  52. {discogs_sdk-0.7.0 → discogs_sdk-0.8.0}/src/discogs_sdk/_oauth_types.py +0 -0
  53. {discogs_sdk-0.7.0 → discogs_sdk-0.8.0}/src/discogs_sdk/_sync/__init__.py +0 -0
  54. {discogs_sdk-0.7.0 → discogs_sdk-0.8.0}/src/discogs_sdk/_sync/resources/__init__.py +0 -0
  55. {discogs_sdk-0.7.0 → discogs_sdk-0.8.0}/src/discogs_sdk/_sync/resources/artists.py +0 -0
  56. {discogs_sdk-0.7.0 → discogs_sdk-0.8.0}/src/discogs_sdk/_sync/resources/exports.py +0 -0
  57. {discogs_sdk-0.7.0 → discogs_sdk-0.8.0}/src/discogs_sdk/_sync/resources/labels.py +0 -0
  58. {discogs_sdk-0.7.0 → discogs_sdk-0.8.0}/src/discogs_sdk/_sync/resources/lists.py +0 -0
  59. {discogs_sdk-0.7.0 → discogs_sdk-0.8.0}/src/discogs_sdk/_sync/resources/marketplace.py +0 -0
  60. {discogs_sdk-0.7.0 → discogs_sdk-0.8.0}/src/discogs_sdk/_sync/resources/masters.py +0 -0
  61. {discogs_sdk-0.7.0 → discogs_sdk-0.8.0}/src/discogs_sdk/_sync/resources/releases.py +0 -0
  62. {discogs_sdk-0.7.0 → discogs_sdk-0.8.0}/src/discogs_sdk/_sync/resources/search.py +0 -0
  63. {discogs_sdk-0.7.0 → discogs_sdk-0.8.0}/src/discogs_sdk/_sync/resources/uploads.py +0 -0
  64. {discogs_sdk-0.7.0 → discogs_sdk-0.8.0}/src/discogs_sdk/_sync/resources/wantlist.py +0 -0
  65. {discogs_sdk-0.7.0 → discogs_sdk-0.8.0}/src/discogs_sdk/models/__init__.py +0 -0
  66. {discogs_sdk-0.7.0 → discogs_sdk-0.8.0}/src/discogs_sdk/models/_lazy_fields.py +0 -0
  67. {discogs_sdk-0.7.0 → discogs_sdk-0.8.0}/src/discogs_sdk/models/_timestamp.py +0 -0
  68. {discogs_sdk-0.7.0 → discogs_sdk-0.8.0}/src/discogs_sdk/models/artist.py +0 -0
  69. {discogs_sdk-0.7.0 → discogs_sdk-0.8.0}/src/discogs_sdk/models/collection.py +0 -0
  70. {discogs_sdk-0.7.0 → discogs_sdk-0.8.0}/src/discogs_sdk/models/export.py +0 -0
  71. {discogs_sdk-0.7.0 → discogs_sdk-0.8.0}/src/discogs_sdk/models/label.py +0 -0
  72. {discogs_sdk-0.7.0 → discogs_sdk-0.8.0}/src/discogs_sdk/models/list_.py +0 -0
  73. {discogs_sdk-0.7.0 → discogs_sdk-0.8.0}/src/discogs_sdk/models/marketplace.py +0 -0
  74. {discogs_sdk-0.7.0 → discogs_sdk-0.8.0}/src/discogs_sdk/models/master.py +0 -0
  75. {discogs_sdk-0.7.0 → discogs_sdk-0.8.0}/src/discogs_sdk/models/release.py +0 -0
  76. {discogs_sdk-0.7.0 → discogs_sdk-0.8.0}/src/discogs_sdk/models/upload.py +0 -0
  77. {discogs_sdk-0.7.0 → discogs_sdk-0.8.0}/src/discogs_sdk/models/user.py +0 -0
  78. {discogs_sdk-0.7.0 → discogs_sdk-0.8.0}/src/discogs_sdk/models/wantlist.py +0 -0
  79. {discogs_sdk-0.7.0 → discogs_sdk-0.8.0}/src/discogs_sdk/oauth.py +0 -0
  80. {discogs_sdk-0.7.0 → discogs_sdk-0.8.0}/src/discogs_sdk/py.typed +0 -0
@@ -0,0 +1,257 @@
1
+ Metadata-Version: 2.4
2
+ Name: discogs-sdk
3
+ Version: 0.8.0
4
+ Summary: Modern Python client for the Discogs API
5
+ Keywords: api,discogs,music,python,sdk
6
+ Author: Jean-Marc Fontaine
7
+ Author-email: Jean-Marc Fontaine <jm@jmfontaine.net>
8
+ License-Expression: Apache-2.0
9
+ License-File: LICENSE.txt
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Programming Language :: Python :: 3 :: Only
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Programming Language :: Python :: 3.14
18
+ Classifier: Programming Language :: Python :: 3.15
19
+ Classifier: Typing :: Typed
20
+ Requires-Dist: httpx2>=2.12
21
+ Requires-Dist: pydantic>=2.12
22
+ Requires-Dist: pydantic>=2.14 ; python_full_version == '3.15.*'
23
+ Requires-Dist: typing-extensions>=4
24
+ Requires-Dist: tzdata>=2024.1
25
+ Requires-Python: >=3.10
26
+ Project-URL: Homepage, https://github.com/jmfontaine/discogs-sdk
27
+ Project-URL: Issues, https://github.com/jmfontaine/discogs-sdk/issues
28
+ Project-URL: Repository, https://github.com/jmfontaine/discogs-sdk
29
+ Description-Content-Type: text/markdown
30
+
31
+ # discogs-sdk
32
+
33
+ <p align="center">
34
+ <a href="https://pypi.org/project/discogs-sdk/"><img src="https://img.shields.io/pypi/v/discogs-sdk.svg" alt="PyPI version"></a>
35
+ <a href="https://pypi.org/project/discogs-sdk/"><img src="https://img.shields.io/pypi/pyversions/discogs-sdk.svg" alt="Python versions"></a>
36
+ <a href="https://github.com/jmfontaine/discogs-sdk/actions"><img src="https://github.com/jmfontaine/discogs-sdk/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
37
+ <a href="https://pypi.org/project/discogs-sdk/"><img src="https://img.shields.io/pypi/dm/discogs-sdk.svg" alt="PyPI downloads"></a>
38
+ <a href="https://github.com/jmfontaine/discogs-sdk/blob/main/LICENSE.txt"><img src="https://img.shields.io/pypi/l/discogs-sdk.svg" alt="License"></a>
39
+ </p>
40
+
41
+ discogs-sdk is a modern Python client for the [Discogs API](https://www.discogs.com/developers) covering every documented v2 endpoint, with a fluent chainable syntax and built-in response caching.
42
+
43
+ ```python
44
+ from discogs_sdk import Discogs
45
+
46
+ with Discogs() as client:
47
+ release = client.releases.get(352665)
48
+ print(f"{release.title} ({release.year})")
49
+
50
+ for result in client.search(query="Nine Inch Nails", type="artist"):
51
+ print(result.title)
52
+ ```
53
+
54
+ ## Installation
55
+
56
+ ```bash
57
+ pip install discogs-sdk
58
+ # or
59
+ uv add discogs-sdk
60
+ ```
61
+
62
+ Requires Python 3.10+.
63
+
64
+ ## Features
65
+
66
+ - **Complete Endpoint Coverage** — Every route in the Discogs API v2 documentation
67
+ - **Fluent API** — Chain sub-resources naturally: `client.releases.get(id).rating.get()`
68
+ - **Lazy Loading** — No HTTP calls until you actually need the data
69
+ - **Effortless Pagination** — Browse results without managing pages or offsets
70
+ - **Rate Limit Aware** — Bounded retries with `Retry-After` support, the live budget on `client.ratelimit`, and a structured event per request
71
+ - **Built-in Caching** — Optional TTL-based caching reduces API calls
72
+ - **Flexible Auth** — Supports personal tokens, consumer key/secret, or full OAuth 1.0a
73
+ - **Type Safe** — Get autocomplete and IDE support
74
+ - **Async & Sync** — Full support for both synchronous and asynchronous workflows
75
+
76
+ ### How it compares
77
+
78
+ The established alternative is [python3-discogs-client](https://github.com/joalla/discogs_client). Both load data
79
+ lazily, paginate automatically, support OAuth 1.0a and back off on HTTP 429, so the differences that matter are:
80
+
81
+ | | discogs-sdk | python3-discogs-client |
82
+ |---|---|---|
83
+ | Documented v2 API coverage | Complete | Partial † |
84
+ | Sync and async | Both | Sync only |
85
+ | Responses | Typed Pydantic models | Untyped attributes |
86
+ | Response cache | In-memory or SQLite | None |
87
+
88
+ † No inventory export or upload, release ratings or have/want stats, collection fields, folder creation,
89
+ contributions or submissions.
90
+
91
+ Coming from python3-discogs-client? The
92
+ [migration guide](https://github.com/jmfontaine/discogs-sdk/blob/main/docs/migrating-from-python3-discogs-client.md)
93
+ maps each of its idioms to discogs-sdk and names the behaviour that differs.
94
+
95
+ ## Quick start
96
+
97
+ Create a personal access token in [your Discogs developer settings](https://www.discogs.com/settings/developers) and
98
+ export it; the client reads it from the environment
99
+ ([other auth modes](https://github.com/jmfontaine/discogs-sdk/blob/main/docs/authentication.md)):
100
+
101
+ ```bash
102
+ export DISCOGS_TOKEN="your-token-here"
103
+ ```
104
+
105
+ ```python
106
+ from discogs_sdk import Discogs
107
+
108
+ with Discogs() as client:
109
+ release = client.releases.get(352665) # no request yet
110
+ print(release.title) # the GET is sent here → "The Downward Spiral"
111
+
112
+ for rel in client.artists.get(3857).releases.list(sort="year"):
113
+ print(f"{rel.title} ({rel.year})")
114
+ ```
115
+
116
+ The async client has the same API. Await a lazy resource to fetch it, and iterate pages with `async for`:
117
+
118
+ ```python
119
+ import asyncio
120
+
121
+ from discogs_sdk import AsyncDiscogs
122
+
123
+
124
+ async def main():
125
+ async with AsyncDiscogs() as client:
126
+ release = await client.releases.get(352665)
127
+ print(release.title)
128
+
129
+ async for result in client.search(query="Nine Inch Nails", type="artist"):
130
+ print(result.title)
131
+
132
+
133
+ asyncio.run(main())
134
+ ```
135
+
136
+ ## Behaviors to know
137
+
138
+ - **Lazy loading.** `.get()` sends no request; the first data attribute access does, and that is where
139
+ `NotFoundError` is raised. [More](https://github.com/jmfontaine/discogs-sdk/blob/main/docs/getting-started.md#lazy-loading)
140
+ - **Async.** `await` a proxy for its data and use `async for` on pages. Awaiting returns the model, which has no
141
+ sub-resources, so keep the proxy to chain (`artist_proxy.releases.list()`).
142
+ [More](https://github.com/jmfontaine/discogs-sdk/blob/main/docs/getting-started.md#async-proxies)
143
+ - **Pagination cost.** `search()` and most `.list()` methods fetch pages on demand. Each page is a GET against the rate
144
+ limit (60/min authenticated, 25/min anonymous); a cache hit costs nothing (one request if the entry no longer parses)
145
+ and retries can cost more.
146
+ [More](https://github.com/jmfontaine/discogs-sdk/blob/main/docs/pagination.md)
147
+ - **Retries.** Reads retry; a mutation is never replayed after an ambiguous failure.
148
+ [More](https://github.com/jmfontaine/discogs-sdk/blob/main/docs/errors-and-retries.md#settling-an-ambiguous-write)
149
+ - **Caching.** Off by default; only `GET`/`HEAD` are cached; a successful write clears the cache.
150
+ [More](https://github.com/jmfontaine/discogs-sdk/blob/main/docs/caching.md)
151
+
152
+ ## Design principles
153
+
154
+ The SDK does more than relay requests: it pages, retries, renames keys and parses timestamps. These rules say what it
155
+ may and may not do, and every new feature is checked against them.
156
+
157
+ - **Requests stay predictable.** A low-level method sends only the requests its documentation names. Combining calls
158
+ is fine; the method documents the cost, and every call is observable through `on_request`. Auto-paging sends
159
+ one GET per page as you iterate
160
+ ([cost](https://github.com/jmfontaine/discogs-sdk/blob/main/docs/pagination.md#what-a-page-costs)), a lazy proxy
161
+ sends one GET on its first data access
162
+ ([lazy loading](https://github.com/jmfontaine/discogs-sdk/blob/main/docs/getting-started.md#lazy-loading)), and a
163
+ retried read emits one `RequestEvent` whose `attempts` counts every send
164
+ ([observability](https://github.com/jmfontaine/discogs-sdk/blob/main/docs/observability.md)).
165
+ - **Data may be normalized** (names, types, timestamps, URLs) when nothing is lost, because `raw` keeps the original;
166
+ when the result is computed from the response alone; and when the normalization is documented. Examples are
167
+ [renamed keys](https://github.com/jmfontaine/discogs-sdk/blob/main/docs/models.md#field-naming),
168
+ [timestamps parsed into aware `datetime`s](https://github.com/jmfontaine/discogs-sdk/blob/main/docs/models.md#timestamps)
169
+ and the [absolute `uri` on search results](https://github.com/jmfontaine/discogs-sdk/blob/main/docs/models.md#search-result-links).
170
+ A guess the SDK cannot avoid is measured, documented and checkable through `raw`, like the
171
+ `America/Los_Angeles` zone it assumes for a timestamp sent without an offset.
172
+ - **Data is never made up.** The SDK invents no value that the API did not send or that cannot be computed from what
173
+ it sent, such as a guessed currency. A timestamp it cannot parse becomes `None`, not an estimate.
174
+ - **Helpers may combine calls for common use cases.** They send requests only through the SDK's public methods, so
175
+ the cache, retries and `on_request` apply to them as to any other call.
176
+ - **Defaults are safe, sane and unsurprising.** In particular, helpers don't cap their effort by default. A caller who
177
+ wants a bound passes one, and a capped result says whether it is complete.
178
+ - **Undocumented behaviour is quarantined.** A helper that depends on API behaviour Discogs does not document lives in
179
+ [`discogs_sdk.experimental`](#experimental-helpers). It documents that dependency and its consequences, such as
180
+ whether its result can be trusted to be complete; it raises when it detects that the behaviour clearly no longer
181
+ holds; and it may change or be removed without a deprecation period. Core methods never depend on undocumented
182
+ behaviour.
183
+
184
+ ## Experimental helpers
185
+
186
+ `discogs_sdk.experimental` holds helpers that depend on API behaviour Discogs does not document, under the
187
+ [rules above](#design-principles): each may change or be removed without a deprecation period.
188
+
189
+ `releases_added_since()` answers a question the API has no filter for: which releases matching a search were added to
190
+ Discogs on or after a date. It takes a `Discogs` client; `async_releases_added_since()` takes an `AsyncDiscogs` one.
191
+
192
+ ```python
193
+ from datetime import date
194
+
195
+ from discogs_sdk import Discogs
196
+ from discogs_sdk.experimental import releases_added_since
197
+
198
+ with Discogs() as client:
199
+ result = releases_added_since(client, date(2026, 10, 1), artist="Nine Inch Nails")
200
+ for release in result.releases: # newest first
201
+ print(release.date_added, release.title)
202
+ print(result.complete) # False only when max_requests stopped the scan
203
+ ```
204
+
205
+ - **Completeness assumes an undocumented sort.** The helper searches with `sort="date_added"` and
206
+ `sort_order="desc"`, which Discogs answers newest-added first without documenting it, and looks up each result to
207
+ read its `date_added`, stopping at the first release added before the date. Every release it returns has a verified
208
+ date, but a newer release that Discogs sorts after an older one is never seen. A `date_added` newer than the one
209
+ before it shows the sort is not holding and raises `DiscogsError`.
210
+ - **Cost.** One search request per page scanned, plus one lookup per release in the window, plus one for the release
211
+ that ends the scan (none when the results run out first). A release without a `date_added` is skipped and costs a
212
+ lookup too. Cache hits cost nothing, and each retry is one more send.
213
+ - **No cap by default.** `max_requests=N` bounds the HTTP sends, retries included. Once the sends reach it the helper
214
+ returns what it found with `complete=False`; a request already started may still retry, so the total can exceed `N`
215
+ by up to `client.max_retries`.
216
+
217
+ A `date` means the start of that day in UTC; a `datetime` must be timezone-aware. `type` may only be `"release"`, and
218
+ `sort`, `sort_order` and `page` belong to the helper: passing them raises `ValueError` before any request.
219
+
220
+ ## Documentation
221
+
222
+ The full guide lives in [`docs/`](https://github.com/jmfontaine/discogs-sdk/tree/main/docs):
223
+
224
+ - [Getting started](https://github.com/jmfontaine/discogs-sdk/blob/main/docs/getting-started.md) — behaviors to know, installation, fetching, search, sub-resources, async usage
225
+ - [Pagination](https://github.com/jmfontaine/discogs-sdk/blob/main/docs/pagination.md) — what a page costs, stopping early, fetching one page, page attributes
226
+ - [Authentication](https://github.com/jmfontaine/discogs-sdk/blob/main/docs/authentication.md) — personal token, consumer key/secret, OAuth 1.0a, credential precedence
227
+ - [Collection and marketplace](https://github.com/jmfontaine/discogs-sdk/blob/main/docs/collection-and-marketplace.md) — folders, instances, wantlist, listings, orders
228
+ - [Errors and retries](https://github.com/jmfontaine/discogs-sdk/blob/main/docs/errors-and-retries.md) — rate limits, retries, the exception hierarchy
229
+ - [Configuration](https://github.com/jmfontaine/discogs-sdk/blob/main/docs/configuration.md) — every client parameter
230
+ - [Caching](https://github.com/jmfontaine/discogs-sdk/blob/main/docs/caching.md) — the response cache, `no_cache()`, `cache_only()`, custom backends
231
+ - [Observability](https://github.com/jmfontaine/discogs-sdk/blob/main/docs/observability.md) — `client.ratelimit` and `on_request` events
232
+ - [Concurrency](https://github.com/jmfontaine/discogs-sdk/blob/main/docs/concurrency.md) — sharing a client across threads and tasks
233
+ - [Custom HTTP clients](https://github.com/jmfontaine/discogs-sdk/blob/main/docs/http-clients.md) — injecting an `httpx2` client
234
+ - [Models](https://github.com/jmfontaine/discogs-sdk/blob/main/docs/models.md) — field naming, search result links, timestamps, original API values
235
+ - [Migrating from python3-discogs-client](https://github.com/jmfontaine/discogs-sdk/blob/main/docs/migrating-from-python3-discogs-client.md) — idiom-by-idiom translation and behaviour differences
236
+ - [Endpoint map](https://github.com/jmfontaine/discogs-sdk/blob/main/docs/endpoints.md) — which SDK call reaches which Discogs endpoint
237
+ - [AI coding agents](https://github.com/jmfontaine/discogs-sdk/blob/main/docs/ai-agents.md) — installing the packaged agent skill, and a rules snippet for other agents
238
+
239
+ ## Examples
240
+
241
+ The [`examples/`](https://github.com/jmfontaine/discogs-sdk/tree/main/examples) directory has runnable scripts for every feature:
242
+
243
+ - [`quickstart.py`](https://github.com/jmfontaine/discogs-sdk/blob/main/examples/quickstart.py) — first requests, lazy loading, search
244
+ - [`authentication.py`](https://github.com/jmfontaine/discogs-sdk/blob/main/examples/authentication.py) — all auth modes including OAuth 1.0a
245
+ - [`database.py`](https://github.com/jmfontaine/discogs-sdk/blob/main/examples/database.py) — releases, artists, masters, labels, search
246
+ - [`marketplace.py`](https://github.com/jmfontaine/discogs-sdk/blob/main/examples/marketplace.py) — listings, orders, fees, inventory
247
+ - [`collection.py`](https://github.com/jmfontaine/discogs-sdk/blob/main/examples/collection.py) — folders, instances, fields, wantlist
248
+ - [`async_usage.py`](https://github.com/jmfontaine/discogs-sdk/blob/main/examples/async_usage.py) — async client with await and async for
249
+ - [`advanced.py`](https://github.com/jmfontaine/discogs-sdk/blob/main/examples/advanced.py) — error handling, caching, custom HTTP clients, exports
250
+
251
+ ## Contributing
252
+
253
+ Contributions are welcome. See [CONTRIBUTING.md](https://github.com/jmfontaine/discogs-sdk/blob/main/CONTRIBUTING.md) for guidelines.
254
+
255
+ ## License
256
+
257
+ discogs-sdk is licensed under the [Apache License 2.0](https://github.com/jmfontaine/discogs-sdk/blob/main/LICENSE.txt).
@@ -0,0 +1,227 @@
1
+ # discogs-sdk
2
+
3
+ <p align="center">
4
+ <a href="https://pypi.org/project/discogs-sdk/"><img src="https://img.shields.io/pypi/v/discogs-sdk.svg" alt="PyPI version"></a>
5
+ <a href="https://pypi.org/project/discogs-sdk/"><img src="https://img.shields.io/pypi/pyversions/discogs-sdk.svg" alt="Python versions"></a>
6
+ <a href="https://github.com/jmfontaine/discogs-sdk/actions"><img src="https://github.com/jmfontaine/discogs-sdk/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
7
+ <a href="https://pypi.org/project/discogs-sdk/"><img src="https://img.shields.io/pypi/dm/discogs-sdk.svg" alt="PyPI downloads"></a>
8
+ <a href="https://github.com/jmfontaine/discogs-sdk/blob/main/LICENSE.txt"><img src="https://img.shields.io/pypi/l/discogs-sdk.svg" alt="License"></a>
9
+ </p>
10
+
11
+ discogs-sdk is a modern Python client for the [Discogs API](https://www.discogs.com/developers) covering every documented v2 endpoint, with a fluent chainable syntax and built-in response caching.
12
+
13
+ ```python
14
+ from discogs_sdk import Discogs
15
+
16
+ with Discogs() as client:
17
+ release = client.releases.get(352665)
18
+ print(f"{release.title} ({release.year})")
19
+
20
+ for result in client.search(query="Nine Inch Nails", type="artist"):
21
+ print(result.title)
22
+ ```
23
+
24
+ ## Installation
25
+
26
+ ```bash
27
+ pip install discogs-sdk
28
+ # or
29
+ uv add discogs-sdk
30
+ ```
31
+
32
+ Requires Python 3.10+.
33
+
34
+ ## Features
35
+
36
+ - **Complete Endpoint Coverage** — Every route in the Discogs API v2 documentation
37
+ - **Fluent API** — Chain sub-resources naturally: `client.releases.get(id).rating.get()`
38
+ - **Lazy Loading** — No HTTP calls until you actually need the data
39
+ - **Effortless Pagination** — Browse results without managing pages or offsets
40
+ - **Rate Limit Aware** — Bounded retries with `Retry-After` support, the live budget on `client.ratelimit`, and a structured event per request
41
+ - **Built-in Caching** — Optional TTL-based caching reduces API calls
42
+ - **Flexible Auth** — Supports personal tokens, consumer key/secret, or full OAuth 1.0a
43
+ - **Type Safe** — Get autocomplete and IDE support
44
+ - **Async & Sync** — Full support for both synchronous and asynchronous workflows
45
+
46
+ ### How it compares
47
+
48
+ The established alternative is [python3-discogs-client](https://github.com/joalla/discogs_client). Both load data
49
+ lazily, paginate automatically, support OAuth 1.0a and back off on HTTP 429, so the differences that matter are:
50
+
51
+ | | discogs-sdk | python3-discogs-client |
52
+ |---|---|---|
53
+ | Documented v2 API coverage | Complete | Partial † |
54
+ | Sync and async | Both | Sync only |
55
+ | Responses | Typed Pydantic models | Untyped attributes |
56
+ | Response cache | In-memory or SQLite | None |
57
+
58
+ † No inventory export or upload, release ratings or have/want stats, collection fields, folder creation,
59
+ contributions or submissions.
60
+
61
+ Coming from python3-discogs-client? The
62
+ [migration guide](https://github.com/jmfontaine/discogs-sdk/blob/main/docs/migrating-from-python3-discogs-client.md)
63
+ maps each of its idioms to discogs-sdk and names the behaviour that differs.
64
+
65
+ ## Quick start
66
+
67
+ Create a personal access token in [your Discogs developer settings](https://www.discogs.com/settings/developers) and
68
+ export it; the client reads it from the environment
69
+ ([other auth modes](https://github.com/jmfontaine/discogs-sdk/blob/main/docs/authentication.md)):
70
+
71
+ ```bash
72
+ export DISCOGS_TOKEN="your-token-here"
73
+ ```
74
+
75
+ ```python
76
+ from discogs_sdk import Discogs
77
+
78
+ with Discogs() as client:
79
+ release = client.releases.get(352665) # no request yet
80
+ print(release.title) # the GET is sent here → "The Downward Spiral"
81
+
82
+ for rel in client.artists.get(3857).releases.list(sort="year"):
83
+ print(f"{rel.title} ({rel.year})")
84
+ ```
85
+
86
+ The async client has the same API. Await a lazy resource to fetch it, and iterate pages with `async for`:
87
+
88
+ ```python
89
+ import asyncio
90
+
91
+ from discogs_sdk import AsyncDiscogs
92
+
93
+
94
+ async def main():
95
+ async with AsyncDiscogs() as client:
96
+ release = await client.releases.get(352665)
97
+ print(release.title)
98
+
99
+ async for result in client.search(query="Nine Inch Nails", type="artist"):
100
+ print(result.title)
101
+
102
+
103
+ asyncio.run(main())
104
+ ```
105
+
106
+ ## Behaviors to know
107
+
108
+ - **Lazy loading.** `.get()` sends no request; the first data attribute access does, and that is where
109
+ `NotFoundError` is raised. [More](https://github.com/jmfontaine/discogs-sdk/blob/main/docs/getting-started.md#lazy-loading)
110
+ - **Async.** `await` a proxy for its data and use `async for` on pages. Awaiting returns the model, which has no
111
+ sub-resources, so keep the proxy to chain (`artist_proxy.releases.list()`).
112
+ [More](https://github.com/jmfontaine/discogs-sdk/blob/main/docs/getting-started.md#async-proxies)
113
+ - **Pagination cost.** `search()` and most `.list()` methods fetch pages on demand. Each page is a GET against the rate
114
+ limit (60/min authenticated, 25/min anonymous); a cache hit costs nothing (one request if the entry no longer parses)
115
+ and retries can cost more.
116
+ [More](https://github.com/jmfontaine/discogs-sdk/blob/main/docs/pagination.md)
117
+ - **Retries.** Reads retry; a mutation is never replayed after an ambiguous failure.
118
+ [More](https://github.com/jmfontaine/discogs-sdk/blob/main/docs/errors-and-retries.md#settling-an-ambiguous-write)
119
+ - **Caching.** Off by default; only `GET`/`HEAD` are cached; a successful write clears the cache.
120
+ [More](https://github.com/jmfontaine/discogs-sdk/blob/main/docs/caching.md)
121
+
122
+ ## Design principles
123
+
124
+ The SDK does more than relay requests: it pages, retries, renames keys and parses timestamps. These rules say what it
125
+ may and may not do, and every new feature is checked against them.
126
+
127
+ - **Requests stay predictable.** A low-level method sends only the requests its documentation names. Combining calls
128
+ is fine; the method documents the cost, and every call is observable through `on_request`. Auto-paging sends
129
+ one GET per page as you iterate
130
+ ([cost](https://github.com/jmfontaine/discogs-sdk/blob/main/docs/pagination.md#what-a-page-costs)), a lazy proxy
131
+ sends one GET on its first data access
132
+ ([lazy loading](https://github.com/jmfontaine/discogs-sdk/blob/main/docs/getting-started.md#lazy-loading)), and a
133
+ retried read emits one `RequestEvent` whose `attempts` counts every send
134
+ ([observability](https://github.com/jmfontaine/discogs-sdk/blob/main/docs/observability.md)).
135
+ - **Data may be normalized** (names, types, timestamps, URLs) when nothing is lost, because `raw` keeps the original;
136
+ when the result is computed from the response alone; and when the normalization is documented. Examples are
137
+ [renamed keys](https://github.com/jmfontaine/discogs-sdk/blob/main/docs/models.md#field-naming),
138
+ [timestamps parsed into aware `datetime`s](https://github.com/jmfontaine/discogs-sdk/blob/main/docs/models.md#timestamps)
139
+ and the [absolute `uri` on search results](https://github.com/jmfontaine/discogs-sdk/blob/main/docs/models.md#search-result-links).
140
+ A guess the SDK cannot avoid is measured, documented and checkable through `raw`, like the
141
+ `America/Los_Angeles` zone it assumes for a timestamp sent without an offset.
142
+ - **Data is never made up.** The SDK invents no value that the API did not send or that cannot be computed from what
143
+ it sent, such as a guessed currency. A timestamp it cannot parse becomes `None`, not an estimate.
144
+ - **Helpers may combine calls for common use cases.** They send requests only through the SDK's public methods, so
145
+ the cache, retries and `on_request` apply to them as to any other call.
146
+ - **Defaults are safe, sane and unsurprising.** In particular, helpers don't cap their effort by default. A caller who
147
+ wants a bound passes one, and a capped result says whether it is complete.
148
+ - **Undocumented behaviour is quarantined.** A helper that depends on API behaviour Discogs does not document lives in
149
+ [`discogs_sdk.experimental`](#experimental-helpers). It documents that dependency and its consequences, such as
150
+ whether its result can be trusted to be complete; it raises when it detects that the behaviour clearly no longer
151
+ holds; and it may change or be removed without a deprecation period. Core methods never depend on undocumented
152
+ behaviour.
153
+
154
+ ## Experimental helpers
155
+
156
+ `discogs_sdk.experimental` holds helpers that depend on API behaviour Discogs does not document, under the
157
+ [rules above](#design-principles): each may change or be removed without a deprecation period.
158
+
159
+ `releases_added_since()` answers a question the API has no filter for: which releases matching a search were added to
160
+ Discogs on or after a date. It takes a `Discogs` client; `async_releases_added_since()` takes an `AsyncDiscogs` one.
161
+
162
+ ```python
163
+ from datetime import date
164
+
165
+ from discogs_sdk import Discogs
166
+ from discogs_sdk.experimental import releases_added_since
167
+
168
+ with Discogs() as client:
169
+ result = releases_added_since(client, date(2026, 10, 1), artist="Nine Inch Nails")
170
+ for release in result.releases: # newest first
171
+ print(release.date_added, release.title)
172
+ print(result.complete) # False only when max_requests stopped the scan
173
+ ```
174
+
175
+ - **Completeness assumes an undocumented sort.** The helper searches with `sort="date_added"` and
176
+ `sort_order="desc"`, which Discogs answers newest-added first without documenting it, and looks up each result to
177
+ read its `date_added`, stopping at the first release added before the date. Every release it returns has a verified
178
+ date, but a newer release that Discogs sorts after an older one is never seen. A `date_added` newer than the one
179
+ before it shows the sort is not holding and raises `DiscogsError`.
180
+ - **Cost.** One search request per page scanned, plus one lookup per release in the window, plus one for the release
181
+ that ends the scan (none when the results run out first). A release without a `date_added` is skipped and costs a
182
+ lookup too. Cache hits cost nothing, and each retry is one more send.
183
+ - **No cap by default.** `max_requests=N` bounds the HTTP sends, retries included. Once the sends reach it the helper
184
+ returns what it found with `complete=False`; a request already started may still retry, so the total can exceed `N`
185
+ by up to `client.max_retries`.
186
+
187
+ A `date` means the start of that day in UTC; a `datetime` must be timezone-aware. `type` may only be `"release"`, and
188
+ `sort`, `sort_order` and `page` belong to the helper: passing them raises `ValueError` before any request.
189
+
190
+ ## Documentation
191
+
192
+ The full guide lives in [`docs/`](https://github.com/jmfontaine/discogs-sdk/tree/main/docs):
193
+
194
+ - [Getting started](https://github.com/jmfontaine/discogs-sdk/blob/main/docs/getting-started.md) — behaviors to know, installation, fetching, search, sub-resources, async usage
195
+ - [Pagination](https://github.com/jmfontaine/discogs-sdk/blob/main/docs/pagination.md) — what a page costs, stopping early, fetching one page, page attributes
196
+ - [Authentication](https://github.com/jmfontaine/discogs-sdk/blob/main/docs/authentication.md) — personal token, consumer key/secret, OAuth 1.0a, credential precedence
197
+ - [Collection and marketplace](https://github.com/jmfontaine/discogs-sdk/blob/main/docs/collection-and-marketplace.md) — folders, instances, wantlist, listings, orders
198
+ - [Errors and retries](https://github.com/jmfontaine/discogs-sdk/blob/main/docs/errors-and-retries.md) — rate limits, retries, the exception hierarchy
199
+ - [Configuration](https://github.com/jmfontaine/discogs-sdk/blob/main/docs/configuration.md) — every client parameter
200
+ - [Caching](https://github.com/jmfontaine/discogs-sdk/blob/main/docs/caching.md) — the response cache, `no_cache()`, `cache_only()`, custom backends
201
+ - [Observability](https://github.com/jmfontaine/discogs-sdk/blob/main/docs/observability.md) — `client.ratelimit` and `on_request` events
202
+ - [Concurrency](https://github.com/jmfontaine/discogs-sdk/blob/main/docs/concurrency.md) — sharing a client across threads and tasks
203
+ - [Custom HTTP clients](https://github.com/jmfontaine/discogs-sdk/blob/main/docs/http-clients.md) — injecting an `httpx2` client
204
+ - [Models](https://github.com/jmfontaine/discogs-sdk/blob/main/docs/models.md) — field naming, search result links, timestamps, original API values
205
+ - [Migrating from python3-discogs-client](https://github.com/jmfontaine/discogs-sdk/blob/main/docs/migrating-from-python3-discogs-client.md) — idiom-by-idiom translation and behaviour differences
206
+ - [Endpoint map](https://github.com/jmfontaine/discogs-sdk/blob/main/docs/endpoints.md) — which SDK call reaches which Discogs endpoint
207
+ - [AI coding agents](https://github.com/jmfontaine/discogs-sdk/blob/main/docs/ai-agents.md) — installing the packaged agent skill, and a rules snippet for other agents
208
+
209
+ ## Examples
210
+
211
+ The [`examples/`](https://github.com/jmfontaine/discogs-sdk/tree/main/examples) directory has runnable scripts for every feature:
212
+
213
+ - [`quickstart.py`](https://github.com/jmfontaine/discogs-sdk/blob/main/examples/quickstart.py) — first requests, lazy loading, search
214
+ - [`authentication.py`](https://github.com/jmfontaine/discogs-sdk/blob/main/examples/authentication.py) — all auth modes including OAuth 1.0a
215
+ - [`database.py`](https://github.com/jmfontaine/discogs-sdk/blob/main/examples/database.py) — releases, artists, masters, labels, search
216
+ - [`marketplace.py`](https://github.com/jmfontaine/discogs-sdk/blob/main/examples/marketplace.py) — listings, orders, fees, inventory
217
+ - [`collection.py`](https://github.com/jmfontaine/discogs-sdk/blob/main/examples/collection.py) — folders, instances, fields, wantlist
218
+ - [`async_usage.py`](https://github.com/jmfontaine/discogs-sdk/blob/main/examples/async_usage.py) — async client with await and async for
219
+ - [`advanced.py`](https://github.com/jmfontaine/discogs-sdk/blob/main/examples/advanced.py) — error handling, caching, custom HTTP clients, exports
220
+
221
+ ## Contributing
222
+
223
+ Contributions are welcome. See [CONTRIBUTING.md](https://github.com/jmfontaine/discogs-sdk/blob/main/CONTRIBUTING.md) for guidelines.
224
+
225
+ ## License
226
+
227
+ discogs-sdk is licensed under the [Apache License 2.0](https://github.com/jmfontaine/discogs-sdk/blob/main/LICENSE.txt).
@@ -4,7 +4,7 @@ requires = ["uv-build>=0.10.3,<0.14"]
4
4
 
5
5
  [project]
6
6
  name = "discogs-sdk"
7
- version = "0.7.0"
7
+ version = "0.8.0"
8
8
  description = "Modern Python client for the Discogs API"
9
9
  readme = "README.md"
10
10
  keywords = [
@@ -60,6 +60,7 @@ dev = [
60
60
  "ty>=0.0.17",
61
61
  ]
62
62
  test = [
63
+ "markdown-it-py>=3",
63
64
  "pytest>=8.3",
64
65
  "pytest-asyncio>=1.4",
65
66
  "pytest-cov>=6",
@@ -124,6 +125,7 @@ ignore_names = [
124
125
  "_drop_losing_field_names",
125
126
  "_keep_raw",
126
127
  "fast_sqlite_busy_timeout",
128
+ "handle_starttag",
127
129
  "model_config",
128
130
  "pytestmark",
129
131
  ]
@@ -4,7 +4,7 @@ requires = [ "uv-build>=0.10.3,<0.14" ]
4
4
 
5
5
  [project]
6
6
  name = "discogs-sdk"
7
- version = "0.7.0"
7
+ version = "0.8.0"
8
8
  description = "Modern Python client for the Discogs API"
9
9
  readme = "README.md"
10
10
  keywords = [ "api", "discogs", "music", "python", "sdk" ]
@@ -84,7 +84,12 @@ dev = [
84
84
  # registers respx's "httpcore2" mocker, which is what `using="httpcore2"` in
85
85
  # `mock_router` (tests/conftest.py) selects; respx's built-in mockers only
86
86
  # target httpx/httpcore.
87
+ # markdown-it-py parses the Markdown docs for tests/test_doc_links.py and
88
+ # tests/test_doc_examples.py; a CommonMark parser finds links that regular
89
+ # expressions miss (an image inside a link, a definition inside a block quote
90
+ # or wrapped onto the next line) and fences exactly as GitHub does.
87
91
  test = [
92
+ "markdown-it-py>=3",
88
93
  "pytest>=8.3",
89
94
  "pytest-asyncio>=1.4",
90
95
  "pytest-cov>=6",
@@ -151,6 +156,8 @@ ignore_names = [
151
156
  "_drop_losing_field_names",
152
157
  "_keep_raw",
153
158
  "fast_sqlite_busy_timeout",
159
+ # HTMLParser calls it (tests/markdown_links.py).
160
+ "handle_starttag",
154
161
  "model_config",
155
162
  "pytestmark",
156
163
  ]