discogs-typescript 0.1.0
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.
- package/LICENSE +21 -0
- package/README.md +396 -0
- package/dist/index.d.ts +2573 -0
- package/dist/index.js +1739 -0
- package/dist/index.js.map +1 -0
- package/package.json +79 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,2573 @@
|
|
|
1
|
+
/** A long-lived access token. Does not expire unless the user revokes access. */
|
|
2
|
+
export declare interface AccessToken {
|
|
3
|
+
oauthToken: string;
|
|
4
|
+
oauthTokenSecret: string;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Body accepted when adding an order message. At least one of `message` or `status` must be
|
|
9
|
+
* supplied; supplying both prepends
|
|
10
|
+
* `"Seller changed status from Old Status to New Status"` to the message.
|
|
11
|
+
*/
|
|
12
|
+
export declare interface AddOrderMessageParams {
|
|
13
|
+
message?: string;
|
|
14
|
+
status?: OrderStatus;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** Response of {@link MarketplaceResource.addOrderMessage}. */
|
|
18
|
+
export declare interface AddOrderMessageResponse {
|
|
19
|
+
/** Narrower than {@link OrderTextMessage.from} — only these two fields are returned. */
|
|
20
|
+
from: {
|
|
21
|
+
username: string;
|
|
22
|
+
resource_url: string;
|
|
23
|
+
};
|
|
24
|
+
message: string;
|
|
25
|
+
order: {
|
|
26
|
+
id: string;
|
|
27
|
+
resource_url: string;
|
|
28
|
+
};
|
|
29
|
+
timestamp: string;
|
|
30
|
+
subject: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Response of {@link CollectionResource.addReleaseToFolder}. */
|
|
34
|
+
export declare interface AddToCollectionResponse {
|
|
35
|
+
instance_id: number;
|
|
36
|
+
resource_url: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* An artist — a person or group credited on releases.
|
|
41
|
+
*
|
|
42
|
+
* @see https://www.discogs.com/developers/#page:database,header:database-artist
|
|
43
|
+
*/
|
|
44
|
+
export declare interface Artist {
|
|
45
|
+
id: number;
|
|
46
|
+
name: string;
|
|
47
|
+
resource_url: string;
|
|
48
|
+
uri: string;
|
|
49
|
+
releases_url: string;
|
|
50
|
+
profile: string;
|
|
51
|
+
data_quality: DataQuality;
|
|
52
|
+
namevariations?: string[];
|
|
53
|
+
urls?: string[];
|
|
54
|
+
images?: Image_2[];
|
|
55
|
+
members?: ArtistMember[];
|
|
56
|
+
/** @remarks Undocumented; returned by the live API for artists with aliases. */
|
|
57
|
+
aliases?: ArtistMember[];
|
|
58
|
+
/** @remarks Undocumented; returned by the live API for artists who are group members. */
|
|
59
|
+
groups?: ArtistMember[];
|
|
60
|
+
/** @remarks Undocumented; returned by the live API. */
|
|
61
|
+
realname?: string;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** An artist credit as embedded in releases, masters and tracklists. */
|
|
65
|
+
export declare interface ArtistCredit {
|
|
66
|
+
id: number;
|
|
67
|
+
name: string;
|
|
68
|
+
/** Artist name variation used on this particular release; empty when the canonical name is used. */
|
|
69
|
+
anv: string;
|
|
70
|
+
/** Text joining this credit to the next one, e.g. `"&"` or `","`. */
|
|
71
|
+
join: string;
|
|
72
|
+
/** Credited role, e.g. `"Design"`, `"Written-By, Producer"`. Empty for main artists. */
|
|
73
|
+
role: string;
|
|
74
|
+
/** Tracks this credit applies to; empty when it applies to the whole release. */
|
|
75
|
+
tracks: string;
|
|
76
|
+
resource_url: string;
|
|
77
|
+
/** @remarks Undocumented; returned by the live API on some resources. */
|
|
78
|
+
thumbnail_url?: string;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** A master release in an artist's discography. */
|
|
82
|
+
export declare interface ArtistMasterRelease extends ArtistReleaseBase {
|
|
83
|
+
type: 'master';
|
|
84
|
+
main_release: number;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** A member of a band, as listed on an {@link Artist}. */
|
|
88
|
+
export declare interface ArtistMember {
|
|
89
|
+
id: number;
|
|
90
|
+
name: string;
|
|
91
|
+
active: boolean;
|
|
92
|
+
resource_url: string;
|
|
93
|
+
/** @remarks Undocumented; returned by the live API. */
|
|
94
|
+
thumbnail_url?: string;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* An entry in an artist's discography — either a master or an individual release,
|
|
99
|
+
* discriminated by the `type` field.
|
|
100
|
+
*/
|
|
101
|
+
export declare type ArtistRelease = ArtistMasterRelease | ArtistSingleRelease;
|
|
102
|
+
|
|
103
|
+
/** Fields shared by both variants of {@link ArtistRelease}. */
|
|
104
|
+
declare interface ArtistReleaseBase {
|
|
105
|
+
id: number;
|
|
106
|
+
title: string;
|
|
107
|
+
artist: string;
|
|
108
|
+
/** Credited role, e.g. `"Main"`, `"Appearance"`, `"TrackAppearance"`. */
|
|
109
|
+
role: string;
|
|
110
|
+
resource_url: string;
|
|
111
|
+
thumb: string;
|
|
112
|
+
year: number;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** Sort keys accepted by {@link DatabaseResource.getArtistReleases}. */
|
|
116
|
+
export declare type ArtistReleaseSort = 'year' | 'title' | 'format';
|
|
117
|
+
|
|
118
|
+
/** Response of {@link DatabaseResource.getArtistReleases}. */
|
|
119
|
+
export declare type ArtistReleasesResponse = Paginated<'releases', ArtistRelease>;
|
|
120
|
+
|
|
121
|
+
/** A single release in an artist's discography. */
|
|
122
|
+
export declare interface ArtistSingleRelease extends ArtistReleaseBase {
|
|
123
|
+
type: 'release';
|
|
124
|
+
status: SubmissionStatus;
|
|
125
|
+
format: string;
|
|
126
|
+
label: string;
|
|
127
|
+
/** @remarks Undocumented; returned by the live API. */
|
|
128
|
+
stats?: MasterVersionStats;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Any credential shape accepted by the client's `auth` option, or a hand-rolled
|
|
133
|
+
* {@link AuthStrategy}.
|
|
134
|
+
*/
|
|
135
|
+
export declare type AuthOption = TokenCredentials | ConsumerCredentials | OAuthCredentials | AuthStrategy;
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* The authentication strategy contract.
|
|
139
|
+
*
|
|
140
|
+
* @module
|
|
141
|
+
*/
|
|
142
|
+
/** The parts of an outgoing request a strategy may inspect and mutate. */
|
|
143
|
+
export declare interface AuthorizableRequest {
|
|
144
|
+
/** Uppercase HTTP method, e.g. `"GET"`. */
|
|
145
|
+
method: string;
|
|
146
|
+
/** Fully resolved request URL, including the query string. */
|
|
147
|
+
url: URL;
|
|
148
|
+
/** Mutable headers — strategies add their `Authorization` header here. */
|
|
149
|
+
headers: Headers;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* A pluggable authentication scheme.
|
|
154
|
+
*
|
|
155
|
+
* Implementations mutate `headers` in place. `authorize` may be asynchronous because
|
|
156
|
+
* HMAC-SHA1 signing goes through the Web Crypto API.
|
|
157
|
+
*/
|
|
158
|
+
export declare interface AuthStrategy {
|
|
159
|
+
authorize(request: AuthorizableRequest): void | Promise<void>;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/** Condensed release metadata embedded in collection and wantlist items. */
|
|
163
|
+
export declare interface BasicInformation {
|
|
164
|
+
id: number;
|
|
165
|
+
title: string;
|
|
166
|
+
year: number;
|
|
167
|
+
resource_url: string;
|
|
168
|
+
thumb: string;
|
|
169
|
+
/** @remarks Present on most, but not all, collection and wantlist responses. */
|
|
170
|
+
cover_image?: string;
|
|
171
|
+
artists: ArtistCredit[];
|
|
172
|
+
labels: LabelCredit[];
|
|
173
|
+
formats: Format[];
|
|
174
|
+
genres?: string[];
|
|
175
|
+
styles?: string[];
|
|
176
|
+
/** @remarks Undocumented; returned by the live API. */
|
|
177
|
+
master_id?: number;
|
|
178
|
+
/** @remarks Undocumented; returned by the live API. */
|
|
179
|
+
master_url?: string | null;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/** Body accepted by {@link CollectionResource.changeInstance}. */
|
|
183
|
+
export declare interface ChangeInstanceParams {
|
|
184
|
+
/** New rating, 0–5. */
|
|
185
|
+
rating?: number;
|
|
186
|
+
/** Target folder id — supply this to move the instance to a different folder. */
|
|
187
|
+
folder_id?: number;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/** A custom notes field of type `dropdown`, whose value must be one of `options`. */
|
|
191
|
+
export declare interface CollectionDropdownField {
|
|
192
|
+
id: number;
|
|
193
|
+
name: string;
|
|
194
|
+
position: number;
|
|
195
|
+
type: 'dropdown';
|
|
196
|
+
public: boolean;
|
|
197
|
+
options: string[];
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* A user-defined collection notes field, discriminated by `type`.
|
|
202
|
+
*
|
|
203
|
+
* These fields can only be created and deleted through the Discogs website; the API can list
|
|
204
|
+
* them and change their values on an instance.
|
|
205
|
+
*/
|
|
206
|
+
export declare type CollectionField = CollectionDropdownField | CollectionTextareaField;
|
|
207
|
+
|
|
208
|
+
/** Response of {@link CollectionResource.getFields}. */
|
|
209
|
+
export declare interface CollectionFieldsResponse {
|
|
210
|
+
fields: CollectionField[];
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/** A collection folder. */
|
|
214
|
+
export declare interface CollectionFolder {
|
|
215
|
+
id: number;
|
|
216
|
+
name: string;
|
|
217
|
+
/** Number of release instances in the folder. */
|
|
218
|
+
count: number;
|
|
219
|
+
resource_url: string;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/** Response of {@link CollectionResource.getFolders}. */
|
|
223
|
+
export declare interface CollectionFoldersResponse {
|
|
224
|
+
folders: CollectionFolder[];
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* One copy of a release in a collection folder.
|
|
229
|
+
*
|
|
230
|
+
* @remarks `notes` here is an array of field values — on wantlist items, by contrast, `notes`
|
|
231
|
+
* is a plain string.
|
|
232
|
+
*/
|
|
233
|
+
export declare interface CollectionItem {
|
|
234
|
+
/** The release id. */
|
|
235
|
+
id: number;
|
|
236
|
+
/** Identifies this particular copy, since a user may own several. */
|
|
237
|
+
instance_id: number;
|
|
238
|
+
folder_id: number;
|
|
239
|
+
/** 0–5, where `0` means unrated. */
|
|
240
|
+
rating: number;
|
|
241
|
+
date_added: string;
|
|
242
|
+
basic_information: BasicInformation;
|
|
243
|
+
/** Only public fields are returned unless authenticated as the collection owner. */
|
|
244
|
+
notes?: CollectionNote[];
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/** Response of {@link CollectionResource.getItemsByFolder} and `getItemsByRelease`. */
|
|
248
|
+
export declare type CollectionItemsResponse = Paginated<'releases', CollectionItem>;
|
|
249
|
+
|
|
250
|
+
/** The value of one custom notes field on a collection instance. */
|
|
251
|
+
export declare interface CollectionNote {
|
|
252
|
+
field_id: number;
|
|
253
|
+
value: string;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* User collection endpoints.
|
|
258
|
+
*
|
|
259
|
+
* A collection is arranged into folders. Folder `0` is the permanent "All" folder (releases
|
|
260
|
+
* cannot be added to it) and folder `1` is "Uncategorized". Since a user may own several
|
|
261
|
+
* copies of the same release, each copy in a folder is an *instance* with its own
|
|
262
|
+
* `instance_id`.
|
|
263
|
+
*
|
|
264
|
+
* Reachable as `client.collection`.
|
|
265
|
+
*/
|
|
266
|
+
export declare class CollectionResource {
|
|
267
|
+
#private;
|
|
268
|
+
constructor(client: DiscogsClient);
|
|
269
|
+
/**
|
|
270
|
+
* Lists a user's collection folders.
|
|
271
|
+
*
|
|
272
|
+
* Without authentication as the owner, only folder `0` ("All") is visible, and only if the
|
|
273
|
+
* collection is public.
|
|
274
|
+
*
|
|
275
|
+
* @see https://www.discogs.com/developers/#page:user-collection,header:user-collection-collection
|
|
276
|
+
*/
|
|
277
|
+
getFolders(username: string): Promise<CollectionFoldersResponse>;
|
|
278
|
+
/**
|
|
279
|
+
* Creates a new folder. Requires authentication as the collection owner.
|
|
280
|
+
*
|
|
281
|
+
* @see https://www.discogs.com/developers/#page:user-collection,header:user-collection-collection-post
|
|
282
|
+
*/
|
|
283
|
+
createFolder(username: string, name: string): Promise<CollectionFolder>;
|
|
284
|
+
/**
|
|
285
|
+
* Gets a single folder. Requires authentication as the owner unless `folderId` is `0`.
|
|
286
|
+
*
|
|
287
|
+
* @see https://www.discogs.com/developers/#page:user-collection,header:user-collection-collection-folder
|
|
288
|
+
*/
|
|
289
|
+
getFolder(username: string, folderId: number): Promise<CollectionFolder>;
|
|
290
|
+
/**
|
|
291
|
+
* Renames a folder. Requires authentication as the owner.
|
|
292
|
+
*
|
|
293
|
+
* Folders `0` ("All") and `1` ("Uncategorized") cannot be renamed.
|
|
294
|
+
*
|
|
295
|
+
* @see https://www.discogs.com/developers/#page:user-collection,header:user-collection-collection-folder-post
|
|
296
|
+
*/
|
|
297
|
+
editFolder(username: string, folderId: number, name: string): Promise<CollectionFolder>;
|
|
298
|
+
/**
|
|
299
|
+
* Deletes a folder. Requires authentication as the owner, and the folder must be empty.
|
|
300
|
+
*
|
|
301
|
+
* @see https://www.discogs.com/developers/#page:user-collection,header:user-collection-collection-folder-delete
|
|
302
|
+
*/
|
|
303
|
+
deleteFolder(username: string, folderId: number): Promise<void>;
|
|
304
|
+
/**
|
|
305
|
+
* Finds every instance of a given release across a user's collection folders.
|
|
306
|
+
*
|
|
307
|
+
* @param releaseId - Must be non-zero.
|
|
308
|
+
*
|
|
309
|
+
* @see https://www.discogs.com/developers/#page:user-collection,header:user-collection-collection-items-by-release
|
|
310
|
+
*/
|
|
311
|
+
getItemsByRelease(username: string, releaseId: number, params?: PaginationParams): Promise<CollectionItemsResponse>;
|
|
312
|
+
/**
|
|
313
|
+
* Lists the releases in a collection folder.
|
|
314
|
+
*
|
|
315
|
+
* Requires authentication as the owner when `folderId` is not `0` or the collection is
|
|
316
|
+
* private. Without it, only public notes fields are returned.
|
|
317
|
+
*
|
|
318
|
+
* @see https://www.discogs.com/developers/#page:user-collection,header:user-collection-collection-items-by-folder
|
|
319
|
+
*/
|
|
320
|
+
getItemsByFolder(username: string, folderId: number, params?: GetCollectionItemsParams): Promise<CollectionItemsResponse>;
|
|
321
|
+
/**
|
|
322
|
+
* Adds a release to a folder. Requires authentication as the owner.
|
|
323
|
+
*
|
|
324
|
+
* @param folderId - Must be non-zero; pass `1` for "Uncategorized".
|
|
325
|
+
*
|
|
326
|
+
* @see https://www.discogs.com/developers/#page:user-collection,header:user-collection-add-to-collection-folder
|
|
327
|
+
*/
|
|
328
|
+
addReleaseToFolder(username: string, folderId: number, releaseId: number): Promise<AddToCollectionResponse>;
|
|
329
|
+
/**
|
|
330
|
+
* Changes an instance's rating and/or moves it to a different folder. Requires
|
|
331
|
+
* authentication as the owner.
|
|
332
|
+
*
|
|
333
|
+
* Note the two folder ids: `folderId` identifies the folder the instance currently lives in,
|
|
334
|
+
* while `params.folder_id` is the folder to move it to.
|
|
335
|
+
*
|
|
336
|
+
* @see https://www.discogs.com/developers/#page:user-collection,header:user-collection-change-rating-of-release
|
|
337
|
+
*/
|
|
338
|
+
changeInstance(username: string, folderId: number, releaseId: number, instanceId: number, params: ChangeInstanceParams): Promise<void>;
|
|
339
|
+
/**
|
|
340
|
+
* Removes an instance from a collection folder. Requires authentication as the owner.
|
|
341
|
+
*
|
|
342
|
+
* To move it to "Uncategorized" instead of deleting it, use
|
|
343
|
+
* {@link CollectionResource.changeInstance}.
|
|
344
|
+
*
|
|
345
|
+
* @see https://www.discogs.com/developers/#page:user-collection,header:user-collection-delete-instance-from-folder
|
|
346
|
+
*/
|
|
347
|
+
deleteInstance(username: string, folderId: number, releaseId: number, instanceId: number): Promise<void>;
|
|
348
|
+
/**
|
|
349
|
+
* Lists a user's custom collection notes fields.
|
|
350
|
+
*
|
|
351
|
+
* These can only be created and deleted through the Discogs website. Without authentication
|
|
352
|
+
* as the owner, only fields with `public: true` are returned.
|
|
353
|
+
*
|
|
354
|
+
* @see https://www.discogs.com/developers/#page:user-collection,header:user-collection-list-custom-fields
|
|
355
|
+
*/
|
|
356
|
+
getFields(username: string): Promise<CollectionFieldsResponse>;
|
|
357
|
+
/**
|
|
358
|
+
* Sets the value of a custom notes field on a collection instance.
|
|
359
|
+
*
|
|
360
|
+
* @param value - For a `dropdown` field this must be one of the field's `options`. Sent as a
|
|
361
|
+
* query-string parameter, which is what this endpoint expects.
|
|
362
|
+
*
|
|
363
|
+
* @see https://www.discogs.com/developers/#page:user-collection,header:user-collection-edit-fields-instance
|
|
364
|
+
*/
|
|
365
|
+
editFieldInstance(username: string, folderId: number, releaseId: number, instanceId: number, fieldId: number, value: string): Promise<void>;
|
|
366
|
+
/**
|
|
367
|
+
* Gets the minimum, median and maximum value of a collection, as currency-formatted strings.
|
|
368
|
+
* Requires authentication as the collection owner.
|
|
369
|
+
*
|
|
370
|
+
* @see https://www.discogs.com/developers/#page:user-collection,header:user-collection-collection-value
|
|
371
|
+
*/
|
|
372
|
+
getValue(username: string): Promise<CollectionValue>;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
/** Sort keys accepted by {@link CollectionResource.getItemsByFolder}. */
|
|
376
|
+
export declare type CollectionSort = 'label' | 'artist' | 'title' | 'catno' | 'format' | 'rating' | 'added' | 'year';
|
|
377
|
+
|
|
378
|
+
/** A custom notes field of type `textarea`, which accepts free text. */
|
|
379
|
+
export declare interface CollectionTextareaField {
|
|
380
|
+
id: number;
|
|
381
|
+
name: string;
|
|
382
|
+
position: number;
|
|
383
|
+
type: 'textarea';
|
|
384
|
+
public: boolean;
|
|
385
|
+
/** Height of the input on the website, in lines. */
|
|
386
|
+
lines: number;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* The estimated value of a collection.
|
|
391
|
+
*
|
|
392
|
+
* All three values are currency-formatted strings (e.g. `"$250.00"`), not numbers.
|
|
393
|
+
*/
|
|
394
|
+
export declare interface CollectionValue {
|
|
395
|
+
minimum: string;
|
|
396
|
+
median: string;
|
|
397
|
+
maximum: string;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
/** Aggregate community rating for a release. */
|
|
401
|
+
export declare interface CommunityRating {
|
|
402
|
+
average: number;
|
|
403
|
+
count: number;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
/** Aggregate community rating for a release. */
|
|
407
|
+
export declare interface CommunityReleaseRating {
|
|
408
|
+
release_id: number;
|
|
409
|
+
rating: CommunityRating;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
/** A company credit (pressing plant, copyright holder, distributor, …). */
|
|
413
|
+
export declare interface CompanyCredit {
|
|
414
|
+
id: number;
|
|
415
|
+
name: string;
|
|
416
|
+
catno: string;
|
|
417
|
+
entity_type: string;
|
|
418
|
+
entity_type_name: string;
|
|
419
|
+
resource_url: string;
|
|
420
|
+
/** @remarks Undocumented; returned by the live API on some resources. */
|
|
421
|
+
thumbnail_url?: string;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
/** Options for the conditional-request variants of the status endpoints. */
|
|
425
|
+
export declare interface ConditionalRequestOptions {
|
|
426
|
+
/**
|
|
427
|
+
* Sets `If-Modified-Since`. When the export has not changed since this time Discogs answers
|
|
428
|
+
* `304 Not Modified` and the method resolves to `null`.
|
|
429
|
+
*/
|
|
430
|
+
ifModifiedSince?: string | Date;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
/**
|
|
434
|
+
* Credentials for a consumer key/secret pair.
|
|
435
|
+
*
|
|
436
|
+
* These raise your rate limit and unlock image URLs, but do not authenticate you as any
|
|
437
|
+
* particular user.
|
|
438
|
+
*/
|
|
439
|
+
export declare interface ConsumerCredentials {
|
|
440
|
+
consumerKey: string;
|
|
441
|
+
consumerSecret: string;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
/** Sort keys accepted by {@link UserResource.getContributions}. */
|
|
445
|
+
export declare type ContributionSort = 'label' | 'artist' | 'title' | 'catno' | 'format' | 'rating' | 'year' | 'added';
|
|
446
|
+
|
|
447
|
+
/** Response of {@link UserResource.getContributions}. */
|
|
448
|
+
export declare type ContributionsResponse = Paginated<'contributions', Release>;
|
|
449
|
+
|
|
450
|
+
/** Result of requesting a new export. */
|
|
451
|
+
export declare interface CreateExportResult {
|
|
452
|
+
/**
|
|
453
|
+
* Id of the newly created export, parsed out of the `Location` response header, or `null`
|
|
454
|
+
* if Discogs did not send one.
|
|
455
|
+
*/
|
|
456
|
+
id: number | null;
|
|
457
|
+
/** The raw `Location` header, e.g. `https://api.discogs.com/inventory/export/599632`. */
|
|
458
|
+
location: string | null;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
/**
|
|
462
|
+
* Body accepted when creating a listing.
|
|
463
|
+
*
|
|
464
|
+
* `weight` and `format_quantity` additionally accept the literal string `"auto"`, which asks
|
|
465
|
+
* Discogs to estimate the value.
|
|
466
|
+
*/
|
|
467
|
+
export declare interface CreateListingParams {
|
|
468
|
+
/** The release being listed. */
|
|
469
|
+
release_id: number;
|
|
470
|
+
condition: MediaCondition;
|
|
471
|
+
sleeve_condition?: SleeveCondition;
|
|
472
|
+
/** Price in the seller's currency. */
|
|
473
|
+
price: number;
|
|
474
|
+
/** Remarks displayed to buyers. */
|
|
475
|
+
comments?: string;
|
|
476
|
+
/** Defaults to `false`. */
|
|
477
|
+
allow_offers?: boolean;
|
|
478
|
+
/** Defaults to `"For Sale"`. */
|
|
479
|
+
status?: ListingStatus;
|
|
480
|
+
/** Seller-private reference, shown as "Private Comments" on the website. */
|
|
481
|
+
external_id?: string;
|
|
482
|
+
/** Seller-private physical storage location. */
|
|
483
|
+
location?: string;
|
|
484
|
+
/** Shipping weight in grams, or `"auto"` to let Discogs estimate it. */
|
|
485
|
+
weight?: number | 'auto';
|
|
486
|
+
/** How many items this counts as for shipping, or `"auto"`. */
|
|
487
|
+
format_quantity?: number | 'auto';
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
/** Response of {@link MarketplaceResource.createListing}. */
|
|
491
|
+
export declare interface CreateListingResponse {
|
|
492
|
+
listing_id: number;
|
|
493
|
+
resource_url: string;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
/** Result of submitting an inventory upload. */
|
|
497
|
+
export declare interface CreateUploadResult {
|
|
498
|
+
/**
|
|
499
|
+
* Id of the newly created upload, parsed out of the `Location` response header, or `null`
|
|
500
|
+
* if Discogs did not send one.
|
|
501
|
+
*/
|
|
502
|
+
id: number | null;
|
|
503
|
+
/** The raw `Location` header, e.g. `https://api.discogs.com/inventory/upload/599632`. */
|
|
504
|
+
location: string | null;
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
/**
|
|
508
|
+
* A CSV payload for an inventory upload.
|
|
509
|
+
*
|
|
510
|
+
* A string is wrapped in a `text/csv` {@link Blob} automatically; pass a `Blob` or `File`
|
|
511
|
+
* directly to control the filename and content type.
|
|
512
|
+
*/
|
|
513
|
+
export declare type CsvUpload = string | Blob;
|
|
514
|
+
|
|
515
|
+
/** Every {@link Currency} value, in the order the Discogs docs list them. */
|
|
516
|
+
export declare const CURRENCIES: readonly Currency[];
|
|
517
|
+
|
|
518
|
+
/**
|
|
519
|
+
* Shared primitives that appear across many Discogs resources.
|
|
520
|
+
*
|
|
521
|
+
* @module
|
|
522
|
+
*/
|
|
523
|
+
/**
|
|
524
|
+
* Currency codes accepted by the `curr_abbr` parameter and returned in price objects.
|
|
525
|
+
*
|
|
526
|
+
* @see https://www.discogs.com/developers/#page:database,header:database-release
|
|
527
|
+
*/
|
|
528
|
+
export declare type Currency = 'USD' | 'GBP' | 'EUR' | 'CAD' | 'AUD' | 'JPY' | 'CHF' | 'MXN' | 'BRL' | 'NZD' | 'SEK' | 'ZAR';
|
|
529
|
+
|
|
530
|
+
/**
|
|
531
|
+
* Database endpoints.
|
|
532
|
+
*
|
|
533
|
+
* Reachable as `client.database`.
|
|
534
|
+
*/
|
|
535
|
+
export declare class DatabaseResource {
|
|
536
|
+
#private;
|
|
537
|
+
constructor(client: DiscogsClient);
|
|
538
|
+
/**
|
|
539
|
+
* Gets a release.
|
|
540
|
+
*
|
|
541
|
+
* @param releaseId - The release id.
|
|
542
|
+
* @param params - Optional currency for the embedded marketplace data.
|
|
543
|
+
*
|
|
544
|
+
* @see https://www.discogs.com/developers/#page:database,header:database-release
|
|
545
|
+
*/
|
|
546
|
+
getRelease(releaseId: number, params?: GetReleaseParams): Promise<Release>;
|
|
547
|
+
/**
|
|
548
|
+
* Gets a particular user's rating of a release.
|
|
549
|
+
*
|
|
550
|
+
* @see https://www.discogs.com/developers/#page:database,header:database-release-rating-by-user
|
|
551
|
+
*/
|
|
552
|
+
getReleaseRating(releaseId: number, username: string): Promise<ReleaseRating>;
|
|
553
|
+
/**
|
|
554
|
+
* Sets a user's rating of a release. Requires authentication as that user.
|
|
555
|
+
*
|
|
556
|
+
* @param rating - The new rating, between 1 and 5.
|
|
557
|
+
*
|
|
558
|
+
* @see https://www.discogs.com/developers/#page:database,header:database-release-rating-by-user
|
|
559
|
+
*/
|
|
560
|
+
updateReleaseRating(releaseId: number, username: string, rating: number): Promise<ReleaseRating>;
|
|
561
|
+
/**
|
|
562
|
+
* Deletes a user's rating of a release. Requires authentication as that user.
|
|
563
|
+
*
|
|
564
|
+
* @see https://www.discogs.com/developers/#page:database,header:database-release-rating-by-user
|
|
565
|
+
*/
|
|
566
|
+
deleteReleaseRating(releaseId: number, username: string): Promise<void>;
|
|
567
|
+
/**
|
|
568
|
+
* Gets the community's average rating and rating count for a release.
|
|
569
|
+
*
|
|
570
|
+
* @see https://www.discogs.com/developers/#page:database,header:database-community-release-rating
|
|
571
|
+
*/
|
|
572
|
+
getCommunityReleaseRating(releaseId: number): Promise<CommunityReleaseRating>;
|
|
573
|
+
/**
|
|
574
|
+
* Gets the "have" and "want" counts for a release.
|
|
575
|
+
*
|
|
576
|
+
* @see https://www.discogs.com/developers/#page:database,header:database-release-stats
|
|
577
|
+
*/
|
|
578
|
+
getReleaseStats(releaseId: number): Promise<ReleaseStats>;
|
|
579
|
+
/**
|
|
580
|
+
* Gets a master release.
|
|
581
|
+
*
|
|
582
|
+
* @see https://www.discogs.com/developers/#page:database,header:database-master-release
|
|
583
|
+
*/
|
|
584
|
+
getMaster(masterId: number): Promise<Master>;
|
|
585
|
+
/**
|
|
586
|
+
* Lists all releases that are versions of a master release.
|
|
587
|
+
*
|
|
588
|
+
* @see https://www.discogs.com/developers/#page:database,header:database-master-release-versions
|
|
589
|
+
*/
|
|
590
|
+
getMasterVersions(masterId: number, params?: GetMasterVersionsParams): Promise<MasterVersionsResponse>;
|
|
591
|
+
/**
|
|
592
|
+
* Gets an artist.
|
|
593
|
+
*
|
|
594
|
+
* @see https://www.discogs.com/developers/#page:database,header:database-artist
|
|
595
|
+
*/
|
|
596
|
+
getArtist(artistId: number): Promise<Artist>;
|
|
597
|
+
/**
|
|
598
|
+
* Lists the releases and masters associated with an artist.
|
|
599
|
+
*
|
|
600
|
+
* Entries are discriminated by their `type` field: `"master"` or `"release"`.
|
|
601
|
+
*
|
|
602
|
+
* @see https://www.discogs.com/developers/#page:database,header:database-artist-releases
|
|
603
|
+
*/
|
|
604
|
+
getArtistReleases(artistId: number, params?: GetArtistReleasesParams): Promise<ArtistReleasesResponse>;
|
|
605
|
+
/**
|
|
606
|
+
* Gets a label.
|
|
607
|
+
*
|
|
608
|
+
* @see https://www.discogs.com/developers/#page:database,header:database-label
|
|
609
|
+
*/
|
|
610
|
+
getLabel(labelId: number): Promise<Label>;
|
|
611
|
+
/**
|
|
612
|
+
* Lists the releases associated with a label.
|
|
613
|
+
*
|
|
614
|
+
* @see https://www.discogs.com/developers/#page:database,header:database-all-label-releases
|
|
615
|
+
*/
|
|
616
|
+
getLabelReleases(labelId: number, params?: PaginationParams): Promise<LabelReleasesResponse>;
|
|
617
|
+
/**
|
|
618
|
+
* Searches the Discogs database.
|
|
619
|
+
*
|
|
620
|
+
* **Authentication (as any user) is required.** Unauthenticated searches fail with a 401.
|
|
621
|
+
*
|
|
622
|
+
* @example
|
|
623
|
+
* ```ts
|
|
624
|
+
* await client.database.search({ artist: 'nirvana', release_title: 'nevermind', per_page: 3 });
|
|
625
|
+
* ```
|
|
626
|
+
*
|
|
627
|
+
* @see https://www.discogs.com/developers/#page:database,header:database-search
|
|
628
|
+
*/
|
|
629
|
+
search(params?: SearchParams): Promise<SearchResponse>;
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
/**
|
|
633
|
+
* Data-quality marker set by the Discogs community, e.g. `"Correct"`, `"Needs Vote"`,
|
|
634
|
+
* `"Complete and Correct"`. Not exhaustively enumerated by the API docs, so left as a string.
|
|
635
|
+
*/
|
|
636
|
+
export declare type DataQuality = string;
|
|
637
|
+
|
|
638
|
+
/** Default base URL of the Discogs API. */
|
|
639
|
+
export declare const DEFAULT_BASE_URL = "https://api.discogs.com";
|
|
640
|
+
|
|
641
|
+
/** Default number of items Discogs returns per page. */
|
|
642
|
+
export declare const DEFAULT_PER_PAGE = 50;
|
|
643
|
+
|
|
644
|
+
/** Default base URL of the Discogs website, which hosts the authorize page. */
|
|
645
|
+
export declare const DEFAULT_WEBSITE_URL = "https://www.discogs.com";
|
|
646
|
+
|
|
647
|
+
/** 401 — the resource requires authentication, or the supplied credentials were rejected. */
|
|
648
|
+
export declare class DiscogsAuthenticationError extends DiscogsError {
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
/**
|
|
652
|
+
* A client for the Discogs API v2.
|
|
653
|
+
*
|
|
654
|
+
* Endpoints are grouped into resources that mirror the sections of the Discogs documentation.
|
|
655
|
+
*
|
|
656
|
+
* @example
|
|
657
|
+
* ```ts
|
|
658
|
+
* const client = new DiscogsClient({
|
|
659
|
+
* userAgent: 'MyApp/1.0 +https://example.com',
|
|
660
|
+
* auth: { token: process.env.DISCOGS_TOKEN! },
|
|
661
|
+
* });
|
|
662
|
+
*
|
|
663
|
+
* const release = await client.database.getRelease(249504);
|
|
664
|
+
* const results = await client.database.search({ artist: 'nirvana', type: 'release' });
|
|
665
|
+
* ```
|
|
666
|
+
*
|
|
667
|
+
* @see https://www.discogs.com/developers/
|
|
668
|
+
*/
|
|
669
|
+
export declare class DiscogsClient {
|
|
670
|
+
#private;
|
|
671
|
+
/** Database: releases, masters, artists, labels and search. */
|
|
672
|
+
readonly database: DatabaseResource;
|
|
673
|
+
/** Marketplace: inventory, listings, orders, fees, price suggestions and stats. */
|
|
674
|
+
readonly marketplace: MarketplaceResource;
|
|
675
|
+
/** Inventory export: request and download CSV exports of your inventory. */
|
|
676
|
+
readonly inventoryExport: InventoryExportResource;
|
|
677
|
+
/** Inventory upload: bulk add, change and delete listings from a CSV. */
|
|
678
|
+
readonly inventoryUpload: InventoryUploadResource;
|
|
679
|
+
/** User identity: the authenticated user, profiles, submissions and contributions. */
|
|
680
|
+
readonly user: UserResource;
|
|
681
|
+
/** User collection: folders, items, custom fields and collection value. */
|
|
682
|
+
readonly collection: CollectionResource;
|
|
683
|
+
/** User wantlist. */
|
|
684
|
+
readonly wantlist: WantlistResource;
|
|
685
|
+
/** User lists. */
|
|
686
|
+
readonly lists: ListsResource;
|
|
687
|
+
constructor(config: DiscogsClientConfig);
|
|
688
|
+
/**
|
|
689
|
+
* Rate-limit state from the most recent response, or `null` if no response has carried the
|
|
690
|
+
* headers yet.
|
|
691
|
+
*
|
|
692
|
+
* Because this reflects only the latest response it is unreliable while requests overlap —
|
|
693
|
+
* use the `onResponse` config option when you need per-request accuracy.
|
|
694
|
+
*/
|
|
695
|
+
get rateLimit(): RateLimit | null;
|
|
696
|
+
/**
|
|
697
|
+
* Sends an arbitrary request to the API, returning the parsed body together with the raw
|
|
698
|
+
* response and its rate-limit headers.
|
|
699
|
+
*
|
|
700
|
+
* Use this to reach anything the typed resources do not cover, or when you need response
|
|
701
|
+
* headers such as `Location` or `Last-Modified`.
|
|
702
|
+
*
|
|
703
|
+
* @example
|
|
704
|
+
* ```ts
|
|
705
|
+
* const { data, rateLimit } = await client.request<Release>({ path: '/releases/249504' });
|
|
706
|
+
* ```
|
|
707
|
+
*/
|
|
708
|
+
request<T>(options: RequestOptions): Promise<DiscogsResponse<T>>;
|
|
709
|
+
/* Excluded from this release type: requestData */
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
/** Configuration for {@link DiscogsClient}. */
|
|
713
|
+
export declare interface DiscogsClientConfig {
|
|
714
|
+
/**
|
|
715
|
+
* Identifies your application to Discogs. **Required** — Discogs returns an empty response
|
|
716
|
+
* to requests without a User-Agent, and rejects strings that impersonate a browser or a
|
|
717
|
+
* generic HTTP library.
|
|
718
|
+
*
|
|
719
|
+
* @example `'MyDiscogsClient/1.0 +https://mydiscogsclient.org'`
|
|
720
|
+
*/
|
|
721
|
+
userAgent: string;
|
|
722
|
+
/**
|
|
723
|
+
* Credentials. Omit to make unauthenticated requests, which are limited to 25 requests per
|
|
724
|
+
* minute and receive no image URLs.
|
|
725
|
+
*
|
|
726
|
+
* - `{ token }` — a personal access token; authenticates as the token holder.
|
|
727
|
+
* - `{ consumerKey, consumerSecret }` — raises the rate limit and unlocks image URLs, but
|
|
728
|
+
* authenticates as no one.
|
|
729
|
+
* - `{ consumerKey, consumerSecret, accessToken, accessTokenSecret }` — full OAuth 1.0a;
|
|
730
|
+
* authenticates as the user who granted access. See {@link DiscogsOAuth}.
|
|
731
|
+
*/
|
|
732
|
+
auth?: AuthOption;
|
|
733
|
+
/** Override the API base URL. Defaults to `https://api.discogs.com`. */
|
|
734
|
+
baseUrl?: string;
|
|
735
|
+
/**
|
|
736
|
+
* Which representation to request. Discogs offers `discogs` (raw markup in text fields),
|
|
737
|
+
* `html`, and `plaintext`. Defaults to `discogs`, which is also the server-side default.
|
|
738
|
+
*/
|
|
739
|
+
mediaType?: MediaType;
|
|
740
|
+
/** Custom `fetch` implementation. Defaults to the global one. */
|
|
741
|
+
fetch?: typeof globalThis.fetch;
|
|
742
|
+
/**
|
|
743
|
+
* Called after every response, before the body is read.
|
|
744
|
+
*
|
|
745
|
+
* This is the reliable way to observe rate-limit state per request —
|
|
746
|
+
* {@link DiscogsClient.rateLimit} only holds the most recent value and is therefore racy
|
|
747
|
+
* when requests overlap.
|
|
748
|
+
*/
|
|
749
|
+
onResponse?: (info: {
|
|
750
|
+
response: Response;
|
|
751
|
+
rateLimit: RateLimit | null;
|
|
752
|
+
}) => void;
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
/**
|
|
756
|
+
* Base class for every error the client throws for a failed API response.
|
|
757
|
+
*
|
|
758
|
+
* Use `instanceof DiscogsError` to catch all of them, or one of the subclasses below to
|
|
759
|
+
* handle a specific status.
|
|
760
|
+
*/
|
|
761
|
+
export declare class DiscogsError extends Error {
|
|
762
|
+
/** HTTP status code of the failing response. */
|
|
763
|
+
readonly status: number;
|
|
764
|
+
/** The raw response object. */
|
|
765
|
+
readonly response: Response;
|
|
766
|
+
/** Parsed response body, when it could be read. */
|
|
767
|
+
readonly body: unknown;
|
|
768
|
+
constructor(message: string, options: DiscogsErrorOptions);
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
/**
|
|
772
|
+
* The error payload Discogs returns for every non-2xx response.
|
|
773
|
+
*
|
|
774
|
+
* @example `{ "message": "Release not found." }`
|
|
775
|
+
*/
|
|
776
|
+
export declare interface DiscogsErrorBody {
|
|
777
|
+
message: string;
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
/** Options carried by every {@link DiscogsError}. */
|
|
781
|
+
export declare interface DiscogsErrorOptions {
|
|
782
|
+
/** HTTP status code of the failing response. */
|
|
783
|
+
status: number;
|
|
784
|
+
/** The raw response, in case you need headers or want to re-read the body. */
|
|
785
|
+
response: Response;
|
|
786
|
+
/** Parsed response body, when it could be read. */
|
|
787
|
+
body?: unknown;
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
/** 405 — the HTTP verb is not supported for this resource (e.g. `PUT /artists/1`). */
|
|
791
|
+
export declare class DiscogsMethodNotAllowedError extends DiscogsError {
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
/** 404 — the resource does not exist. */
|
|
795
|
+
export declare class DiscogsNotFoundError extends DiscogsError {
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
/**
|
|
799
|
+
* Drives the three-legged OAuth 1.0a flow that yields an access token for a Discogs user.
|
|
800
|
+
*
|
|
801
|
+
* Once you have the access token, hand it to {@link DiscogsClient} as the `auth` option.
|
|
802
|
+
*
|
|
803
|
+
* @example
|
|
804
|
+
* ```ts
|
|
805
|
+
* const oauth = new DiscogsOAuth({
|
|
806
|
+
* consumerKey: process.env.DISCOGS_CONSUMER_KEY!,
|
|
807
|
+
* consumerSecret: process.env.DISCOGS_CONSUMER_SECRET!,
|
|
808
|
+
* userAgent: 'MyApp/1.0 +https://example.com',
|
|
809
|
+
* });
|
|
810
|
+
*
|
|
811
|
+
* // 1. Get a temporary request token and send the user to Discogs.
|
|
812
|
+
* const request = await oauth.getRequestToken('https://example.com/callback');
|
|
813
|
+
* console.log(oauth.getAuthorizeUrl(request.oauthToken));
|
|
814
|
+
*
|
|
815
|
+
* // 2. Discogs redirects back with ?oauth_verifier=… — exchange it for an access token.
|
|
816
|
+
* const access = await oauth.getAccessToken({ ...request, verifier });
|
|
817
|
+
*
|
|
818
|
+
* // 3. Use it.
|
|
819
|
+
* const client = new DiscogsClient({
|
|
820
|
+
* userAgent: 'MyApp/1.0 +https://example.com',
|
|
821
|
+
* auth: {
|
|
822
|
+
* consumerKey, consumerSecret,
|
|
823
|
+
* accessToken: access.oauthToken,
|
|
824
|
+
* accessTokenSecret: access.oauthTokenSecret,
|
|
825
|
+
* },
|
|
826
|
+
* });
|
|
827
|
+
* ```
|
|
828
|
+
*/
|
|
829
|
+
export declare class DiscogsOAuth {
|
|
830
|
+
#private;
|
|
831
|
+
constructor(config: DiscogsOAuthConfig);
|
|
832
|
+
/**
|
|
833
|
+
* Step 1 — requests a temporary token from `GET /oauth/request_token`.
|
|
834
|
+
*
|
|
835
|
+
* @param callbackUrl - Where Discogs should send the user after they approve access. Pass
|
|
836
|
+
* `'oob'` (out of band) when you have no callback URL and want the user to type the
|
|
837
|
+
* verifier in manually.
|
|
838
|
+
*/
|
|
839
|
+
getRequestToken(callbackUrl: string): Promise<RequestToken>;
|
|
840
|
+
/**
|
|
841
|
+
* Step 2 — the URL to send the user to so they can approve your application.
|
|
842
|
+
*
|
|
843
|
+
* @param requestToken - The `oauthToken` from {@link DiscogsOAuth.getRequestToken}.
|
|
844
|
+
*/
|
|
845
|
+
getAuthorizeUrl(requestToken: string): string;
|
|
846
|
+
/**
|
|
847
|
+
* Step 3 — exchanges the approved request token for a long-lived access token via
|
|
848
|
+
* `POST /oauth/access_token`.
|
|
849
|
+
*
|
|
850
|
+
* Request tokens and verifiers expire 15 minutes after they are issued; an expired or
|
|
851
|
+
* malformed exchange fails with a 400.
|
|
852
|
+
*/
|
|
853
|
+
getAccessToken(params: GetAccessTokenParams): Promise<AccessToken>;
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
/** Configuration for {@link DiscogsOAuth}. */
|
|
857
|
+
export declare interface DiscogsOAuthConfig extends OAuthNonceOptions {
|
|
858
|
+
consumerKey: string;
|
|
859
|
+
consumerSecret: string;
|
|
860
|
+
/**
|
|
861
|
+
* Identifies your application to Discogs. Required — requests without a User-Agent receive
|
|
862
|
+
* an empty response.
|
|
863
|
+
*
|
|
864
|
+
* @example `'MyDiscogsClient/1.0 +https://mydiscogsclient.org'`
|
|
865
|
+
*/
|
|
866
|
+
userAgent: string;
|
|
867
|
+
/** Defaults to `"PLAINTEXT"`, as recommended by the Discogs documentation. */
|
|
868
|
+
signatureMethod?: OAuthSignatureMethod;
|
|
869
|
+
/** Override the API base URL. Defaults to `https://api.discogs.com`. */
|
|
870
|
+
baseUrl?: string;
|
|
871
|
+
/** Override the website base URL used to build the authorize link. */
|
|
872
|
+
websiteUrl?: string;
|
|
873
|
+
/** Custom `fetch` implementation. Defaults to the global one. */
|
|
874
|
+
fetch?: typeof globalThis.fetch;
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
/** 403 — authenticated, but not allowed to access or modify this resource. */
|
|
878
|
+
export declare class DiscogsPermissionError extends DiscogsError {
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
/**
|
|
882
|
+
* 429 — the rate limit was exceeded.
|
|
883
|
+
*
|
|
884
|
+
* Discogs allows 60 requests per minute when authenticated and 25 when not, measured as a
|
|
885
|
+
* moving average over a 60-second window per source IP. Inspect
|
|
886
|
+
* {@link DiscogsRateLimitError.rateLimit} to see where you stand.
|
|
887
|
+
*/
|
|
888
|
+
export declare class DiscogsRateLimitError extends DiscogsError {
|
|
889
|
+
/** Rate-limit headers from the rejected response, when present. */
|
|
890
|
+
readonly rateLimit: RateLimit | null;
|
|
891
|
+
constructor(message: string, options: DiscogsErrorOptions & {
|
|
892
|
+
rateLimit?: RateLimit | null;
|
|
893
|
+
});
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
/** A response with its parsed body and the metadata that came with it. */
|
|
897
|
+
export declare interface DiscogsResponse<T> {
|
|
898
|
+
/** The parsed response body. `null` for `204 No Content` and `304 Not Modified`. */
|
|
899
|
+
data: T;
|
|
900
|
+
/** The raw response, for headers such as `Location` and `Last-Modified`. */
|
|
901
|
+
response: Response;
|
|
902
|
+
/** Rate-limit state from this response, or `null` when the headers were absent. */
|
|
903
|
+
rateLimit: RateLimit | null;
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
/**
|
|
907
|
+
* 5xx — Discogs failed to handle the request.
|
|
908
|
+
*
|
|
909
|
+
* For a 500 the `message` in the body is an error code you can quote to Discogs Support.
|
|
910
|
+
*/
|
|
911
|
+
export declare class DiscogsServerError extends DiscogsError {
|
|
912
|
+
}
|
|
913
|
+
|
|
914
|
+
/**
|
|
915
|
+
* 422 — the request was well-formed but semantically wrong: a missing or mistyped parameter,
|
|
916
|
+
* an invalid enum value, or a nonsensical action.
|
|
917
|
+
*/
|
|
918
|
+
export declare class DiscogsValidationError extends DiscogsError {
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
/**
|
|
922
|
+
* Body accepted when editing a listing.
|
|
923
|
+
*
|
|
924
|
+
* Listings whose status is not `For Sale`, `Draft` or `Expired` can only be deleted, not
|
|
925
|
+
* edited. A `Sold` listing cannot be re-listed — create a new listing instead.
|
|
926
|
+
*/
|
|
927
|
+
export declare type EditListingParams = CreateListingParams;
|
|
928
|
+
|
|
929
|
+
/**
|
|
930
|
+
* Body accepted when editing an order.
|
|
931
|
+
*
|
|
932
|
+
* `status` and `shipping` are mutually exclusive: changing the shipping price invoices the
|
|
933
|
+
* buyer and forces the status to `Invoice Sent`, so Discogs rejects requests that set both.
|
|
934
|
+
* Shipping can only be changed while the order is not cancelled, `Payment Received` or
|
|
935
|
+
* `Shipped`.
|
|
936
|
+
*/
|
|
937
|
+
export declare interface EditOrderParams {
|
|
938
|
+
/** Must appear in the order's current {@link Order.next_status} list. */
|
|
939
|
+
status?: OrderStatus;
|
|
940
|
+
/** New shipping price. Sends an invoice and moves the order to `Invoice Sent`. */
|
|
941
|
+
shipping?: number;
|
|
942
|
+
/** Seller only — buyers receive a 403. */
|
|
943
|
+
tracking?: OrderTracking;
|
|
944
|
+
}
|
|
945
|
+
|
|
946
|
+
/** Body accepted by {@link UserResource.editProfile}. All fields are optional. */
|
|
947
|
+
export declare interface EditProfileParams {
|
|
948
|
+
/** The user's real name. */
|
|
949
|
+
name?: string;
|
|
950
|
+
home_page?: string;
|
|
951
|
+
location?: string;
|
|
952
|
+
profile?: string;
|
|
953
|
+
curr_abbr?: Currency;
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
/** The permanent "All" folder, which lists every release in the collection. */
|
|
957
|
+
export declare const FOLDER_ALL = 0;
|
|
958
|
+
|
|
959
|
+
/** The permanent "Uncategorized" folder, the default destination for new additions. */
|
|
960
|
+
export declare const FOLDER_UNCATEGORIZED = 1;
|
|
961
|
+
|
|
962
|
+
/** A physical or digital format descriptor. */
|
|
963
|
+
export declare interface Format {
|
|
964
|
+
name: string;
|
|
965
|
+
/** Quantity of this format, as a string (e.g. `"1"`, `"2"`). */
|
|
966
|
+
qty: string;
|
|
967
|
+
/** Free-form text qualifier, e.g. `"Digipak"`. */
|
|
968
|
+
text?: string;
|
|
969
|
+
descriptions?: string[];
|
|
970
|
+
}
|
|
971
|
+
|
|
972
|
+
/** Arguments for {@link DiscogsOAuth.getAccessToken}. */
|
|
973
|
+
export declare interface GetAccessTokenParams {
|
|
974
|
+
/** The request token from {@link DiscogsOAuth.getRequestToken}. */
|
|
975
|
+
oauthToken: string;
|
|
976
|
+
/** The matching request token secret. */
|
|
977
|
+
oauthTokenSecret: string;
|
|
978
|
+
/**
|
|
979
|
+
* The verifier Discogs handed back after the user approved access — either from the
|
|
980
|
+
* `oauth_verifier` query parameter on your callback URL, or typed in by the user when no
|
|
981
|
+
* callback is registered.
|
|
982
|
+
*/
|
|
983
|
+
verifier: string;
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
/** Query parameters for {@link DatabaseResource.getArtistReleases}. */
|
|
987
|
+
export declare interface GetArtistReleasesParams extends PaginationParams {
|
|
988
|
+
sort?: ArtistReleaseSort;
|
|
989
|
+
sort_order?: SortOrder;
|
|
990
|
+
}
|
|
991
|
+
|
|
992
|
+
/** Query parameters for {@link CollectionResource.getItemsByFolder}. */
|
|
993
|
+
export declare interface GetCollectionItemsParams extends PaginationParams {
|
|
994
|
+
sort?: CollectionSort;
|
|
995
|
+
sort_order?: SortOrder;
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
/** Query parameters for {@link UserResource.getContributions}. */
|
|
999
|
+
export declare interface GetContributionsParams extends PaginationParams {
|
|
1000
|
+
sort?: ContributionSort;
|
|
1001
|
+
sort_order?: SortOrder;
|
|
1002
|
+
}
|
|
1003
|
+
|
|
1004
|
+
/** Query parameters for {@link MarketplaceResource.getInventory}. */
|
|
1005
|
+
export declare interface GetInventoryParams extends PaginationParams {
|
|
1006
|
+
/** Only return listings with this status. */
|
|
1007
|
+
status?: ListingStatusFilter;
|
|
1008
|
+
sort?: InventorySort;
|
|
1009
|
+
sort_order?: SortOrder;
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
/** Query parameters for {@link MarketplaceResource.getListing}. */
|
|
1013
|
+
export declare interface GetListingParams {
|
|
1014
|
+
/** Defaults to the authenticated user's currency. */
|
|
1015
|
+
curr_abbr?: Currency;
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
/** Query parameters for {@link MarketplaceResource.getReleaseStats}. */
|
|
1019
|
+
export declare interface GetMarketplaceStatsParams {
|
|
1020
|
+
/** Defaults to the authenticated user's buyer currency, or USD when unauthenticated. */
|
|
1021
|
+
curr_abbr?: Currency;
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
/** Query parameters for {@link DatabaseResource.getMasterVersions}. */
|
|
1025
|
+
export declare interface GetMasterVersionsParams extends PaginationParams {
|
|
1026
|
+
/** Filter by format, e.g. `"Vinyl"`. */
|
|
1027
|
+
format?: string;
|
|
1028
|
+
/** Filter by label, e.g. `"Scorpio Music"`. */
|
|
1029
|
+
label?: string;
|
|
1030
|
+
/** Filter by release year, e.g. `"1992"`. */
|
|
1031
|
+
released?: string;
|
|
1032
|
+
/** Filter by country, e.g. `"Belgium"`. */
|
|
1033
|
+
country?: string;
|
|
1034
|
+
sort?: MasterVersionSort;
|
|
1035
|
+
sort_order?: SortOrder;
|
|
1036
|
+
}
|
|
1037
|
+
|
|
1038
|
+
/** Query parameters for {@link DatabaseResource.getRelease}. */
|
|
1039
|
+
export declare interface GetReleaseParams {
|
|
1040
|
+
/**
|
|
1041
|
+
* Currency for marketplace data (`lowest_price`). Defaults to the authenticated user's
|
|
1042
|
+
* currency, or USD when unauthenticated.
|
|
1043
|
+
*/
|
|
1044
|
+
curr_abbr?: Currency;
|
|
1045
|
+
}
|
|
1046
|
+
|
|
1047
|
+
/** HTTP verbs used by the Discogs API. */
|
|
1048
|
+
export declare type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE';
|
|
1049
|
+
|
|
1050
|
+
/** A barcode, matrix number, rights-society code, or similar identifier. */
|
|
1051
|
+
export declare interface Identifier {
|
|
1052
|
+
type: string;
|
|
1053
|
+
value: string;
|
|
1054
|
+
/** @remarks Optional; present when the submitter added a qualifier. */
|
|
1055
|
+
description?: string;
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
/**
|
|
1059
|
+
* Basic information about the authenticated user.
|
|
1060
|
+
*
|
|
1061
|
+
* @see https://www.discogs.com/developers/#page:user-identity,header:user-identity-identity
|
|
1062
|
+
*/
|
|
1063
|
+
export declare interface Identity {
|
|
1064
|
+
id: number;
|
|
1065
|
+
username: string;
|
|
1066
|
+
resource_url: string;
|
|
1067
|
+
/** The name of the application whose credentials made the request. */
|
|
1068
|
+
consumer_name: string;
|
|
1069
|
+
}
|
|
1070
|
+
|
|
1071
|
+
/**
|
|
1072
|
+
* A user-contributed image.
|
|
1073
|
+
*
|
|
1074
|
+
* Image URLs are signed and only present when the request is authenticated (a consumer
|
|
1075
|
+
* key/secret pair is sufficient). Never construct these URLs yourself — altering any part of
|
|
1076
|
+
* them results in a 404.
|
|
1077
|
+
*/
|
|
1078
|
+
declare interface Image_2 {
|
|
1079
|
+
type: 'primary' | 'secondary';
|
|
1080
|
+
uri: string;
|
|
1081
|
+
/** 150px thumbnail variant. */
|
|
1082
|
+
uri150: string;
|
|
1083
|
+
resource_url: string;
|
|
1084
|
+
width: number;
|
|
1085
|
+
height: number;
|
|
1086
|
+
}
|
|
1087
|
+
export { Image_2 as Image }
|
|
1088
|
+
|
|
1089
|
+
/**
|
|
1090
|
+
* A requested CSV export of your Marketplace inventory.
|
|
1091
|
+
*
|
|
1092
|
+
* @see https://www.discogs.com/developers/#page:inventory-export
|
|
1093
|
+
*/
|
|
1094
|
+
export declare interface InventoryExport {
|
|
1095
|
+
id: number;
|
|
1096
|
+
status: JobStatus;
|
|
1097
|
+
/** Timestamp the export was requested, e.g. `"2018-09-27T12:50:39"`. */
|
|
1098
|
+
created_ts: string;
|
|
1099
|
+
/** Timestamp the export finished. `null` while the export is still running. */
|
|
1100
|
+
finished_ts: string | null;
|
|
1101
|
+
filename: string;
|
|
1102
|
+
/** URL of this export's status resource. */
|
|
1103
|
+
url: string;
|
|
1104
|
+
/** URL to download the finished CSV. */
|
|
1105
|
+
download_url: string;
|
|
1106
|
+
}
|
|
1107
|
+
|
|
1108
|
+
/**
|
|
1109
|
+
* Inventory export endpoints.
|
|
1110
|
+
*
|
|
1111
|
+
* Reachable as `client.inventoryExport`.
|
|
1112
|
+
*/
|
|
1113
|
+
export declare class InventoryExportResource {
|
|
1114
|
+
#private;
|
|
1115
|
+
constructor(client: DiscogsClient);
|
|
1116
|
+
/**
|
|
1117
|
+
* Requests a CSV export of your inventory.
|
|
1118
|
+
*
|
|
1119
|
+
* Exports are generated asynchronously — poll {@link InventoryExportResource.get} until the
|
|
1120
|
+
* status reports success, then call {@link InventoryExportResource.downloadCsv}.
|
|
1121
|
+
*
|
|
1122
|
+
* @throws A `DiscogsError` with status 409 when an export is already in progress.
|
|
1123
|
+
*
|
|
1124
|
+
* @see https://www.discogs.com/developers/#page:inventory-export,header:inventory-export-export-your-inventory
|
|
1125
|
+
*/
|
|
1126
|
+
create(): Promise<CreateExportResult>;
|
|
1127
|
+
/**
|
|
1128
|
+
* Lists your recent inventory exports, newest first.
|
|
1129
|
+
*
|
|
1130
|
+
* @remarks Discogs names the collection key `items` on this endpoint, not `exports`.
|
|
1131
|
+
*
|
|
1132
|
+
* @see https://www.discogs.com/developers/#page:inventory-export,header:inventory-export-get-recent-exports
|
|
1133
|
+
*/
|
|
1134
|
+
list(params?: PaginationParams): Promise<InventoryExportsResponse>;
|
|
1135
|
+
/**
|
|
1136
|
+
* Gets the status of an export.
|
|
1137
|
+
*
|
|
1138
|
+
* @returns The export, or `null` when `ifModifiedSince` was supplied and Discogs answered
|
|
1139
|
+
* `304 Not Modified`.
|
|
1140
|
+
*
|
|
1141
|
+
* @see https://www.discogs.com/developers/#page:inventory-export,header:inventory-export-get-an-export
|
|
1142
|
+
*/
|
|
1143
|
+
get(exportId: number, options?: ConditionalRequestOptions): Promise<InventoryExport | null>;
|
|
1144
|
+
/**
|
|
1145
|
+
* Downloads a finished export as CSV text.
|
|
1146
|
+
*
|
|
1147
|
+
* @see https://www.discogs.com/developers/#page:inventory-export,header:inventory-export-download-an-export
|
|
1148
|
+
*/
|
|
1149
|
+
downloadCsv(exportId: number): Promise<string>;
|
|
1150
|
+
/**
|
|
1151
|
+
* Downloads a finished export as a raw {@link Response}, so you can stream it to disk or
|
|
1152
|
+
* read the `Content-Disposition` filename.
|
|
1153
|
+
*
|
|
1154
|
+
* @see https://www.discogs.com/developers/#page:inventory-export,header:inventory-export-download-an-export
|
|
1155
|
+
*/
|
|
1156
|
+
downloadRaw(exportId: number): Promise<Response>;
|
|
1157
|
+
}
|
|
1158
|
+
|
|
1159
|
+
/**
|
|
1160
|
+
* Response of {@link InventoryExportResource.list}.
|
|
1161
|
+
*
|
|
1162
|
+
* Note that Discogs uses `items` as the collection key here, which is easy to confuse with
|
|
1163
|
+
* `pagination.items` — the latter is a count, the former the array of exports.
|
|
1164
|
+
*/
|
|
1165
|
+
export declare type InventoryExportsResponse = Paginated<'items', InventoryExport>;
|
|
1166
|
+
|
|
1167
|
+
/** Response of {@link MarketplaceResource.getInventory}. */
|
|
1168
|
+
export declare type InventoryResponse = Paginated<'listings', Listing>;
|
|
1169
|
+
|
|
1170
|
+
/** Sort keys accepted by {@link MarketplaceResource.getInventory}. */
|
|
1171
|
+
export declare type InventorySort = 'listed' | 'price'
|
|
1172
|
+
/** Title of the release. */
|
|
1173
|
+
| 'item' | 'artist' | 'label' | 'catno' | 'audio'
|
|
1174
|
+
/** Owner-authenticated requests only. */
|
|
1175
|
+
| 'status'
|
|
1176
|
+
/** Owner-authenticated requests only. */
|
|
1177
|
+
| 'location';
|
|
1178
|
+
|
|
1179
|
+
/**
|
|
1180
|
+
* A submitted CSV upload against your Marketplace inventory.
|
|
1181
|
+
*
|
|
1182
|
+
* @see https://www.discogs.com/developers/#page:inventory-upload
|
|
1183
|
+
*/
|
|
1184
|
+
export declare interface InventoryUpload {
|
|
1185
|
+
id: number;
|
|
1186
|
+
status: JobStatus;
|
|
1187
|
+
/** Human-readable summary containing light HTML, e.g. `"CSV file contains 1 records.<p>Processed 1 records."` */
|
|
1188
|
+
results: string;
|
|
1189
|
+
created_ts: string;
|
|
1190
|
+
finished_ts: string | null;
|
|
1191
|
+
filename: string;
|
|
1192
|
+
type: InventoryUploadType;
|
|
1193
|
+
}
|
|
1194
|
+
|
|
1195
|
+
/**
|
|
1196
|
+
* Inventory upload endpoints.
|
|
1197
|
+
*
|
|
1198
|
+
* Every upload takes a comma-separated CSV whose first row is a header of **lower case**
|
|
1199
|
+
* field names. Uploads are processed asynchronously — poll
|
|
1200
|
+
* {@link InventoryUploadResource.get} for the outcome.
|
|
1201
|
+
*
|
|
1202
|
+
* Reachable as `client.inventoryUpload`.
|
|
1203
|
+
*/
|
|
1204
|
+
export declare class InventoryUploadResource {
|
|
1205
|
+
#private;
|
|
1206
|
+
constructor(client: DiscogsClient);
|
|
1207
|
+
/**
|
|
1208
|
+
* Uploads a CSV of listings to add to your inventory. Added listings go on sale immediately,
|
|
1209
|
+
* priced in the currency from your Marketplace settings.
|
|
1210
|
+
*
|
|
1211
|
+
* Required columns: `release_id`, `price`, `media_condition`.
|
|
1212
|
+
* Optional columns: `sleeve_condition`, `comments`, `accept_offer` (`Y` or `N`), `location`,
|
|
1213
|
+
* `external_id`, `weight` (grams, non-negative integer), `format_quantity`.
|
|
1214
|
+
* Any other column is ignored.
|
|
1215
|
+
*
|
|
1216
|
+
* @param csv - CSV text, or a `Blob`/`File` if you want to control the filename.
|
|
1217
|
+
*
|
|
1218
|
+
* @example
|
|
1219
|
+
* ```ts
|
|
1220
|
+
* await client.inventoryUpload.add(
|
|
1221
|
+
* 'release_id,price,media_condition\n249504,12.50,Near Mint (NM or M-)\n',
|
|
1222
|
+
* );
|
|
1223
|
+
* ```
|
|
1224
|
+
*
|
|
1225
|
+
* @see https://www.discogs.com/developers/#page:inventory-upload,header:inventory-upload-add-inventory
|
|
1226
|
+
*/
|
|
1227
|
+
add(csv: CsvUpload, filename?: string): Promise<CreateUploadResult>;
|
|
1228
|
+
/**
|
|
1229
|
+
* Uploads a CSV of changes to existing listings.
|
|
1230
|
+
*
|
|
1231
|
+
* Required column: `release_id`.
|
|
1232
|
+
* At least one of: `price`, `media_condition`, `sleeve_condition`, `comments`,
|
|
1233
|
+
* `accept_offer` (`Y` or `N`), `external_id`, `location`, `weight`, `format_quantity`.
|
|
1234
|
+
*
|
|
1235
|
+
* @see https://www.discogs.com/developers/#page:inventory-upload,header:inventory-upload-change-inventory
|
|
1236
|
+
*/
|
|
1237
|
+
change(csv: CsvUpload, filename?: string): Promise<CreateUploadResult>;
|
|
1238
|
+
/**
|
|
1239
|
+
* Uploads a CSV of listings to delete. The only column is `listing_id`.
|
|
1240
|
+
*
|
|
1241
|
+
* @example
|
|
1242
|
+
* ```ts
|
|
1243
|
+
* await client.inventoryUpload.delete('listing_id\n12345678\n98765432\n');
|
|
1244
|
+
* ```
|
|
1245
|
+
*
|
|
1246
|
+
* @see https://www.discogs.com/developers/#page:inventory-upload,header:inventory-upload-delete-inventory
|
|
1247
|
+
*/
|
|
1248
|
+
delete(csv: CsvUpload, filename?: string): Promise<CreateUploadResult>;
|
|
1249
|
+
/**
|
|
1250
|
+
* Lists your recent inventory uploads.
|
|
1251
|
+
*
|
|
1252
|
+
* @remarks Discogs names the collection key `items` on this endpoint, not `uploads`.
|
|
1253
|
+
*
|
|
1254
|
+
* @see https://www.discogs.com/developers/#page:inventory-upload,header:inventory-upload-get-recent-uploads
|
|
1255
|
+
*/
|
|
1256
|
+
list(params?: PaginationParams): Promise<InventoryUploadsResponse>;
|
|
1257
|
+
/**
|
|
1258
|
+
* Gets the status of an upload, including how many records were processed.
|
|
1259
|
+
*
|
|
1260
|
+
* @returns The upload, or `null` when `ifModifiedSince` was supplied and Discogs answered
|
|
1261
|
+
* `304 Not Modified`.
|
|
1262
|
+
*
|
|
1263
|
+
* @see https://www.discogs.com/developers/#page:inventory-upload,header:inventory-upload-get-an-upload
|
|
1264
|
+
*/
|
|
1265
|
+
get(uploadId: number, options?: ConditionalRequestOptions): Promise<InventoryUpload | null>;
|
|
1266
|
+
}
|
|
1267
|
+
|
|
1268
|
+
/** Response of {@link InventoryUploadResource.list}. Uses `items` as the collection key. */
|
|
1269
|
+
export declare type InventoryUploadsResponse = Paginated<'items', InventoryUpload>;
|
|
1270
|
+
|
|
1271
|
+
/** Which kind of change an inventory upload applies. */
|
|
1272
|
+
export declare type InventoryUploadType = 'add' | 'change' | 'delete';
|
|
1273
|
+
|
|
1274
|
+
/**
|
|
1275
|
+
* Processing status of an export or upload job.
|
|
1276
|
+
*
|
|
1277
|
+
* The docs only ever show `"success"`; the full set is not enumerated, so this stays a string.
|
|
1278
|
+
*/
|
|
1279
|
+
export declare type JobStatus = string;
|
|
1280
|
+
|
|
1281
|
+
/**
|
|
1282
|
+
* Authenticates with a consumer key and secret.
|
|
1283
|
+
*
|
|
1284
|
+
* Sends `Authorization: Discogs key=<key>, secret=<secret>`. This raises your rate limit to
|
|
1285
|
+
* the authenticated tier and unlocks image URLs, but does not authenticate you as any
|
|
1286
|
+
* particular user — endpoints that act on a user's data still require OAuth or a personal
|
|
1287
|
+
* access token.
|
|
1288
|
+
*
|
|
1289
|
+
* @see https://www.discogs.com/developers/#page:authentication,header:authentication-discogs-auth-flow
|
|
1290
|
+
*/
|
|
1291
|
+
export declare class KeySecretAuth implements AuthStrategy {
|
|
1292
|
+
#private;
|
|
1293
|
+
constructor(consumerKey: string, consumerSecret: string);
|
|
1294
|
+
authorize(request: AuthorizableRequest): void;
|
|
1295
|
+
}
|
|
1296
|
+
|
|
1297
|
+
/**
|
|
1298
|
+
* A label — a company or imprint that released records.
|
|
1299
|
+
*
|
|
1300
|
+
* @see https://www.discogs.com/developers/#page:database,header:database-label
|
|
1301
|
+
*/
|
|
1302
|
+
export declare interface Label {
|
|
1303
|
+
id: number;
|
|
1304
|
+
name: string;
|
|
1305
|
+
resource_url: string;
|
|
1306
|
+
uri: string;
|
|
1307
|
+
releases_url: string;
|
|
1308
|
+
profile: string;
|
|
1309
|
+
data_quality: DataQuality;
|
|
1310
|
+
contact_info?: string;
|
|
1311
|
+
urls?: string[];
|
|
1312
|
+
images?: Image_2[];
|
|
1313
|
+
sublabels?: LabelRef[];
|
|
1314
|
+
/** @remarks Undocumented; present when the label is itself a sublabel. */
|
|
1315
|
+
parent_label?: LabelRef;
|
|
1316
|
+
}
|
|
1317
|
+
|
|
1318
|
+
/** A label credit as embedded in releases. */
|
|
1319
|
+
export declare interface LabelCredit {
|
|
1320
|
+
id: number;
|
|
1321
|
+
name: string;
|
|
1322
|
+
/** Catalogue number for this release on this label. */
|
|
1323
|
+
catno: string;
|
|
1324
|
+
entity_type: string;
|
|
1325
|
+
/** @remarks Present on some resources only (e.g. collection/wantlist basic information). */
|
|
1326
|
+
entity_type_name?: string;
|
|
1327
|
+
resource_url: string;
|
|
1328
|
+
/** @remarks Undocumented; returned by the live API on some resources. */
|
|
1329
|
+
thumbnail_url?: string;
|
|
1330
|
+
}
|
|
1331
|
+
|
|
1332
|
+
/** A sublabel or parent label reference. */
|
|
1333
|
+
export declare interface LabelRef {
|
|
1334
|
+
id: number;
|
|
1335
|
+
name: string;
|
|
1336
|
+
resource_url: string;
|
|
1337
|
+
}
|
|
1338
|
+
|
|
1339
|
+
/** One release on a label. */
|
|
1340
|
+
export declare interface LabelRelease {
|
|
1341
|
+
id: number;
|
|
1342
|
+
title: string;
|
|
1343
|
+
artist: string;
|
|
1344
|
+
catno: string;
|
|
1345
|
+
format: string;
|
|
1346
|
+
status: SubmissionStatus;
|
|
1347
|
+
resource_url: string;
|
|
1348
|
+
thumb: string;
|
|
1349
|
+
year: number;
|
|
1350
|
+
/** @remarks Undocumented; returned by the live API. */
|
|
1351
|
+
stats?: MasterVersionStats;
|
|
1352
|
+
}
|
|
1353
|
+
|
|
1354
|
+
/** Response of {@link DatabaseResource.getLabelReleases}. */
|
|
1355
|
+
export declare type LabelReleasesResponse = Paginated<'releases', LabelRelease>;
|
|
1356
|
+
|
|
1357
|
+
/**
|
|
1358
|
+
* A list with its items.
|
|
1359
|
+
*
|
|
1360
|
+
* @remarks Field names differ from {@link ListSummary} — see the module description.
|
|
1361
|
+
*/
|
|
1362
|
+
export declare interface ListDetail {
|
|
1363
|
+
list_id: number;
|
|
1364
|
+
name: string;
|
|
1365
|
+
description: string;
|
|
1366
|
+
public: boolean;
|
|
1367
|
+
created_ts: string;
|
|
1368
|
+
modified_ts: string;
|
|
1369
|
+
url: string;
|
|
1370
|
+
resource_url: string;
|
|
1371
|
+
items: ListItem[];
|
|
1372
|
+
/** @remarks Undocumented; returned by the live API. */
|
|
1373
|
+
image_url?: string;
|
|
1374
|
+
/** @remarks Undocumented; returned by the live API. */
|
|
1375
|
+
user?: {
|
|
1376
|
+
id: number;
|
|
1377
|
+
username: string;
|
|
1378
|
+
resource_url: string;
|
|
1379
|
+
};
|
|
1380
|
+
}
|
|
1381
|
+
|
|
1382
|
+
/**
|
|
1383
|
+
* A Marketplace listing.
|
|
1384
|
+
*
|
|
1385
|
+
* Fields marked "owner only" are returned only when the request is authenticated as the
|
|
1386
|
+
* listing's seller.
|
|
1387
|
+
*
|
|
1388
|
+
* @see https://www.discogs.com/developers/#page:marketplace,header:marketplace-listing
|
|
1389
|
+
*/
|
|
1390
|
+
export declare interface Listing {
|
|
1391
|
+
id: number;
|
|
1392
|
+
status: ListingStatusFilter;
|
|
1393
|
+
resource_url: string;
|
|
1394
|
+
uri: string;
|
|
1395
|
+
condition: MediaCondition;
|
|
1396
|
+
sleeve_condition?: SleeveCondition;
|
|
1397
|
+
comments: string;
|
|
1398
|
+
/** ISO 8601 timestamp of when the listing was posted. */
|
|
1399
|
+
posted: string;
|
|
1400
|
+
ships_from: string;
|
|
1401
|
+
allow_offers: boolean;
|
|
1402
|
+
audio: boolean;
|
|
1403
|
+
price: Price;
|
|
1404
|
+
original_price?: OriginalPrice;
|
|
1405
|
+
shipping_price?: Price;
|
|
1406
|
+
original_shipping_price?: OriginalPrice;
|
|
1407
|
+
seller: ListingSeller;
|
|
1408
|
+
release: ListingRelease;
|
|
1409
|
+
/** Owner only. Shipping weight in grams. */
|
|
1410
|
+
weight?: number;
|
|
1411
|
+
/** Owner only. How many items this listing counts as for shipping purposes. */
|
|
1412
|
+
format_quantity?: number;
|
|
1413
|
+
/** Owner only. Seller-private reference, shown as "Private Comments" on the website. */
|
|
1414
|
+
external_id?: string;
|
|
1415
|
+
/** Owner only. Seller-private physical storage location. */
|
|
1416
|
+
location?: string;
|
|
1417
|
+
/** Owner only. Always `1` for NearMint sellers, for whom it is read-only. */
|
|
1418
|
+
quantity?: number;
|
|
1419
|
+
/** Only present for authenticated users. */
|
|
1420
|
+
in_cart?: boolean;
|
|
1421
|
+
/** @remarks Undocumented; returned by the live API. */
|
|
1422
|
+
ships_from_country_code?: string;
|
|
1423
|
+
}
|
|
1424
|
+
|
|
1425
|
+
/** Every {@link ListingStatusFilter}, as enumerated by the API's own 422 error message. */
|
|
1426
|
+
export declare const LISTING_STATUS_FILTERS: readonly ListingStatusFilter[];
|
|
1427
|
+
|
|
1428
|
+
/** The release a listing refers to. */
|
|
1429
|
+
export declare interface ListingRelease {
|
|
1430
|
+
id: number;
|
|
1431
|
+
description: string;
|
|
1432
|
+
resource_url: string;
|
|
1433
|
+
thumbnail: string;
|
|
1434
|
+
catalog_number: string;
|
|
1435
|
+
year: number;
|
|
1436
|
+
/** Present on some listings only. */
|
|
1437
|
+
artist?: string;
|
|
1438
|
+
/** Present on some listings only. */
|
|
1439
|
+
title?: string;
|
|
1440
|
+
/** Present on some listings only. */
|
|
1441
|
+
format?: string;
|
|
1442
|
+
/** @remarks Undocumented; returned by the live API. */
|
|
1443
|
+
stats?: {
|
|
1444
|
+
community?: {
|
|
1445
|
+
in_collection: number;
|
|
1446
|
+
in_wantlist: number;
|
|
1447
|
+
};
|
|
1448
|
+
};
|
|
1449
|
+
}
|
|
1450
|
+
|
|
1451
|
+
/** The seller of a listing. Richer on {@link Listing} than on inventory entries. */
|
|
1452
|
+
export declare interface ListingSeller extends UserIdRef {
|
|
1453
|
+
avatar_url?: string;
|
|
1454
|
+
url?: string;
|
|
1455
|
+
/** Free-text shipping policy. */
|
|
1456
|
+
shipping?: string;
|
|
1457
|
+
/** Free-text accepted payment methods. */
|
|
1458
|
+
payment?: string;
|
|
1459
|
+
stats?: SellerStats;
|
|
1460
|
+
/** @remarks Undocumented; returned by the live API. */
|
|
1461
|
+
html_url?: string;
|
|
1462
|
+
/** @remarks Undocumented; returned by the live API. */
|
|
1463
|
+
uid?: number;
|
|
1464
|
+
/** @remarks Undocumented; returned by the live API. */
|
|
1465
|
+
min_order_total?: number;
|
|
1466
|
+
}
|
|
1467
|
+
|
|
1468
|
+
/** Listing statuses that can be set when creating or editing a listing. */
|
|
1469
|
+
export declare type ListingStatus = 'For Sale' | 'Draft';
|
|
1470
|
+
|
|
1471
|
+
/** Listing statuses accepted as an inventory filter. */
|
|
1472
|
+
export declare type ListingStatusFilter = 'All' | 'Deleted' | 'Draft' | 'Expired' | 'For Sale' | 'Sold' | 'Suspended' | 'Violation';
|
|
1473
|
+
|
|
1474
|
+
/** An entry in a list. */
|
|
1475
|
+
export declare interface ListItem {
|
|
1476
|
+
id: number;
|
|
1477
|
+
/** The kind of database object this entry points at. */
|
|
1478
|
+
type: 'release' | 'master' | 'artist' | 'label';
|
|
1479
|
+
display_title: string;
|
|
1480
|
+
comment: string;
|
|
1481
|
+
uri: string;
|
|
1482
|
+
image_url: string;
|
|
1483
|
+
resource_url: string;
|
|
1484
|
+
/** @remarks Undocumented; returned by the live API. */
|
|
1485
|
+
stats?: {
|
|
1486
|
+
community?: {
|
|
1487
|
+
in_collection: number;
|
|
1488
|
+
in_wantlist: number;
|
|
1489
|
+
};
|
|
1490
|
+
};
|
|
1491
|
+
}
|
|
1492
|
+
|
|
1493
|
+
/** Query parameters for {@link MarketplaceResource.listOrders}. */
|
|
1494
|
+
export declare interface ListOrdersParams extends PaginationParams {
|
|
1495
|
+
status?: OrderStatusFilter;
|
|
1496
|
+
/** ISO 8601 timestamp, e.g. `"2019-06-24T20:58:58Z"`. */
|
|
1497
|
+
created_after?: string;
|
|
1498
|
+
/** ISO 8601 timestamp. */
|
|
1499
|
+
created_before?: string;
|
|
1500
|
+
/** When omitted, both archived and unarchived orders are returned. */
|
|
1501
|
+
archived?: boolean;
|
|
1502
|
+
sort?: OrderSort;
|
|
1503
|
+
sort_order?: SortOrder;
|
|
1504
|
+
}
|
|
1505
|
+
|
|
1506
|
+
/**
|
|
1507
|
+
* User list endpoints.
|
|
1508
|
+
*
|
|
1509
|
+
* Reachable as `client.lists`.
|
|
1510
|
+
*/
|
|
1511
|
+
export declare class ListsResource {
|
|
1512
|
+
#private;
|
|
1513
|
+
constructor(client: DiscogsClient);
|
|
1514
|
+
/**
|
|
1515
|
+
* Lists a user's lists. Private lists are only returned when authenticated as the owner.
|
|
1516
|
+
*
|
|
1517
|
+
* @see https://www.discogs.com/developers/#page:user-lists,header:user-lists-user-lists
|
|
1518
|
+
*/
|
|
1519
|
+
getUserLists(username: string, params?: PaginationParams): Promise<UserListsResponse>;
|
|
1520
|
+
/**
|
|
1521
|
+
* Gets a list and its items. Private lists are only returned when authenticated as the
|
|
1522
|
+
* owner.
|
|
1523
|
+
*
|
|
1524
|
+
* @remarks This endpoint names its fields differently from the index endpoint —
|
|
1525
|
+
* `created_ts` / `modified_ts` / `list_id` / `url` rather than
|
|
1526
|
+
* `date_added` / `date_changed` / `id` / `uri`.
|
|
1527
|
+
*
|
|
1528
|
+
* @see https://www.discogs.com/developers/#page:user-lists,header:user-lists-list
|
|
1529
|
+
*/
|
|
1530
|
+
getList(listId: number | string): Promise<ListDetail>;
|
|
1531
|
+
}
|
|
1532
|
+
|
|
1533
|
+
/** A list as returned by the per-user index endpoint. */
|
|
1534
|
+
export declare interface ListSummary {
|
|
1535
|
+
id: number;
|
|
1536
|
+
name: string;
|
|
1537
|
+
description: string;
|
|
1538
|
+
public: boolean;
|
|
1539
|
+
date_added: string;
|
|
1540
|
+
date_changed: string;
|
|
1541
|
+
uri: string;
|
|
1542
|
+
resource_url: string;
|
|
1543
|
+
/** @remarks Undocumented; returned by the live API. */
|
|
1544
|
+
image_url?: string;
|
|
1545
|
+
}
|
|
1546
|
+
|
|
1547
|
+
/** The Discogs commission on a sale. */
|
|
1548
|
+
export declare type MarketplaceFee = Price;
|
|
1549
|
+
|
|
1550
|
+
/**
|
|
1551
|
+
* Marketplace endpoints.
|
|
1552
|
+
*
|
|
1553
|
+
* Reachable as `client.marketplace`.
|
|
1554
|
+
*/
|
|
1555
|
+
export declare class MarketplaceResource {
|
|
1556
|
+
#private;
|
|
1557
|
+
constructor(client: DiscogsClient);
|
|
1558
|
+
/**
|
|
1559
|
+
* Lists the listings in a user's inventory.
|
|
1560
|
+
*
|
|
1561
|
+
* Unless authenticated as the inventory's owner, only `For Sale` items are returned and the
|
|
1562
|
+
* seller-private fields (`weight`, `format_quantity`, `external_id`, `location`,
|
|
1563
|
+
* `quantity`) are omitted.
|
|
1564
|
+
*
|
|
1565
|
+
* @see https://www.discogs.com/developers/#page:marketplace,header:marketplace-inventory
|
|
1566
|
+
*/
|
|
1567
|
+
getInventory(username: string, params?: GetInventoryParams): Promise<InventoryResponse>;
|
|
1568
|
+
/**
|
|
1569
|
+
* Gets a listing.
|
|
1570
|
+
*
|
|
1571
|
+
* @see https://www.discogs.com/developers/#page:marketplace,header:marketplace-listing
|
|
1572
|
+
*/
|
|
1573
|
+
getListing(listingId: number, params?: GetListingParams): Promise<Listing>;
|
|
1574
|
+
/**
|
|
1575
|
+
* Creates a listing in the authenticated user's inventory.
|
|
1576
|
+
*
|
|
1577
|
+
* @see https://www.discogs.com/developers/#page:marketplace,header:marketplace-new-listing
|
|
1578
|
+
*/
|
|
1579
|
+
createListing(params: CreateListingParams): Promise<CreateListingResponse>;
|
|
1580
|
+
/**
|
|
1581
|
+
* Edits a listing. Requires authentication as the listing's owner.
|
|
1582
|
+
*
|
|
1583
|
+
* Listings whose status is not `For Sale`, `Draft` or `Expired` cannot be edited, only
|
|
1584
|
+
* deleted; a `Sold` listing has to be replaced with a new one.
|
|
1585
|
+
*
|
|
1586
|
+
* @see https://www.discogs.com/developers/#page:marketplace,header:marketplace-listing-post
|
|
1587
|
+
*/
|
|
1588
|
+
editListing(listingId: number, params: EditListingParams): Promise<void>;
|
|
1589
|
+
/**
|
|
1590
|
+
* Permanently removes a listing. Requires authentication as the listing's owner.
|
|
1591
|
+
*
|
|
1592
|
+
* @see https://www.discogs.com/developers/#page:marketplace,header:marketplace-listing-delete
|
|
1593
|
+
*/
|
|
1594
|
+
deleteListing(listingId: number): Promise<void>;
|
|
1595
|
+
/**
|
|
1596
|
+
* Gets an order. Requires authentication as the seller.
|
|
1597
|
+
*
|
|
1598
|
+
* @param orderId - Order ids are strings of the form `"1-1"`.
|
|
1599
|
+
*
|
|
1600
|
+
* @see https://www.discogs.com/developers/#page:marketplace,header:marketplace-order
|
|
1601
|
+
*/
|
|
1602
|
+
getOrder(orderId: string): Promise<Order>;
|
|
1603
|
+
/**
|
|
1604
|
+
* Edits an order. Requires authentication as the seller.
|
|
1605
|
+
*
|
|
1606
|
+
* The new `status` must appear in the order's current `next_status` array. Setting
|
|
1607
|
+
* `shipping` invoices the buyer and forces the status to `Invoice Sent`, so `shipping` and
|
|
1608
|
+
* `status` cannot be sent together. Changing the status through this endpoint always
|
|
1609
|
+
* messages the buyer with a fixed "Seller changed status from … to …" note — use
|
|
1610
|
+
* {@link MarketplaceResource.addOrderMessage} to combine a status change with your own text.
|
|
1611
|
+
*
|
|
1612
|
+
* @see https://www.discogs.com/developers/#page:marketplace,header:marketplace-order-post
|
|
1613
|
+
*/
|
|
1614
|
+
editOrder(orderId: string, params: EditOrderParams): Promise<Order>;
|
|
1615
|
+
/**
|
|
1616
|
+
* Lists the authenticated user's orders.
|
|
1617
|
+
*
|
|
1618
|
+
* @see https://www.discogs.com/developers/#page:marketplace,header:marketplace-list-orders
|
|
1619
|
+
*/
|
|
1620
|
+
listOrders(params?: ListOrdersParams): Promise<OrdersResponse>;
|
|
1621
|
+
/**
|
|
1622
|
+
* Lists an order's messages, most recent first. Requires authentication as the seller.
|
|
1623
|
+
*
|
|
1624
|
+
* Entries are discriminated by their `type` field.
|
|
1625
|
+
*
|
|
1626
|
+
* @see https://www.discogs.com/developers/#page:marketplace,header:marketplace-list-orders-get
|
|
1627
|
+
*/
|
|
1628
|
+
getOrderMessages(orderId: string, params?: PaginationParams): Promise<OrderMessagesResponse>;
|
|
1629
|
+
/**
|
|
1630
|
+
* Adds a message to an order's message log, optionally changing the order status at the
|
|
1631
|
+
* same time. At least one of `message` or `status` must be supplied.
|
|
1632
|
+
*
|
|
1633
|
+
* @see https://www.discogs.com/developers/#page:marketplace,header:marketplace-list-orders-post
|
|
1634
|
+
*/
|
|
1635
|
+
addOrderMessage(orderId: string, params: AddOrderMessageParams): Promise<AddOrderMessageResponse>;
|
|
1636
|
+
/**
|
|
1637
|
+
* Calculates the Discogs commission on a sale price, in the given currency (USD by default).
|
|
1638
|
+
*
|
|
1639
|
+
* @remarks The price is formatted to exactly two decimal places, because the endpoint
|
|
1640
|
+
* requires it: `/marketplace/fee/20` returns a 404 while `/marketplace/fee/20.00` succeeds.
|
|
1641
|
+
* The Discogs docs only ever show `10.00` and never state this, so passing a bare integer
|
|
1642
|
+
* is an easy mistake to make.
|
|
1643
|
+
*
|
|
1644
|
+
* @see https://www.discogs.com/developers/#page:marketplace,header:marketplace-fee
|
|
1645
|
+
*/
|
|
1646
|
+
getFee(price: number, currency?: Currency): Promise<MarketplaceFee>;
|
|
1647
|
+
/**
|
|
1648
|
+
* Gets suggested prices per media condition for a release, in the user's selling currency.
|
|
1649
|
+
*
|
|
1650
|
+
* Requires authentication, and the user must have completed their seller settings. Returns
|
|
1651
|
+
* an empty object when Discogs has no suggestions for the release.
|
|
1652
|
+
*
|
|
1653
|
+
* @see https://www.discogs.com/developers/#page:marketplace,header:marketplace-price-suggestions
|
|
1654
|
+
*/
|
|
1655
|
+
getPriceSuggestions(releaseId: number): Promise<PriceSuggestions>;
|
|
1656
|
+
/**
|
|
1657
|
+
* Gets marketplace statistics for a release: how many copies are for sale and the lowest
|
|
1658
|
+
* listed price.
|
|
1659
|
+
*
|
|
1660
|
+
* `lowest_price` and `num_for_sale` are `null` when nothing is for sale or the release is
|
|
1661
|
+
* blocked from sale.
|
|
1662
|
+
*
|
|
1663
|
+
* @see https://www.discogs.com/developers/#page:marketplace,header:marketplace-release-statistics
|
|
1664
|
+
*/
|
|
1665
|
+
getReleaseStats(releaseId: number, params?: GetMarketplaceStatsParams): Promise<MarketplaceStats>;
|
|
1666
|
+
}
|
|
1667
|
+
|
|
1668
|
+
/**
|
|
1669
|
+
* Marketplace statistics for a release.
|
|
1670
|
+
*
|
|
1671
|
+
* `lowest_price` and `num_for_sale` are `null` when nothing is for sale, or when the release
|
|
1672
|
+
* is blocked from sale.
|
|
1673
|
+
*/
|
|
1674
|
+
export declare interface MarketplaceStats {
|
|
1675
|
+
lowest_price: Price | null;
|
|
1676
|
+
num_for_sale: number | null;
|
|
1677
|
+
blocked_from_sale: boolean;
|
|
1678
|
+
}
|
|
1679
|
+
|
|
1680
|
+
/**
|
|
1681
|
+
* A master release — the abstract "album" that groups together all its versions.
|
|
1682
|
+
*
|
|
1683
|
+
* @see https://www.discogs.com/developers/#page:database,header:database-master-release
|
|
1684
|
+
*/
|
|
1685
|
+
export declare interface Master {
|
|
1686
|
+
id: number;
|
|
1687
|
+
title: string;
|
|
1688
|
+
resource_url: string;
|
|
1689
|
+
uri: string;
|
|
1690
|
+
versions_url: string;
|
|
1691
|
+
main_release: number;
|
|
1692
|
+
main_release_url: string;
|
|
1693
|
+
artists: ArtistCredit[];
|
|
1694
|
+
genres: string[];
|
|
1695
|
+
styles?: string[];
|
|
1696
|
+
tracklist: Track[];
|
|
1697
|
+
images?: Image_2[];
|
|
1698
|
+
videos?: Video[];
|
|
1699
|
+
year: number;
|
|
1700
|
+
data_quality: DataQuality;
|
|
1701
|
+
num_for_sale: number;
|
|
1702
|
+
lowest_price: number | null;
|
|
1703
|
+
/** @remarks Undocumented; returned by the live API. */
|
|
1704
|
+
most_recent_release?: number;
|
|
1705
|
+
/** @remarks Undocumented; returned by the live API. */
|
|
1706
|
+
most_recent_release_url?: string;
|
|
1707
|
+
}
|
|
1708
|
+
|
|
1709
|
+
/** One release that is a version of a master release. */
|
|
1710
|
+
export declare interface MasterVersion {
|
|
1711
|
+
id: number;
|
|
1712
|
+
title: string;
|
|
1713
|
+
status: SubmissionStatus;
|
|
1714
|
+
resource_url: string;
|
|
1715
|
+
thumb: string;
|
|
1716
|
+
format: string;
|
|
1717
|
+
major_formats: string[];
|
|
1718
|
+
label: string;
|
|
1719
|
+
catno: string;
|
|
1720
|
+
country: string;
|
|
1721
|
+
released: string;
|
|
1722
|
+
stats: MasterVersionStats;
|
|
1723
|
+
}
|
|
1724
|
+
|
|
1725
|
+
/** Sort keys accepted by {@link DatabaseResource.getMasterVersions}. */
|
|
1726
|
+
export declare type MasterVersionSort = 'released' | 'title' | 'format' | 'label' | 'catno' | 'country';
|
|
1727
|
+
|
|
1728
|
+
/** Response of {@link DatabaseResource.getMasterVersions}. */
|
|
1729
|
+
export declare type MasterVersionsResponse = Paginated<'versions', MasterVersion>;
|
|
1730
|
+
|
|
1731
|
+
/** Collection/wantlist counts for a master version, split by viewer and community. */
|
|
1732
|
+
export declare interface MasterVersionStats {
|
|
1733
|
+
user: {
|
|
1734
|
+
in_collection: number;
|
|
1735
|
+
in_wantlist: number;
|
|
1736
|
+
};
|
|
1737
|
+
community: {
|
|
1738
|
+
in_collection: number;
|
|
1739
|
+
in_wantlist: number;
|
|
1740
|
+
};
|
|
1741
|
+
}
|
|
1742
|
+
|
|
1743
|
+
/** Maximum number of items Discogs will return per page. */
|
|
1744
|
+
export declare const MAX_PER_PAGE = 100;
|
|
1745
|
+
|
|
1746
|
+
/** Every {@link MediaCondition}, best to worst. */
|
|
1747
|
+
export declare const MEDIA_CONDITIONS: readonly MediaCondition[];
|
|
1748
|
+
|
|
1749
|
+
/** Goldmine grading for the media itself. */
|
|
1750
|
+
export declare type MediaCondition = 'Mint (M)' | 'Near Mint (NM or M-)' | 'Very Good Plus (VG+)' | 'Very Good (VG)' | 'Good Plus (G+)' | 'Good (G)' | 'Fair (F)' | 'Poor (P)';
|
|
1751
|
+
|
|
1752
|
+
/** The three response representations Discogs offers, selected via the `Accept` header. */
|
|
1753
|
+
export declare type MediaType = 'discogs' | 'html' | 'plaintext';
|
|
1754
|
+
|
|
1755
|
+
/**
|
|
1756
|
+
* Signs requests with a full OAuth 1.0a access token, authenticating as the user who granted
|
|
1757
|
+
* access.
|
|
1758
|
+
*
|
|
1759
|
+
* Obtain the access token and secret with {@link DiscogsOAuth}; they do not expire unless the
|
|
1760
|
+
* user revokes them.
|
|
1761
|
+
*/
|
|
1762
|
+
export declare class OAuth1Auth implements AuthStrategy {
|
|
1763
|
+
#private;
|
|
1764
|
+
constructor(credentials: OAuthCredentials, options?: OAuthNonceOptions);
|
|
1765
|
+
authorize(request: AuthorizableRequest): Promise<void>;
|
|
1766
|
+
}
|
|
1767
|
+
|
|
1768
|
+
/**
|
|
1769
|
+
* Credentials for a completed OAuth 1.0a flow. Authenticates as the user who granted access.
|
|
1770
|
+
*/
|
|
1771
|
+
export declare interface OAuthCredentials extends ConsumerCredentials {
|
|
1772
|
+
/** The OAuth access token obtained at the end of the three-legged flow. */
|
|
1773
|
+
accessToken: string;
|
|
1774
|
+
/** The matching access token secret. */
|
|
1775
|
+
accessTokenSecret: string;
|
|
1776
|
+
/**
|
|
1777
|
+
* Signature method to sign requests with. Defaults to `"PLAINTEXT"`, which is what the
|
|
1778
|
+
* Discogs documentation recommends (all traffic is over HTTPS anyway).
|
|
1779
|
+
*/
|
|
1780
|
+
signatureMethod?: OAuthSignatureMethod;
|
|
1781
|
+
}
|
|
1782
|
+
|
|
1783
|
+
/** Injection points used by the tests to make signatures deterministic. */
|
|
1784
|
+
export declare interface OAuthNonceOptions {
|
|
1785
|
+
/** Overrides nonce generation. Defaults to 16 random bytes, hex-encoded. */
|
|
1786
|
+
nonce?: () => string;
|
|
1787
|
+
/** Overrides the timestamp. Defaults to the current Unix time in seconds. */
|
|
1788
|
+
timestamp?: () => string;
|
|
1789
|
+
}
|
|
1790
|
+
|
|
1791
|
+
/** OAuth 1.0a signature methods supported by Discogs. */
|
|
1792
|
+
export declare type OAuthSignatureMethod = 'PLAINTEXT' | 'HMAC-SHA1';
|
|
1793
|
+
|
|
1794
|
+
/**
|
|
1795
|
+
* A Marketplace order.
|
|
1796
|
+
*
|
|
1797
|
+
* @see https://www.discogs.com/developers/#page:marketplace,header:marketplace-order
|
|
1798
|
+
*/
|
|
1799
|
+
export declare interface Order {
|
|
1800
|
+
/** Order ids are strings of the form `"1-1"`, not numbers. */
|
|
1801
|
+
id: string;
|
|
1802
|
+
resource_url: string;
|
|
1803
|
+
messages_url: string;
|
|
1804
|
+
uri: string;
|
|
1805
|
+
status: OrderStatusFilter;
|
|
1806
|
+
/**
|
|
1807
|
+
* The statuses this order may legally transition to. Discogs rejects any status not in this
|
|
1808
|
+
* list, and the set is computed per order — there is no static transition table.
|
|
1809
|
+
*/
|
|
1810
|
+
next_status: OrderStatus[];
|
|
1811
|
+
items: OrderItem[];
|
|
1812
|
+
buyer: UserIdRef;
|
|
1813
|
+
seller: UserIdRef;
|
|
1814
|
+
total: Price;
|
|
1815
|
+
fee: Price;
|
|
1816
|
+
shipping: OrderShipping;
|
|
1817
|
+
shipping_address: string;
|
|
1818
|
+
additional_instructions?: string;
|
|
1819
|
+
archived: boolean;
|
|
1820
|
+
created: string;
|
|
1821
|
+
last_activity: string;
|
|
1822
|
+
tracking?: OrderTracking;
|
|
1823
|
+
}
|
|
1824
|
+
|
|
1825
|
+
/** Every {@link OrderStatusFilter}. */
|
|
1826
|
+
export declare const ORDER_STATUS_FILTERS: readonly OrderStatusFilter[];
|
|
1827
|
+
|
|
1828
|
+
/** Every {@link OrderStatus} a seller may set. */
|
|
1829
|
+
export declare const ORDER_STATUSES: readonly OrderStatus[];
|
|
1830
|
+
|
|
1831
|
+
/** A single item within an order. */
|
|
1832
|
+
export declare interface OrderItem {
|
|
1833
|
+
id: number;
|
|
1834
|
+
release: {
|
|
1835
|
+
id: number;
|
|
1836
|
+
description: string;
|
|
1837
|
+
/** Present on {@link MarketplaceResource.listOrders} results. */
|
|
1838
|
+
resource_url?: string;
|
|
1839
|
+
/** Present on {@link MarketplaceResource.listOrders} results. */
|
|
1840
|
+
thumbnail?: string;
|
|
1841
|
+
};
|
|
1842
|
+
price: Price;
|
|
1843
|
+
media_condition?: MediaCondition;
|
|
1844
|
+
sleeve_condition?: SleeveCondition;
|
|
1845
|
+
}
|
|
1846
|
+
|
|
1847
|
+
/** An entry in an order's message log, discriminated by `type`. */
|
|
1848
|
+
export declare type OrderMessage = OrderRefundReceivedMessage | OrderRefundSentMessage | OrderTextMessage | OrderStatusMessage | OrderShippingMessage;
|
|
1849
|
+
|
|
1850
|
+
/** Fields shared by every order message variant. */
|
|
1851
|
+
export declare interface OrderMessageBase {
|
|
1852
|
+
timestamp: string;
|
|
1853
|
+
message: string;
|
|
1854
|
+
subject: string;
|
|
1855
|
+
order: {
|
|
1856
|
+
id: string;
|
|
1857
|
+
resource_url: string;
|
|
1858
|
+
};
|
|
1859
|
+
}
|
|
1860
|
+
|
|
1861
|
+
/** Response of {@link MarketplaceResource.getOrderMessages}. */
|
|
1862
|
+
export declare type OrderMessagesResponse = Paginated<'messages', OrderMessage>;
|
|
1863
|
+
|
|
1864
|
+
/** A refund the buyer received. */
|
|
1865
|
+
export declare interface OrderRefundReceivedMessage extends OrderMessageBase {
|
|
1866
|
+
type: 'refund_received';
|
|
1867
|
+
refund: {
|
|
1868
|
+
amount: number;
|
|
1869
|
+
order: {
|
|
1870
|
+
id: string;
|
|
1871
|
+
resource_url: string;
|
|
1872
|
+
};
|
|
1873
|
+
};
|
|
1874
|
+
}
|
|
1875
|
+
|
|
1876
|
+
/** A refund the seller sent. */
|
|
1877
|
+
export declare interface OrderRefundSentMessage extends OrderMessageBase {
|
|
1878
|
+
type: 'refund_sent';
|
|
1879
|
+
refund: {
|
|
1880
|
+
amount: number;
|
|
1881
|
+
order: {
|
|
1882
|
+
id: string;
|
|
1883
|
+
resource_url: string;
|
|
1884
|
+
};
|
|
1885
|
+
};
|
|
1886
|
+
}
|
|
1887
|
+
|
|
1888
|
+
/** Shipping cost on an order. Carries a `method` alongside the usual price fields. */
|
|
1889
|
+
export declare interface OrderShipping extends Price {
|
|
1890
|
+
method: string;
|
|
1891
|
+
}
|
|
1892
|
+
|
|
1893
|
+
/** An automatic message recording a shipping price change. */
|
|
1894
|
+
export declare interface OrderShippingMessage extends OrderMessageBase {
|
|
1895
|
+
type: 'shipping';
|
|
1896
|
+
original: number;
|
|
1897
|
+
new: number;
|
|
1898
|
+
}
|
|
1899
|
+
|
|
1900
|
+
/** Sort keys accepted by {@link MarketplaceResource.listOrders}. */
|
|
1901
|
+
export declare type OrderSort = 'id' | 'buyer' | 'created' | 'status' | 'last_activity';
|
|
1902
|
+
|
|
1903
|
+
/** Response of {@link MarketplaceResource.listOrders}. */
|
|
1904
|
+
export declare type OrdersResponse = Paginated<'orders', Order>;
|
|
1905
|
+
|
|
1906
|
+
/** Order statuses a seller may set. */
|
|
1907
|
+
export declare type OrderStatus = 'New Order' | 'Buyer Contacted' | 'Invoice Sent' | 'Payment Pending' | 'Payment Received' | 'In Progress' | 'Shipped' | 'Refund Sent' | 'Cancelled (Non-Paying Buyer)' | 'Cancelled (Item Unavailable)' | "Cancelled (Per Buyer's Request)";
|
|
1908
|
+
|
|
1909
|
+
/** Order statuses accepted as a filter by {@link MarketplaceResource.listOrders}. */
|
|
1910
|
+
export declare type OrderStatusFilter = OrderStatus | 'All' | 'Merged' | 'Order Changed' | 'Cancelled' | 'Cancelled (Refund Received)';
|
|
1911
|
+
|
|
1912
|
+
/** An automatic message recording a status change. */
|
|
1913
|
+
export declare interface OrderStatusMessage extends OrderMessageBase {
|
|
1914
|
+
type: 'status';
|
|
1915
|
+
/** Numeric status code, e.g. `1` order created, `3` invoice sent, `5` paid, `6` shipped. */
|
|
1916
|
+
status_id: number;
|
|
1917
|
+
actor: {
|
|
1918
|
+
username: string;
|
|
1919
|
+
resource_url: string;
|
|
1920
|
+
};
|
|
1921
|
+
}
|
|
1922
|
+
|
|
1923
|
+
/** A free-text message from the buyer or seller. */
|
|
1924
|
+
export declare interface OrderTextMessage extends OrderMessageBase {
|
|
1925
|
+
type: 'message';
|
|
1926
|
+
from: {
|
|
1927
|
+
id: number;
|
|
1928
|
+
username: string;
|
|
1929
|
+
avatar_url: string;
|
|
1930
|
+
resource_url: string;
|
|
1931
|
+
};
|
|
1932
|
+
}
|
|
1933
|
+
|
|
1934
|
+
/** Shipment tracking attached to an order. */
|
|
1935
|
+
export declare interface OrderTracking {
|
|
1936
|
+
number: string;
|
|
1937
|
+
carrier?: TrackingCarrier;
|
|
1938
|
+
/** Auto-generated by Discogs from the carrier and tracking number. */
|
|
1939
|
+
url?: string;
|
|
1940
|
+
}
|
|
1941
|
+
|
|
1942
|
+
/**
|
|
1943
|
+
* A monetary amount in the *seller's* original currency, returned alongside the converted
|
|
1944
|
+
* {@link Price} on listing resources.
|
|
1945
|
+
*/
|
|
1946
|
+
export declare interface OriginalPrice {
|
|
1947
|
+
curr_abbr: Currency;
|
|
1948
|
+
curr_id: number;
|
|
1949
|
+
formatted: string;
|
|
1950
|
+
value: number;
|
|
1951
|
+
}
|
|
1952
|
+
|
|
1953
|
+
/**
|
|
1954
|
+
* A paginated response envelope.
|
|
1955
|
+
*
|
|
1956
|
+
* Discogs names the collection key differently per endpoint (`releases`, `listings`, `wants`,
|
|
1957
|
+
* `items`, …), so the key is a type parameter.
|
|
1958
|
+
*
|
|
1959
|
+
* @typeParam K - Name of the key holding the collection.
|
|
1960
|
+
* @typeParam T - Element type of the collection.
|
|
1961
|
+
*/
|
|
1962
|
+
export declare type Paginated<K extends string, T> = {
|
|
1963
|
+
pagination: Pagination;
|
|
1964
|
+
} & {
|
|
1965
|
+
[P in K]: T[];
|
|
1966
|
+
};
|
|
1967
|
+
|
|
1968
|
+
/** The `pagination` object attached to every paginated response. */
|
|
1969
|
+
export declare interface Pagination {
|
|
1970
|
+
/** The page currently being viewed. */
|
|
1971
|
+
page: number;
|
|
1972
|
+
/** Total number of pages available. */
|
|
1973
|
+
pages: number;
|
|
1974
|
+
/** Total number of items across all pages. */
|
|
1975
|
+
items: number;
|
|
1976
|
+
/** Number of items on each page. */
|
|
1977
|
+
per_page: number;
|
|
1978
|
+
urls: PaginationUrls;
|
|
1979
|
+
}
|
|
1980
|
+
|
|
1981
|
+
/** Pagination parameters accepted by every paginated endpoint. */
|
|
1982
|
+
export declare interface PaginationParams {
|
|
1983
|
+
/** 1-based page number. Defaults to `1`. */
|
|
1984
|
+
page?: number;
|
|
1985
|
+
/** Items per page. Defaults to `50`, maximum `100`. */
|
|
1986
|
+
per_page?: number;
|
|
1987
|
+
}
|
|
1988
|
+
|
|
1989
|
+
/** Links to other pages of a paginated result. May be an empty object on single-page results. */
|
|
1990
|
+
export declare interface PaginationUrls {
|
|
1991
|
+
first?: string;
|
|
1992
|
+
prev?: string;
|
|
1993
|
+
next?: string;
|
|
1994
|
+
last?: string;
|
|
1995
|
+
}
|
|
1996
|
+
|
|
1997
|
+
/**
|
|
1998
|
+
* Parses an RFC 5988 `Link` header into its `rel` relations.
|
|
1999
|
+
*
|
|
2000
|
+
* The same information is available in the body's `pagination.urls`, so this is mainly useful
|
|
2001
|
+
* when you are working with a raw {@link Response} from {@link DiscogsClient.request}.
|
|
2002
|
+
*
|
|
2003
|
+
* @param header - Raw `Link` header value, or `null` when absent.
|
|
2004
|
+
* @returns A map of relation name to URL. Empty when the header is absent or unparseable.
|
|
2005
|
+
*
|
|
2006
|
+
* @example
|
|
2007
|
+
* ```ts
|
|
2008
|
+
* parseLinkHeader('<https://api.discogs.com/artists/1/releases?page=2>; rel=next')
|
|
2009
|
+
* // → { next: 'https://api.discogs.com/artists/1/releases?page=2' }
|
|
2010
|
+
* ```
|
|
2011
|
+
*/
|
|
2012
|
+
export declare function parseLinkHeader(header: string | null | undefined): PaginationUrls;
|
|
2013
|
+
|
|
2014
|
+
/**
|
|
2015
|
+
* Reads the rate-limit headers off a response.
|
|
2016
|
+
*
|
|
2017
|
+
* @returns The parsed rate-limit state, or `null` when the headers are absent — which happens
|
|
2018
|
+
* on endpoints Discogs does not throttle, and on responses served from a cache.
|
|
2019
|
+
*/
|
|
2020
|
+
export declare function parseRateLimit(headers: Headers): RateLimit | null;
|
|
2021
|
+
|
|
2022
|
+
/** A monetary amount as returned by most Marketplace endpoints. */
|
|
2023
|
+
export declare interface Price {
|
|
2024
|
+
currency: Currency;
|
|
2025
|
+
value: number;
|
|
2026
|
+
}
|
|
2027
|
+
|
|
2028
|
+
/**
|
|
2029
|
+
* Suggested prices keyed by media condition, denominated in the user's selling currency.
|
|
2030
|
+
*
|
|
2031
|
+
* An empty object is returned when Discogs has no suggestions for the release.
|
|
2032
|
+
*/
|
|
2033
|
+
export declare type PriceSuggestions = Partial<Record<MediaCondition, Price>>;
|
|
2034
|
+
|
|
2035
|
+
/** A bag of query-string parameters. `null` and `undefined` values are dropped. */
|
|
2036
|
+
export declare type QueryParams = Record<string, QueryValue>;
|
|
2037
|
+
|
|
2038
|
+
/** Query-string values the serializer knows how to render. */
|
|
2039
|
+
export declare type QueryValue = string | number | boolean | null | undefined | Array<string | number>;
|
|
2040
|
+
|
|
2041
|
+
/** Header carrying the total request allowance for the current window. */
|
|
2042
|
+
export declare const RATE_LIMIT_HEADER = "X-Discogs-Ratelimit";
|
|
2043
|
+
|
|
2044
|
+
/** Header carrying the number of requests still available in the current window. */
|
|
2045
|
+
export declare const RATE_LIMIT_REMAINING_HEADER = "X-Discogs-Ratelimit-Remaining";
|
|
2046
|
+
|
|
2047
|
+
/** Header carrying the number of requests already used in the current window. */
|
|
2048
|
+
export declare const RATE_LIMIT_USED_HEADER = "X-Discogs-Ratelimit-Used";
|
|
2049
|
+
|
|
2050
|
+
/**
|
|
2051
|
+
* Rate-limit state parsed from the `X-Discogs-Ratelimit*` response headers.
|
|
2052
|
+
*
|
|
2053
|
+
* Discogs throttles by source IP over a rolling 60-second window: 60 requests per minute when
|
|
2054
|
+
* authenticated, 25 when not.
|
|
2055
|
+
*
|
|
2056
|
+
* @see https://www.discogs.com/developers/#page:home,header:home-rate-limiting
|
|
2057
|
+
*/
|
|
2058
|
+
export declare interface RateLimit {
|
|
2059
|
+
/** Total number of requests permitted in the current one-minute window. */
|
|
2060
|
+
limit: number;
|
|
2061
|
+
/** Requests already made in the current window. */
|
|
2062
|
+
used: number;
|
|
2063
|
+
/** Requests still available in the current window. */
|
|
2064
|
+
remaining: number;
|
|
2065
|
+
}
|
|
2066
|
+
|
|
2067
|
+
/**
|
|
2068
|
+
* A release — a particular physical or digital object released by one or more artists.
|
|
2069
|
+
*
|
|
2070
|
+
* @see https://www.discogs.com/developers/#page:database,header:database-release
|
|
2071
|
+
*/
|
|
2072
|
+
export declare interface Release {
|
|
2073
|
+
id: number;
|
|
2074
|
+
title: string;
|
|
2075
|
+
status: SubmissionStatus;
|
|
2076
|
+
data_quality: DataQuality;
|
|
2077
|
+
resource_url: string;
|
|
2078
|
+
uri: string;
|
|
2079
|
+
artists: ArtistCredit[];
|
|
2080
|
+
/** @remarks Undocumented; returned by the live API. Artists joined into a sortable string. */
|
|
2081
|
+
artists_sort?: string;
|
|
2082
|
+
extraartists?: ArtistCredit[];
|
|
2083
|
+
labels: LabelCredit[];
|
|
2084
|
+
companies: CompanyCredit[];
|
|
2085
|
+
series: SeriesEntry[];
|
|
2086
|
+
formats: Format[];
|
|
2087
|
+
format_quantity: number;
|
|
2088
|
+
identifiers: Identifier[];
|
|
2089
|
+
genres: string[];
|
|
2090
|
+
styles?: string[];
|
|
2091
|
+
tracklist: Track[];
|
|
2092
|
+
images?: Image_2[];
|
|
2093
|
+
videos?: Video[];
|
|
2094
|
+
community: ReleaseCommunity;
|
|
2095
|
+
country?: string;
|
|
2096
|
+
released?: string;
|
|
2097
|
+
released_formatted?: string;
|
|
2098
|
+
year: number;
|
|
2099
|
+
notes?: string;
|
|
2100
|
+
/** Estimated shipping weight in grams. */
|
|
2101
|
+
estimated_weight?: number;
|
|
2102
|
+
date_added: string;
|
|
2103
|
+
date_changed: string;
|
|
2104
|
+
master_id?: number;
|
|
2105
|
+
master_url?: string;
|
|
2106
|
+
thumb: string;
|
|
2107
|
+
num_for_sale: number;
|
|
2108
|
+
lowest_price: number | null;
|
|
2109
|
+
/** @remarks Undocumented; returned by the live API. */
|
|
2110
|
+
blocked_from_sale?: boolean;
|
|
2111
|
+
/** @remarks Undocumented; returned by the live API. */
|
|
2112
|
+
is_offensive?: boolean;
|
|
2113
|
+
}
|
|
2114
|
+
|
|
2115
|
+
/** Community metadata attached to a release. */
|
|
2116
|
+
export declare interface ReleaseCommunity {
|
|
2117
|
+
have: number;
|
|
2118
|
+
want: number;
|
|
2119
|
+
rating: CommunityRating;
|
|
2120
|
+
status: SubmissionStatus;
|
|
2121
|
+
data_quality: DataQuality;
|
|
2122
|
+
submitter: UserRef;
|
|
2123
|
+
contributors: UserRef[];
|
|
2124
|
+
}
|
|
2125
|
+
|
|
2126
|
+
/** A user's rating of a release. */
|
|
2127
|
+
export declare interface ReleaseRating {
|
|
2128
|
+
username: string;
|
|
2129
|
+
release_id: number;
|
|
2130
|
+
/** 1–5, or `0` when the user has not rated the release. */
|
|
2131
|
+
rating: number;
|
|
2132
|
+
}
|
|
2133
|
+
|
|
2134
|
+
/**
|
|
2135
|
+
* "Have" and "want" counts for a release.
|
|
2136
|
+
*
|
|
2137
|
+
* @remarks Both fields may be absent for blocked releases; the live API also returns
|
|
2138
|
+
* `is_offensive` on this endpoint.
|
|
2139
|
+
*/
|
|
2140
|
+
export declare interface ReleaseStats {
|
|
2141
|
+
num_have?: number;
|
|
2142
|
+
num_want?: number;
|
|
2143
|
+
/** @remarks Undocumented; returned by the live API. */
|
|
2144
|
+
is_offensive?: boolean;
|
|
2145
|
+
}
|
|
2146
|
+
|
|
2147
|
+
/** Options for a single request. */
|
|
2148
|
+
export declare interface RequestOptions {
|
|
2149
|
+
method?: HttpMethod;
|
|
2150
|
+
/** Path relative to the base URL, e.g. `"/releases/249504"`. */
|
|
2151
|
+
path: string;
|
|
2152
|
+
query?: QueryParams;
|
|
2153
|
+
/** Body to send as JSON. Mutually exclusive with `formData`. */
|
|
2154
|
+
body?: unknown;
|
|
2155
|
+
/** Body to send as `multipart/form-data`. Mutually exclusive with `body`. */
|
|
2156
|
+
formData?: FormData;
|
|
2157
|
+
/** Extra headers, merged over the defaults. */
|
|
2158
|
+
headers?: HeadersInit;
|
|
2159
|
+
/** Aborts the request. */
|
|
2160
|
+
signal?: AbortSignal;
|
|
2161
|
+
/**
|
|
2162
|
+
* How to read the response body. `"json"` parses JSON, `"text"` returns the raw string,
|
|
2163
|
+
* `"none"` skips reading entirely and leaves the body for you.
|
|
2164
|
+
*/
|
|
2165
|
+
responseType?: 'json' | 'text' | 'none';
|
|
2166
|
+
}
|
|
2167
|
+
|
|
2168
|
+
/** A temporary request token, valid for 15 minutes. */
|
|
2169
|
+
export declare interface RequestToken {
|
|
2170
|
+
oauthToken: string;
|
|
2171
|
+
oauthTokenSecret: string;
|
|
2172
|
+
/** Discogs confirms it honoured the callback URL you supplied. */
|
|
2173
|
+
callbackConfirmed: boolean;
|
|
2174
|
+
}
|
|
2175
|
+
|
|
2176
|
+
/**
|
|
2177
|
+
* Query parameters for {@link DatabaseResource.search}.
|
|
2178
|
+
*
|
|
2179
|
+
* Every field is optional, but at least one should be supplied for a meaningful result.
|
|
2180
|
+
*
|
|
2181
|
+
* @see https://www.discogs.com/developers/#page:database,header:database-search
|
|
2182
|
+
*/
|
|
2183
|
+
export declare interface SearchParams extends PaginationParams {
|
|
2184
|
+
/** Free-text search query. Sent on the wire as `q`. */
|
|
2185
|
+
q?: string;
|
|
2186
|
+
/** Restrict results to a single resource type. */
|
|
2187
|
+
type?: SearchType;
|
|
2188
|
+
/** Search the combined `"Artist Name - Release Title"` field. */
|
|
2189
|
+
title?: string;
|
|
2190
|
+
/** Search release titles. */
|
|
2191
|
+
release_title?: string;
|
|
2192
|
+
/** Search release credits. */
|
|
2193
|
+
credit?: string;
|
|
2194
|
+
/** Search artist names. */
|
|
2195
|
+
artist?: string;
|
|
2196
|
+
/** Search artist name variations (ANV). */
|
|
2197
|
+
anv?: string;
|
|
2198
|
+
/** Search label names. */
|
|
2199
|
+
label?: string;
|
|
2200
|
+
/** Search genres. */
|
|
2201
|
+
genre?: string;
|
|
2202
|
+
/** Search styles. */
|
|
2203
|
+
style?: string;
|
|
2204
|
+
/** Search release country. */
|
|
2205
|
+
country?: string;
|
|
2206
|
+
/** Search release year. */
|
|
2207
|
+
year?: string | number;
|
|
2208
|
+
/** Search formats. */
|
|
2209
|
+
format?: string;
|
|
2210
|
+
/** Search catalogue numbers. */
|
|
2211
|
+
catno?: string;
|
|
2212
|
+
/** Search barcodes. */
|
|
2213
|
+
barcode?: string;
|
|
2214
|
+
/** Search track titles. */
|
|
2215
|
+
track?: string;
|
|
2216
|
+
/** Search by submitter username. */
|
|
2217
|
+
submitter?: string;
|
|
2218
|
+
/** Search by contributor username. */
|
|
2219
|
+
contributor?: string;
|
|
2220
|
+
}
|
|
2221
|
+
|
|
2222
|
+
/** Response of {@link DatabaseResource.search}. */
|
|
2223
|
+
export declare type SearchResponse = Paginated<'results', SearchResult>;
|
|
2224
|
+
|
|
2225
|
+
/**
|
|
2226
|
+
* A single search result.
|
|
2227
|
+
*
|
|
2228
|
+
* Which fields are populated depends on the `type` of the result, so nearly everything is
|
|
2229
|
+
* optional.
|
|
2230
|
+
*/
|
|
2231
|
+
export declare interface SearchResult {
|
|
2232
|
+
id: number;
|
|
2233
|
+
type: SearchType;
|
|
2234
|
+
title: string;
|
|
2235
|
+
uri: string;
|
|
2236
|
+
resource_url: string;
|
|
2237
|
+
thumb: string;
|
|
2238
|
+
/** @remarks Undocumented; returned by the live API. */
|
|
2239
|
+
cover_image?: string;
|
|
2240
|
+
/** Release year as a string — Discogs does not return a number here. */
|
|
2241
|
+
year?: string;
|
|
2242
|
+
country?: string;
|
|
2243
|
+
catno?: string;
|
|
2244
|
+
label?: string[];
|
|
2245
|
+
genre?: string[];
|
|
2246
|
+
style?: string[];
|
|
2247
|
+
format?: string[];
|
|
2248
|
+
barcode?: string[];
|
|
2249
|
+
community?: {
|
|
2250
|
+
want: number;
|
|
2251
|
+
have: number;
|
|
2252
|
+
};
|
|
2253
|
+
/** @remarks Undocumented; returned by the live API for release results. */
|
|
2254
|
+
master_id?: number | null;
|
|
2255
|
+
/** @remarks Undocumented; returned by the live API for release results. */
|
|
2256
|
+
master_url?: string | null;
|
|
2257
|
+
/** @remarks Undocumented; returned by the live API for release results. */
|
|
2258
|
+
formats?: Format[];
|
|
2259
|
+
/** @remarks Undocumented; returned by the live API when authenticated. */
|
|
2260
|
+
user_data?: {
|
|
2261
|
+
in_wantlist: boolean;
|
|
2262
|
+
in_collection: boolean;
|
|
2263
|
+
};
|
|
2264
|
+
}
|
|
2265
|
+
|
|
2266
|
+
/** Resource types that can be searched. */
|
|
2267
|
+
export declare type SearchType = 'release' | 'master' | 'artist' | 'label';
|
|
2268
|
+
|
|
2269
|
+
/** Seller rating summary. */
|
|
2270
|
+
export declare interface SellerStats {
|
|
2271
|
+
/** Percentage rating, returned as a string (e.g. `"100"`). */
|
|
2272
|
+
rating: string;
|
|
2273
|
+
stars: number;
|
|
2274
|
+
total: number;
|
|
2275
|
+
}
|
|
2276
|
+
|
|
2277
|
+
/** An entry in the `series` array of a release. */
|
|
2278
|
+
export declare interface SeriesEntry {
|
|
2279
|
+
id: number;
|
|
2280
|
+
name: string;
|
|
2281
|
+
catno: string;
|
|
2282
|
+
entity_type: string;
|
|
2283
|
+
entity_type_name?: string;
|
|
2284
|
+
resource_url: string;
|
|
2285
|
+
/** @remarks Undocumented; returned by the live API on some resources. */
|
|
2286
|
+
thumbnail_url?: string;
|
|
2287
|
+
}
|
|
2288
|
+
|
|
2289
|
+
/** Every {@link SleeveCondition}. */
|
|
2290
|
+
export declare const SLEEVE_CONDITIONS: readonly SleeveCondition[];
|
|
2291
|
+
|
|
2292
|
+
/** Grading for the sleeve: any {@link MediaCondition}, plus three sleeve-specific values. */
|
|
2293
|
+
export declare type SleeveCondition = MediaCondition | 'Generic' | 'Not Graded' | 'No Cover';
|
|
2294
|
+
|
|
2295
|
+
/** Sort direction accepted by every endpoint that takes a `sort` parameter. */
|
|
2296
|
+
export declare type SortOrder = 'asc' | 'desc';
|
|
2297
|
+
|
|
2298
|
+
/** An artist entry in a user's submissions. */
|
|
2299
|
+
export declare interface SubmissionArtist {
|
|
2300
|
+
id: number;
|
|
2301
|
+
name: string;
|
|
2302
|
+
namevariations: string[];
|
|
2303
|
+
data_quality: string;
|
|
2304
|
+
releases_url: string;
|
|
2305
|
+
resource_url: string;
|
|
2306
|
+
uri: string;
|
|
2307
|
+
}
|
|
2308
|
+
|
|
2309
|
+
/** A label entry in a user's submissions. */
|
|
2310
|
+
export declare interface SubmissionLabel {
|
|
2311
|
+
id: number;
|
|
2312
|
+
name: string;
|
|
2313
|
+
profile?: string;
|
|
2314
|
+
releases_url: string;
|
|
2315
|
+
resource_url: string;
|
|
2316
|
+
uri: string;
|
|
2317
|
+
data_quality: string;
|
|
2318
|
+
}
|
|
2319
|
+
|
|
2320
|
+
/** The database entries a user has submitted, grouped by resource type. */
|
|
2321
|
+
export declare interface Submissions {
|
|
2322
|
+
artists: SubmissionArtist[];
|
|
2323
|
+
labels: SubmissionLabel[];
|
|
2324
|
+
releases: Release[];
|
|
2325
|
+
}
|
|
2326
|
+
|
|
2327
|
+
/**
|
|
2328
|
+
* Response of {@link UserResource.getSubmissions}.
|
|
2329
|
+
*
|
|
2330
|
+
* Unlike other paginated endpoints the collection key holds an object grouping three arrays,
|
|
2331
|
+
* not a single array, so {@link Paginated} does not apply here.
|
|
2332
|
+
*/
|
|
2333
|
+
export declare interface SubmissionsResponse {
|
|
2334
|
+
pagination: Pagination;
|
|
2335
|
+
submissions: Submissions;
|
|
2336
|
+
}
|
|
2337
|
+
|
|
2338
|
+
/** Submission status of a database entry, e.g. `"Accepted"`. */
|
|
2339
|
+
export declare type SubmissionStatus = string;
|
|
2340
|
+
|
|
2341
|
+
/**
|
|
2342
|
+
* Authenticates with a personal access token.
|
|
2343
|
+
*
|
|
2344
|
+
* Sends `Authorization: Discogs token=<token>`. This authenticates as the token holder and
|
|
2345
|
+
* only as the token holder — use {@link OAuth1Auth} to act on behalf of other users.
|
|
2346
|
+
*
|
|
2347
|
+
* @see https://www.discogs.com/developers/#page:authentication,header:authentication-discogs-auth-flow
|
|
2348
|
+
*/
|
|
2349
|
+
export declare class TokenAuth implements AuthStrategy {
|
|
2350
|
+
#private;
|
|
2351
|
+
constructor(token: string);
|
|
2352
|
+
authorize(request: AuthorizableRequest): void;
|
|
2353
|
+
}
|
|
2354
|
+
|
|
2355
|
+
/** Credentials for a personal access token, generated in Discogs Developer Settings. */
|
|
2356
|
+
export declare interface TokenCredentials {
|
|
2357
|
+
/** A personal access token. Authenticates as the token holder. */
|
|
2358
|
+
token: string;
|
|
2359
|
+
}
|
|
2360
|
+
|
|
2361
|
+
/** A single entry in a release or master tracklist. */
|
|
2362
|
+
export declare interface Track {
|
|
2363
|
+
position: string;
|
|
2364
|
+
/** Trailing underscore is part of the wire format. Usually `"track"` or `"heading"`. */
|
|
2365
|
+
type_: string;
|
|
2366
|
+
title: string;
|
|
2367
|
+
duration: string;
|
|
2368
|
+
artists?: ArtistCredit[];
|
|
2369
|
+
extraartists?: ArtistCredit[];
|
|
2370
|
+
}
|
|
2371
|
+
|
|
2372
|
+
/** Every {@link TrackingCarrier}. */
|
|
2373
|
+
export declare const TRACKING_CARRIERS: readonly TrackingCarrier[];
|
|
2374
|
+
|
|
2375
|
+
/** Carriers Discogs can generate a tracking URL for. */
|
|
2376
|
+
export declare type TrackingCarrier = 'UPS' | 'USPS' | 'DHL' | 'Deutsche Post' | 'La Poste' | 'Royal Mail' | 'PostNL' | 'DHL Germany' | 'Other';
|
|
2377
|
+
|
|
2378
|
+
/** Reference to a user that also carries their numeric id. */
|
|
2379
|
+
export declare interface UserIdRef extends UserRef {
|
|
2380
|
+
id: number;
|
|
2381
|
+
}
|
|
2382
|
+
|
|
2383
|
+
/** Response of {@link ListsResource.getUserLists}. */
|
|
2384
|
+
export declare type UserListsResponse = Paginated<'lists', ListSummary>;
|
|
2385
|
+
|
|
2386
|
+
/**
|
|
2387
|
+
* A user profile.
|
|
2388
|
+
*
|
|
2389
|
+
* `email` is only returned when authenticated as this user. `num_collection` and
|
|
2390
|
+
* `num_wantlist` are only returned when authenticated as this user or when the respective
|
|
2391
|
+
* list is public, and `num_lists` only counts private lists for the owner.
|
|
2392
|
+
*
|
|
2393
|
+
* @see https://www.discogs.com/developers/#page:user-identity,header:user-identity-profile
|
|
2394
|
+
*/
|
|
2395
|
+
export declare interface UserProfile {
|
|
2396
|
+
id: number;
|
|
2397
|
+
username: string;
|
|
2398
|
+
/** The user's real name. */
|
|
2399
|
+
name?: string;
|
|
2400
|
+
/** Only visible when authenticated as this user. */
|
|
2401
|
+
email?: string;
|
|
2402
|
+
/** Profile text, which may contain BBCode. */
|
|
2403
|
+
profile: string;
|
|
2404
|
+
home_page: string;
|
|
2405
|
+
location: string;
|
|
2406
|
+
/** ISO 8601 registration timestamp. */
|
|
2407
|
+
registered: string;
|
|
2408
|
+
rank: number;
|
|
2409
|
+
uri: string;
|
|
2410
|
+
resource_url: string;
|
|
2411
|
+
inventory_url: string;
|
|
2412
|
+
wantlist_url: string;
|
|
2413
|
+
collection_folders_url: string;
|
|
2414
|
+
collection_fields_url: string;
|
|
2415
|
+
avatar_url: string;
|
|
2416
|
+
/** @remarks Not returned by the profile-edit endpoint. */
|
|
2417
|
+
banner_url?: string;
|
|
2418
|
+
num_lists: number;
|
|
2419
|
+
num_for_sale: number;
|
|
2420
|
+
num_collection?: number;
|
|
2421
|
+
num_wantlist?: number;
|
|
2422
|
+
num_pending: number;
|
|
2423
|
+
releases_contributed: number;
|
|
2424
|
+
releases_rated: number;
|
|
2425
|
+
rating_avg: number;
|
|
2426
|
+
/** The user's preferred currency. Not returned by the profile-edit endpoint. */
|
|
2427
|
+
curr_abbr?: Currency;
|
|
2428
|
+
buyer_rating?: number;
|
|
2429
|
+
buyer_rating_stars?: number;
|
|
2430
|
+
buyer_num_ratings?: number;
|
|
2431
|
+
seller_rating?: number;
|
|
2432
|
+
seller_rating_stars?: number;
|
|
2433
|
+
seller_num_ratings?: number;
|
|
2434
|
+
/** @remarks Undocumented; returned by the live API. Unread message count, owner only. */
|
|
2435
|
+
num_unread?: number;
|
|
2436
|
+
/** @remarks Undocumented; returned by the live API. */
|
|
2437
|
+
activated?: boolean;
|
|
2438
|
+
/** @remarks Undocumented; returned by the live API. */
|
|
2439
|
+
marketplace_suspended?: boolean;
|
|
2440
|
+
/** @remarks Undocumented; returned by the live API. */
|
|
2441
|
+
is_staff?: boolean;
|
|
2442
|
+
/** @remarks Undocumented; returned by the live API. */
|
|
2443
|
+
seller_payment_disabled?: boolean;
|
|
2444
|
+
}
|
|
2445
|
+
|
|
2446
|
+
/** Minimal reference to a user, as embedded in other resources. */
|
|
2447
|
+
export declare interface UserRef {
|
|
2448
|
+
username: string;
|
|
2449
|
+
resource_url: string;
|
|
2450
|
+
}
|
|
2451
|
+
|
|
2452
|
+
/**
|
|
2453
|
+
* User identity endpoints.
|
|
2454
|
+
*
|
|
2455
|
+
* Reachable as `client.user`.
|
|
2456
|
+
*/
|
|
2457
|
+
export declare class UserResource {
|
|
2458
|
+
#private;
|
|
2459
|
+
constructor(client: DiscogsClient);
|
|
2460
|
+
/**
|
|
2461
|
+
* Gets basic information about the authenticated user — useful as a credentials check at
|
|
2462
|
+
* the end of the OAuth flow.
|
|
2463
|
+
*
|
|
2464
|
+
* @see https://www.discogs.com/developers/#page:user-identity,header:user-identity-identity
|
|
2465
|
+
*/
|
|
2466
|
+
getIdentity(): Promise<Identity>;
|
|
2467
|
+
/**
|
|
2468
|
+
* Gets a user's profile.
|
|
2469
|
+
*
|
|
2470
|
+
* `email` is only returned when authenticated as this user; `num_collection` and
|
|
2471
|
+
* `num_wantlist` only when authenticated as this user or when the list in question is
|
|
2472
|
+
* public.
|
|
2473
|
+
*
|
|
2474
|
+
* @see https://www.discogs.com/developers/#page:user-identity,header:user-identity-profile
|
|
2475
|
+
*/
|
|
2476
|
+
getProfile(username: string): Promise<UserProfile>;
|
|
2477
|
+
/**
|
|
2478
|
+
* Edits a user's profile. Requires authentication as that user.
|
|
2479
|
+
*
|
|
2480
|
+
* @see https://www.discogs.com/developers/#page:user-identity,header:user-identity-profile-post
|
|
2481
|
+
*/
|
|
2482
|
+
editProfile(username: string, params: EditProfileParams): Promise<UserProfile>;
|
|
2483
|
+
/**
|
|
2484
|
+
* Lists the database entries a user has submitted, grouped into artists, labels and
|
|
2485
|
+
* releases.
|
|
2486
|
+
*
|
|
2487
|
+
* @see https://www.discogs.com/developers/#page:user-identity,header:user-identity-user-submissions
|
|
2488
|
+
*/
|
|
2489
|
+
getSubmissions(username: string, params?: PaginationParams): Promise<SubmissionsResponse>;
|
|
2490
|
+
/**
|
|
2491
|
+
* Lists a user's contributions — the releases they have edited or added to.
|
|
2492
|
+
*
|
|
2493
|
+
* @see https://www.discogs.com/developers/#page:user-identity,header:user-identity-user-contributions
|
|
2494
|
+
*/
|
|
2495
|
+
getContributions(username: string, params?: GetContributionsParams): Promise<ContributionsResponse>;
|
|
2496
|
+
}
|
|
2497
|
+
|
|
2498
|
+
/** An embedded video (usually YouTube) attached to a release, master or artist. */
|
|
2499
|
+
export declare interface Video {
|
|
2500
|
+
uri: string;
|
|
2501
|
+
title: string;
|
|
2502
|
+
description: string;
|
|
2503
|
+
/** Duration in seconds. */
|
|
2504
|
+
duration: number;
|
|
2505
|
+
embed: boolean;
|
|
2506
|
+
}
|
|
2507
|
+
|
|
2508
|
+
/**
|
|
2509
|
+
* A release on a user's wantlist.
|
|
2510
|
+
*
|
|
2511
|
+
* @remarks `notes` here is a plain string and is only visible to the wantlist owner — on
|
|
2512
|
+
* collection items, by contrast, `notes` is an array of custom field values.
|
|
2513
|
+
*/
|
|
2514
|
+
export declare interface WantlistItem {
|
|
2515
|
+
/** The release id. */
|
|
2516
|
+
id: number;
|
|
2517
|
+
resource_url: string;
|
|
2518
|
+
/** 0–5, where `0` means unrated. */
|
|
2519
|
+
rating: number;
|
|
2520
|
+
/** Only visible when authenticated as the wantlist owner. */
|
|
2521
|
+
notes?: string;
|
|
2522
|
+
basic_information: BasicInformation;
|
|
2523
|
+
}
|
|
2524
|
+
|
|
2525
|
+
/** Parameters accepted when adding to or editing an entry on the wantlist. */
|
|
2526
|
+
export declare interface WantlistItemParams {
|
|
2527
|
+
/** User notes to associate with this release. */
|
|
2528
|
+
notes?: string;
|
|
2529
|
+
/** The user's rating of this release, from 0 (unrated) to 5 (best). Defaults to `0`. */
|
|
2530
|
+
rating?: number;
|
|
2531
|
+
}
|
|
2532
|
+
|
|
2533
|
+
/**
|
|
2534
|
+
* User wantlist endpoints.
|
|
2535
|
+
*
|
|
2536
|
+
* Reachable as `client.wantlist`.
|
|
2537
|
+
*/
|
|
2538
|
+
export declare class WantlistResource {
|
|
2539
|
+
#private;
|
|
2540
|
+
constructor(client: DiscogsClient);
|
|
2541
|
+
/**
|
|
2542
|
+
* Lists the releases on a user's wantlist.
|
|
2543
|
+
*
|
|
2544
|
+
* A private wantlist requires authentication as its owner, and the `notes` field is only
|
|
2545
|
+
* returned to the owner.
|
|
2546
|
+
*
|
|
2547
|
+
* @see https://www.discogs.com/developers/#page:user-wantlist,header:user-wantlist-wantlist
|
|
2548
|
+
*/
|
|
2549
|
+
getWants(username: string, params?: PaginationParams): Promise<WantlistResponse>;
|
|
2550
|
+
/**
|
|
2551
|
+
* Adds a release to a user's wantlist. Requires authentication as the wantlist owner.
|
|
2552
|
+
*
|
|
2553
|
+
* @see https://www.discogs.com/developers/#page:user-wantlist,header:user-wantlist-add-to-wantlist
|
|
2554
|
+
*/
|
|
2555
|
+
addToWantlist(username: string, releaseId: number, params?: WantlistItemParams): Promise<WantlistItem>;
|
|
2556
|
+
/**
|
|
2557
|
+
* Edits the notes or rating on a wantlist entry. Requires authentication as the owner.
|
|
2558
|
+
*
|
|
2559
|
+
* @see https://www.discogs.com/developers/#page:user-wantlist,header:user-wantlist-add-to-wantlist-post
|
|
2560
|
+
*/
|
|
2561
|
+
editWantlistItem(username: string, releaseId: number, params?: WantlistItemParams): Promise<WantlistItem>;
|
|
2562
|
+
/**
|
|
2563
|
+
* Removes a release from a user's wantlist. Requires authentication as the owner.
|
|
2564
|
+
*
|
|
2565
|
+
* @see https://www.discogs.com/developers/#page:user-wantlist,header:user-wantlist-add-to-wantlist-delete
|
|
2566
|
+
*/
|
|
2567
|
+
removeFromWantlist(username: string, releaseId: number): Promise<void>;
|
|
2568
|
+
}
|
|
2569
|
+
|
|
2570
|
+
/** Response of {@link WantlistResource.getWants}. */
|
|
2571
|
+
export declare type WantlistResponse = Paginated<'wants', WantlistItem>;
|
|
2572
|
+
|
|
2573
|
+
export { }
|