discogs-sdk 0.3.1__tar.gz → 0.5.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 (75) hide show
  1. discogs_sdk-0.5.0/LICENSE.txt +201 -0
  2. {discogs_sdk-0.3.1 → discogs_sdk-0.5.0}/PKG-INFO +138 -31
  3. {discogs_sdk-0.3.1 → discogs_sdk-0.5.0}/README.md +133 -28
  4. discogs_sdk-0.5.0/pyproject.toml +121 -0
  5. discogs_sdk-0.5.0/pyproject.toml.orig +147 -0
  6. {discogs_sdk-0.3.1 → discogs_sdk-0.5.0}/src/discogs_sdk/__init__.py +32 -5
  7. {discogs_sdk-0.3.1 → discogs_sdk-0.5.0}/src/discogs_sdk/_async/_client.py +203 -51
  8. discogs_sdk-0.5.0/src/discogs_sdk/_async/_lazy.py +112 -0
  9. {discogs_sdk-0.3.1 → discogs_sdk-0.5.0}/src/discogs_sdk/_async/_oauth.py +10 -19
  10. {discogs_sdk-0.3.1 → discogs_sdk-0.5.0}/src/discogs_sdk/_async/_paginator.py +32 -7
  11. {discogs_sdk-0.3.1 → discogs_sdk-0.5.0}/src/discogs_sdk/_async/_resource.py +16 -26
  12. {discogs_sdk-0.3.1 → discogs_sdk-0.5.0}/src/discogs_sdk/_async/resources/artists.py +30 -10
  13. {discogs_sdk-0.3.1 → discogs_sdk-0.5.0}/src/discogs_sdk/_async/resources/collection.py +82 -34
  14. {discogs_sdk-0.3.1 → discogs_sdk-0.5.0}/src/discogs_sdk/_async/resources/exports.py +7 -8
  15. {discogs_sdk-0.3.1 → discogs_sdk-0.5.0}/src/discogs_sdk/_async/resources/labels.py +22 -9
  16. {discogs_sdk-0.3.1 → discogs_sdk-0.5.0}/src/discogs_sdk/_async/resources/lists.py +6 -6
  17. {discogs_sdk-0.3.1 → discogs_sdk-0.5.0}/src/discogs_sdk/_async/resources/marketplace.py +73 -31
  18. {discogs_sdk-0.3.1 → discogs_sdk-0.5.0}/src/discogs_sdk/_async/resources/masters.py +26 -9
  19. discogs_sdk-0.5.0/src/discogs_sdk/_async/resources/releases.py +156 -0
  20. {discogs_sdk-0.3.1 → discogs_sdk-0.5.0}/src/discogs_sdk/_async/resources/uploads.py +9 -12
  21. {discogs_sdk-0.3.1 → discogs_sdk-0.5.0}/src/discogs_sdk/_async/resources/users.py +69 -25
  22. {discogs_sdk-0.3.1 → discogs_sdk-0.5.0}/src/discogs_sdk/_async/resources/wantlist.py +13 -6
  23. discogs_sdk-0.5.0/src/discogs_sdk/_base_client.py +404 -0
  24. {discogs_sdk-0.3.1 → discogs_sdk-0.5.0}/src/discogs_sdk/_cache.py +22 -7
  25. discogs_sdk-0.5.0/src/discogs_sdk/_events.py +71 -0
  26. {discogs_sdk-0.3.1 → discogs_sdk-0.5.0}/src/discogs_sdk/_exceptions.py +24 -1
  27. discogs_sdk-0.5.0/src/discogs_sdk/_oauth_types.py +22 -0
  28. {discogs_sdk-0.3.1 → discogs_sdk-0.5.0}/src/discogs_sdk/_sync/_client.py +180 -37
  29. discogs_sdk-0.5.0/src/discogs_sdk/_sync/_lazy.py +87 -0
  30. {discogs_sdk-0.3.1 → discogs_sdk-0.5.0}/src/discogs_sdk/_sync/_oauth.py +30 -23
  31. {discogs_sdk-0.3.1 → discogs_sdk-0.5.0}/src/discogs_sdk/_sync/_paginator.py +37 -8
  32. discogs_sdk-0.5.0/src/discogs_sdk/_sync/_resource.py +81 -0
  33. {discogs_sdk-0.3.1 → discogs_sdk-0.5.0}/src/discogs_sdk/_sync/resources/artists.py +32 -8
  34. {discogs_sdk-0.3.1 → discogs_sdk-0.5.0}/src/discogs_sdk/_sync/resources/collection.py +97 -32
  35. {discogs_sdk-0.3.1 → discogs_sdk-0.5.0}/src/discogs_sdk/_sync/resources/exports.py +17 -6
  36. {discogs_sdk-0.3.1 → discogs_sdk-0.5.0}/src/discogs_sdk/_sync/resources/labels.py +27 -8
  37. {discogs_sdk-0.3.1 → discogs_sdk-0.5.0}/src/discogs_sdk/_sync/resources/lists.py +11 -3
  38. {discogs_sdk-0.3.1 → discogs_sdk-0.5.0}/src/discogs_sdk/_sync/resources/marketplace.py +88 -24
  39. {discogs_sdk-0.3.1 → discogs_sdk-0.5.0}/src/discogs_sdk/_sync/resources/masters.py +28 -7
  40. discogs_sdk-0.5.0/src/discogs_sdk/_sync/resources/releases.py +162 -0
  41. {discogs_sdk-0.3.1 → discogs_sdk-0.5.0}/src/discogs_sdk/_sync/resources/search.py +7 -1
  42. discogs_sdk-0.5.0/src/discogs_sdk/_sync/resources/uploads.py +40 -0
  43. {discogs_sdk-0.3.1 → discogs_sdk-0.5.0}/src/discogs_sdk/_sync/resources/users.py +78 -27
  44. {discogs_sdk-0.3.1 → discogs_sdk-0.5.0}/src/discogs_sdk/_sync/resources/wantlist.py +23 -8
  45. {discogs_sdk-0.3.1 → discogs_sdk-0.5.0}/src/discogs_sdk/models/__init__.py +23 -4
  46. {discogs_sdk-0.3.1 → discogs_sdk-0.5.0}/src/discogs_sdk/models/_common.py +29 -6
  47. discogs_sdk-0.5.0/src/discogs_sdk/models/_lazy_fields.py +344 -0
  48. {discogs_sdk-0.3.1 → discogs_sdk-0.5.0}/src/discogs_sdk/models/artist.py +3 -1
  49. {discogs_sdk-0.3.1 → discogs_sdk-0.5.0}/src/discogs_sdk/models/collection.py +19 -3
  50. {discogs_sdk-0.3.1 → discogs_sdk-0.5.0}/src/discogs_sdk/models/label.py +3 -1
  51. {discogs_sdk-0.3.1 → discogs_sdk-0.5.0}/src/discogs_sdk/models/list_.py +3 -2
  52. discogs_sdk-0.5.0/src/discogs_sdk/models/marketplace.py +169 -0
  53. {discogs_sdk-0.3.1 → discogs_sdk-0.5.0}/src/discogs_sdk/models/master.py +13 -3
  54. {discogs_sdk-0.3.1 → discogs_sdk-0.5.0}/src/discogs_sdk/models/release.py +4 -1
  55. {discogs_sdk-0.3.1 → discogs_sdk-0.5.0}/src/discogs_sdk/models/search.py +6 -3
  56. {discogs_sdk-0.3.1 → discogs_sdk-0.5.0}/src/discogs_sdk/models/upload.py +2 -3
  57. {discogs_sdk-0.3.1 → discogs_sdk-0.5.0}/src/discogs_sdk/models/user.py +2 -0
  58. {discogs_sdk-0.3.1 → discogs_sdk-0.5.0}/src/discogs_sdk/oauth.py +7 -6
  59. discogs_sdk-0.3.1/pyproject.toml +0 -79
  60. discogs_sdk-0.3.1/src/discogs_sdk/_async/_lazy.py +0 -94
  61. discogs_sdk-0.3.1/src/discogs_sdk/_async/resources/releases.py +0 -96
  62. discogs_sdk-0.3.1/src/discogs_sdk/_base_client.py +0 -182
  63. discogs_sdk-0.3.1/src/discogs_sdk/_sync/_lazy.py +0 -72
  64. discogs_sdk-0.3.1/src/discogs_sdk/_sync/_resource.py +0 -66
  65. discogs_sdk-0.3.1/src/discogs_sdk/_sync/resources/releases.py +0 -81
  66. discogs_sdk-0.3.1/src/discogs_sdk/_sync/resources/uploads.py +0 -31
  67. discogs_sdk-0.3.1/src/discogs_sdk/models/marketplace.py +0 -90
  68. {discogs_sdk-0.3.1 → discogs_sdk-0.5.0}/src/discogs_sdk/_async/__init__.py +0 -0
  69. {discogs_sdk-0.3.1 → discogs_sdk-0.5.0}/src/discogs_sdk/_async/resources/__init__.py +4 -4
  70. {discogs_sdk-0.3.1 → discogs_sdk-0.5.0}/src/discogs_sdk/_async/resources/search.py +0 -0
  71. {discogs_sdk-0.3.1 → discogs_sdk-0.5.0}/src/discogs_sdk/_sync/__init__.py +0 -0
  72. {discogs_sdk-0.3.1 → discogs_sdk-0.5.0}/src/discogs_sdk/_sync/resources/__init__.py +4 -4
  73. {discogs_sdk-0.3.1 → discogs_sdk-0.5.0}/src/discogs_sdk/models/export.py +0 -0
  74. {discogs_sdk-0.3.1 → discogs_sdk-0.5.0}/src/discogs_sdk/models/wantlist.py +0 -0
  75. {discogs_sdk-0.3.1 → discogs_sdk-0.5.0}/src/discogs_sdk/py.typed +0 -0
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Jean-Marc Fontaine
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -1,23 +1,25 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: discogs-sdk
3
- Version: 0.3.1
3
+ Version: 0.5.0
4
4
  Summary: Modern Python client for the Discogs API
5
5
  Keywords: api,discogs,music,python,sdk
6
6
  Author: Jean-Marc Fontaine
7
7
  Author-email: Jean-Marc Fontaine <jm@jmfontaine.net>
8
8
  License-Expression: Apache-2.0
9
+ License-File: LICENSE.txt
9
10
  Classifier: Development Status :: 3 - Alpha
10
11
  Classifier: Intended Audience :: Developers
11
- Classifier: License :: OSI Approved :: Apache Software License
12
12
  Classifier: Programming Language :: Python :: 3 :: Only
13
13
  Classifier: Programming Language :: Python :: 3.10
14
14
  Classifier: Programming Language :: Python :: 3.11
15
15
  Classifier: Programming Language :: Python :: 3.12
16
16
  Classifier: Programming Language :: Python :: 3.13
17
17
  Classifier: Programming Language :: Python :: 3.14
18
+ Classifier: Programming Language :: Python :: 3.15
18
19
  Classifier: Typing :: Typed
19
- Requires-Dist: httpx>=0.28
20
+ Requires-Dist: httpx2>=2.12
20
21
  Requires-Dist: pydantic>=2.12
22
+ Requires-Dist: pydantic>=2.14.0b2,<2.15 ; python_full_version == '3.15.*'
21
23
  Requires-Dist: typing-extensions>=4
22
24
  Requires-Python: >=3.10
23
25
  Project-URL: Homepage, https://github.com/jmfontaine/discogs-sdk
@@ -35,7 +37,7 @@ Description-Content-Type: text/markdown
35
37
  <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>
36
38
  </p>
37
39
 
38
- discogs-sdk is a modern Python client for the [Discogs API](https://www.discogs.com/developers) with full endpoint coverage, a fluent chainable syntax, and built-in response caching.
40
+ 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.
39
41
 
40
42
  ```python
41
43
  from discogs_sdk import Discogs
@@ -60,11 +62,11 @@ Requires Python 3.10+.
60
62
 
61
63
  ## Features
62
64
 
63
- - **Full API Coverage** — Every endpoint in the Discogs API v2
65
+ - **Complete Endpoint Coverage** — Every route in the Discogs API v2 documentation
64
66
  - **Fluent API** — Chain sub-resources naturally: `client.releases.get(id).rating.get()`
65
67
  - **Lazy Loading** — No HTTP calls until you actually need the data
66
68
  - **Effortless Pagination** — Browse results without managing pages or offsets
67
- - **Rate Limit Friendly** — Automatically stay within API limits
69
+ - **Rate Limit Aware** — Bounded retries with `Retry-After` support, the live budget on `client.ratelimit`, and a structured event per request
68
70
  - **Built-in Caching** — Optional TTL-based caching reduces API calls
69
71
  - **Flexible Auth** — Supports personal tokens, consumer key/secret, or full OAuth 1.0a
70
72
  - **Type Safe** — Get autocomplete and IDE support
@@ -72,17 +74,18 @@ Requires Python 3.10+.
72
74
 
73
75
  ### How it compares
74
76
 
77
+ The established alternative is [python3-discogs-client](https://github.com/joalla/discogs_client). Both load data
78
+ lazily, paginate automatically, support OAuth 1.0a and back off on HTTP 429, so the differences that matter are:
79
+
75
80
  | | discogs-sdk | python3-discogs-client |
76
81
  |---|---|---|
77
- | Full API coverage | ✓ | Partial |
78
- | Fluent sub-resource chaining | ✓ | ✗ |
79
- | Lazy loading | ✓ | ✗ |
80
- | Auto-pagination | ✓ | ✓ |
81
- | Automatic rate limit handling | ✓ | ✗ |
82
- | Caching | ✓ | ✗ |
83
- | OAuth 1.0a | ✓ | ✓ |
84
- | Type safe (Pydantic models) | ✓ | ✗ |
85
- | Async & sync | ✓ | ✗ |
82
+ | Documented v2 API coverage | Complete | Partial † |
83
+ | Sync and async | Both | Sync only |
84
+ | Responses | Typed Pydantic models | Untyped attributes |
85
+ | Response cache | In-memory or SQLite | None |
86
+
87
+ † No inventory export or upload, release ratings or have/want stats, collection fields, folder creation,
88
+ contributions or submissions.
86
89
 
87
90
  ## Quick start
88
91
 
@@ -106,15 +109,34 @@ You can also pass credentials explicitly:
106
109
  client = Discogs(token="your-token-here")
107
110
  ```
108
111
 
109
- The SDK supports three auth modes: personal token, consumer key/secret, and OAuth 1.0a. Credentials passed to the constructor take precedence over environment variables (`DISCOGS_TOKEN`, `DISCOGS_CONSUMER_KEY`, etc.). See [`examples/authentication.py`](examples/authentication.py) for the full OAuth flow.
112
+ The SDK supports three auth modes: personal token, consumer key/secret, and OAuth 1.0a. Exactly one mode is selected
113
+ when the client is constructed, and only that mode's credentials are used. The precedence is:
114
+
115
+ 1. An explicit `token` selects personal-token auth and overrides every environment credential.
116
+ 2. Explicit OAuth access-token credentials select OAuth; any missing half may come from the matching `DISCOGS_*`
117
+ variable, but an unrelated environment token never takes over.
118
+ 3. Explicit `consumer_key`/`consumer_secret` select consumer auth, without borrowing environment access tokens.
119
+ 4. With no auth arguments, the environment resolves the mode: `DISCOGS_TOKEN`, then a complete OAuth set, then
120
+ `DISCOGS_CONSUMER_KEY`/`DISCOGS_CONSUMER_SECRET`, then unauthenticated.
121
+
122
+ An explicitly selected but incomplete credential set raises `ValueError` rather than quietly falling back to a
123
+ different account or mode. See [`examples/authentication.py`](examples/authentication.py) for the full OAuth flow.
110
124
 
111
125
  > [!TIP]
112
126
  > Use a `.env` file with [python-dotenv](https://pypi.org/project/python-dotenv/) or
113
127
  > [direnv](https://direnv.net/) to avoid exporting tokens manually in every shell.
114
128
 
115
129
  > [!NOTE]
116
- > Discogs enforces a 60 requests/minute rate limit. The SDK handles this automatically
117
- > with exponential backoff and `Retry-After` support — no manual throttling needed.
130
+ > Discogs allows 60 requests/minute authenticated and 25/minute unauthenticated, measured as a moving average over
131
+ > the last 60 seconds. The SDK does not pace your requests: it retries a rate-limited **read** a bounded number of
132
+ > times (`max_retries`, default 3), honouring `Retry-After`. Sustained traffic above the limit still needs pacing on
133
+ > your side, and you can still receive `RateLimitError` once the retries are exhausted.
134
+
135
+ > [!WARNING]
136
+ > Mutations are not replayed. A `POST`, `PUT` or `DELETE` is retried only when the failure proves the request never
137
+ > reached the server, such as a refused connection. After a read timeout or a 5xx the change may already have been
138
+ > committed, so the SDK raises instead of sending it again — the remote outcome is genuinely unknown and only you
139
+ > can decide how to reconcile it.
118
140
 
119
141
  ### Fetching resources
120
142
 
@@ -160,6 +182,7 @@ for v in client.masters.get(3719).versions.list(format="Vinyl", country="US"):
160
182
  import asyncio
161
183
  from discogs_sdk import AsyncDiscogs
162
184
 
185
+
163
186
  async def main():
164
187
  async with AsyncDiscogs() as client: # reads DISCOGS_TOKEN from environment
165
188
  # Must await lazy resources in async mode
@@ -170,6 +193,7 @@ async def main():
170
193
  async for result in client.search(query="Nine Inch Nails"):
171
194
  print(result.title)
172
195
 
196
+
173
197
  asyncio.run(main())
174
198
  ```
175
199
 
@@ -186,20 +210,22 @@ user.collection.folders.create(name="Industrial")
186
210
  for item in user.collection.folders.get(0).releases.list(sort="added"):
187
211
  print(item.basic_information.title)
188
212
 
189
- # Add a release
190
- user.collection.folders.get(1).releases.create(release_id=352665)
213
+ # Add a release. The response identifies the copy you just created, which is
214
+ # how you tell it apart from copies of the same release you already own.
215
+ created = user.collection.folders.get(1).releases.create(release_id=352665)
191
216
 
192
217
  # Deep chaining: folder -> release -> instance -> fields
193
- user.collection.folders.get(1).releases.get(352665).instances.get(
194
- 98765
195
- ).fields.update(field_id=1, value="Signed copy")
218
+ instances = user.collection.folders.get(1).releases.get(352665).instances
219
+ instances.get(created.instance_id).fields.update(field_id=1, value="Signed copy")
196
220
 
197
221
  # Collection value
198
222
  value = user.collection.value.get()
199
223
  print(f"Median: {value.median}, Maximum: {value.maximum}")
200
224
 
201
- # Wantlist
202
- user.wantlist.create(release_id=352665, notes="Original pressing", rating=4)
225
+ # Wantlist — the add takes only the release id; Discogs drops notes and ratings
226
+ # sent to it, so they go in the update call
227
+ user.wantlist.create(release_id=352665)
228
+ user.wantlist.update(352665, notes="Original pressing", rating=4)
203
229
  for want in user.wantlist.list():
204
230
  print(want.basic_information.title)
205
231
  ```
@@ -210,7 +236,9 @@ for want in user.wantlist.list():
210
236
  # Listings
211
237
  listing = client.marketplace.listings.get(123456789)
212
238
  new = client.marketplace.listings.create(
213
- release_id=352665, condition="Very Good Plus (VG+)", price=25.00,
239
+ release_id=352665,
240
+ condition="Very Good Plus (VG+)",
241
+ price=25.00,
214
242
  )
215
243
  client.marketplace.listings.update(new.id, price=22.50)
216
244
  client.marketplace.listings.delete(new.id)
@@ -235,6 +263,8 @@ except NotFoundError:
235
263
  print("Not found")
236
264
  except RateLimitError as exc:
237
265
  print(f"Rate limited, retry after {exc.retry_after}s")
266
+ if exc.ratelimit: # the 429's own X-Discogs-Ratelimit* headers, when present
267
+ print(f"{exc.ratelimit.used}/{exc.ratelimit.limit} used this window")
238
268
  except AuthenticationError:
239
269
  print("Bad credentials")
240
270
  ```
@@ -244,6 +274,7 @@ The full exception hierarchy:
244
274
  ```
245
275
  DiscogsError
246
276
  ├── DiscogsConnectionError
277
+ ├── CacheMissError
247
278
  └── DiscogsAPIError
248
279
  ├── AuthenticationError (401)
249
280
  ├── ForbiddenError (403)
@@ -276,12 +307,88 @@ The [`examples/`](examples/) directory has runnable scripts for every feature:
276
307
  | `cache` | `False` | Enable response caching, or pass a custom `ResponseCache` instance |
277
308
  | `consumer_key` | `None` | OAuth consumer key |
278
309
  | `consumer_secret` | `None` | OAuth consumer secret |
279
- | `http_client` | `None` | Custom `httpx.Client` or `httpx.AsyncClient` |
280
- | `max_retries` | `3` | Max retries on 429/5xx/connection errors |
310
+ | `http_client` | `None` | Custom `httpx2.Client` or `httpx2.AsyncClient` |
311
+ | `max_retries` | `3` | Max retries; reads retry on 429/5xx, network errors and timeouts, mutations only on pre-send failures |
312
+ | `on_request` | `None` | Callback receiving a `RequestEvent` per request |
281
313
  | `timeout` | `30.0` | Request timeout in seconds |
282
314
  | `token` | `None` | Personal access token |
283
315
 
284
- Credentials are resolved in order: constructor args > environment variables.
316
+ See [Authentication](#authentication) for how a credential mode is selected.
317
+
318
+ ### Caching
319
+
320
+ Only successful `GET`/`HEAD` responses are cached. Entries are keyed by method, fully resolved URL, the effective
321
+ `Accept` representation, and a non-reversible digest of the selected mode's credentials, so two clients sharing one
322
+ cache — or one SQLite directory — never serve each other's private responses, and unauthenticated traffic gets its
323
+ own namespace. No token or secret is stored in a key.
324
+
325
+ `client.no_cache()` bypasses the cache for the current execution context. Scopes nest, the previous state is
326
+ restored even when the block raises, and concurrent tasks or threads each carry their own state:
327
+
328
+ ```python
329
+ with client.no_cache():
330
+ fresh = client.releases.get(352665).title # always hits the API
331
+ ```
332
+
333
+ `client.cache_only()` is the mirror image: inside the scope a request the cache cannot serve — a miss, an expired
334
+ entry, a non-`GET`, a disabled cache or an enclosing `no_cache()` — raises `CacheMissError` before any network I/O.
335
+ It nests and restores exactly like `no_cache()`, so you can try everything for free first:
336
+
337
+ ```python
338
+ from discogs_sdk import CacheMissError
339
+
340
+ with client.cache_only():
341
+ try:
342
+ title = client.releases.get(352665).title # never hits the API
343
+ except CacheMissError as exc:
344
+ print(f"Not cached: {exc.method} {exc.url}")
345
+ ```
346
+
347
+ ### Observability
348
+
349
+ Every live response carries Discogs' `X-Discogs-Ratelimit`, `X-Discogs-Ratelimit-Used` and
350
+ `X-Discogs-Ratelimit-Remaining` headers. `client.ratelimit` holds them as a `RateLimit(limit, used, remaining)`
351
+ parsed from the most recent **network** response: a cache hit never touches it, and a response without the headers
352
+ leaves the last known value in place. It is `None` until the first live response.
353
+
354
+ `on_request` receives one `RequestEvent` per logical request, invoked synchronously — after a cache hit, or after the
355
+ final network response and before any error is raised, so the event exists even when the call raises. Intermediate
356
+ retried attempts do not emit; the final event carries `attempts`. A call that ends in `DiscogsConnectionError` emits
357
+ nothing, since there is no response. Exceptions raised by the callback propagate unchanged; keep it cheap and never
358
+ block in it, because the async client calls it from the event loop.
359
+
360
+ | Field | Meaning |
361
+ |---|---|
362
+ | `method` | Upper-case HTTP method |
363
+ | `url` | Fully resolved URL, query string included |
364
+ | `status_code` | Status of the response that ended the call |
365
+ | `source` | `"network"` or `"cache"` |
366
+ | `elapsed_ms` | Final network attempt, or the cache lookup |
367
+ | `attempts` | Network attempts (`1` = no retry); `0` on a cache hit |
368
+ | `stored` | Whether this call wrote the response to the cache |
369
+ | `ratelimit` | `RateLimit` from the response; always `None` on a cache hit |
370
+
371
+ A minimal pacing loop:
372
+
373
+ ```python
374
+ import time
375
+
376
+ client = Discogs(
377
+ token="...", on_request=lambda e: print(e.source, e.status_code, e.elapsed_ms)
378
+ )
379
+ title = client.releases.get(352665).title # lazy — the GET fires here
380
+ if client.ratelimit and client.ratelimit.remaining < 10:
381
+ time.sleep(60)
382
+ ```
383
+
384
+ ### Custom HTTP clients
385
+
386
+ An injected `http_client` must be an `httpx2` client — the SDK is built on [httpx2](https://github.com/pydantic/httpx2),
387
+ Pydantic's maintained continuation of httpx. It owns its transport configuration and its lifecycle: `client.close()`
388
+ never closes it. SDK credentials, User-Agent and media type are still applied per request, so they describe the request
389
+ without mutating your client's defaults, and its own `httpx2.Auth` cannot replace credentials you gave the SDK. When the
390
+ SDK has no credentials of its own, your client's authentication is preserved and its responses are not cached, because
391
+ the SDK cannot tell whose account they belong to.
285
392
 
286
393
  ## Field naming
287
394
 
@@ -290,7 +397,7 @@ Model fields use clean Python names. Where the Discogs API uses inconsistent or
290
397
  | API field | Python attribute | Models |
291
398
  |---|---|---|
292
399
  | `anv` | `name_variation` | `ArtistCredit` |
293
- | `catno` | `catalog_number` | `LabelCredit`, `Company`, `LabelRelease`, `SearchResult` |
400
+ | `catno` | `catalog_number` | `LabelCredit`, `Company`, `LabelRelease`, `MasterVersion`, `SearchResult` |
294
401
  | `created_ts` | `created_at` | `Export`, `Upload`, `List_` |
295
402
  | `curr_abbr` | `currency_code` | `OriginalPrice`, `User` |
296
403
  | `curr_id` | `currency_id` | `OriginalPrice` |
@@ -307,7 +414,7 @@ Both names work as attributes, so you can use whichever you prefer:
307
414
  ```python
308
415
  release = client.releases.get(352665) # The Downward Spiral
309
416
  print(release.extra_artists) # Python name
310
- print(release.extraartists) # API name — same value
417
+ print(release.extraartists) # API name — same value
311
418
  ```
312
419
 
313
420
  ## Contributing