discogs-marketplace-api-nodejs 1.13.0 β 1.14.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/README.MD +150 -157
- package/dist/index.d.ts +1 -3
- package/dist/index.js +1 -2
- package/dist/interfaces/search-params.interface.d.ts +168 -67
- package/dist/interfaces/search-result.interface.d.ts +37 -26
- package/dist/scrapers/legacy.scraper.d.ts +2 -2
- package/dist/scrapers/legacy.scraper.js +70 -71
- package/dist/scrapers/modern.scraper.d.ts +2 -5
- package/dist/scrapers/modern.scraper.js +57 -41
- package/dist/scrapers/wantlist.scraper.d.ts +2 -2
- package/dist/scrapers/wantlist.scraper.js +3 -7
- package/dist/search.d.ts +6 -3
- package/dist/search.js +19 -16
- package/dist/types/api.type.d.ts +4 -0
- package/dist/types/from.type.d.ts +2 -1
- package/package.json +1 -1
- package/dist/get-search-params.d.ts +0 -10
- package/dist/get-search-params.js +0 -119
- package/dist/types/search-type.type.d.ts +0 -4
- /package/dist/types/{search-type.type.js β api.type.js} +0 -0
package/README.MD
CHANGED
|
@@ -17,12 +17,12 @@ npm install discogs-marketplace-api-nodejs
|
|
|
17
17
|
import { DiscogsMarketplace } from 'discogs-marketplace-api-nodejs'
|
|
18
18
|
|
|
19
19
|
const result = await DiscogsMarketplace.search({
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
api: 'v2',
|
|
21
|
+
artistIds: [244819],
|
|
22
|
+
genres: ['Rock'],
|
|
23
|
+
sort: 'price,asc',
|
|
24
|
+
limit: 50,
|
|
25
|
+
page: 1,
|
|
26
26
|
})
|
|
27
27
|
|
|
28
28
|
console.log(result.items)
|
|
@@ -30,29 +30,45 @@ console.log(result.items)
|
|
|
30
30
|
|
|
31
31
|
## π Usage Examples
|
|
32
32
|
|
|
33
|
+
This library offers two API modes to access Discogs Marketplace data. The required `api` parameter determines which endpoint to use:
|
|
34
|
+
|
|
35
|
+
- **`api: 'v2'`** (Modern JSON API) - Recommended for most use cases, offers advanced filtering
|
|
36
|
+
- **`api: 'legacy'`** (HTML scraping) - Required for certain search types and general queries
|
|
37
|
+
|
|
38
|
+
Each API has different capabilities and available parameters. See the [API Reference](#-api-reference) section for complete details.
|
|
39
|
+
|
|
33
40
|
### 1. Get 250 latest listings by a specific artist in the Rock genre, page 2
|
|
34
41
|
|
|
35
42
|
```ts
|
|
36
43
|
// https://www.discogs.com/sell/list?sort=listed,desc&limit=250&artist_id=244819&page=2&genre=Rock
|
|
37
44
|
const result = await DiscogsMarketplace.search({
|
|
38
|
-
|
|
39
|
-
|
|
45
|
+
api: 'legacy',
|
|
46
|
+
artistId: 244819,
|
|
40
47
|
genre: 'Rock',
|
|
41
48
|
sort: 'listed,desc',
|
|
42
49
|
limit: 250,
|
|
43
50
|
page: 2,
|
|
44
51
|
})
|
|
52
|
+
// OR
|
|
53
|
+
const result = await DiscogsMarketplace.search({
|
|
54
|
+
api: 'v2',
|
|
55
|
+
artistIds: [244819],
|
|
56
|
+
genres: ['Rock'],
|
|
57
|
+
sort: 'listed,desc',
|
|
58
|
+
limit: 250,
|
|
59
|
+
page: 2,
|
|
60
|
+
})
|
|
45
61
|
```
|
|
46
62
|
|
|
47
63
|
### 2. Get listings of a user's wantlist, sorted by price, limit 50
|
|
48
64
|
|
|
49
65
|
```ts
|
|
50
|
-
// https://www.discogs.com/
|
|
66
|
+
// https://www.discogs.com/shop/mywants
|
|
51
67
|
const result = await DiscogsMarketplace.search({
|
|
68
|
+
api: 'v2',
|
|
52
69
|
limit: 50,
|
|
53
70
|
sort: 'price,asc',
|
|
54
|
-
|
|
55
|
-
searchValue: 'Kirian_',
|
|
71
|
+
wantlist: 'Kirian_',
|
|
56
72
|
})
|
|
57
73
|
```
|
|
58
74
|
|
|
@@ -62,8 +78,14 @@ const result = await DiscogsMarketplace.search({
|
|
|
62
78
|
// https://www.discogs.com/sell/list?release_id=767931&sort=seller,asc&limit=25
|
|
63
79
|
// https://www.discogs.com/sell/release/767931?sort=seller,asc&limit=25
|
|
64
80
|
const result = await DiscogsMarketplace.search({
|
|
65
|
-
|
|
66
|
-
|
|
81
|
+
api: 'legacy',
|
|
82
|
+
releaseId: 767931,
|
|
83
|
+
sort: 'seller,asc',
|
|
84
|
+
})
|
|
85
|
+
// OR
|
|
86
|
+
const result = await DiscogsMarketplace.search({
|
|
87
|
+
api: 'v2',
|
|
88
|
+
releaseIds: [767931],
|
|
67
89
|
sort: 'seller,asc',
|
|
68
90
|
})
|
|
69
91
|
```
|
|
@@ -73,8 +95,8 @@ const result = await DiscogsMarketplace.search({
|
|
|
73
95
|
```ts
|
|
74
96
|
// https://www.discogs.com/sell/list?sort=listed,desc&limit=100&q=in+flames&page=1
|
|
75
97
|
const result = await DiscogsMarketplace.search({
|
|
76
|
-
|
|
77
|
-
|
|
98
|
+
api: 'legacy',
|
|
99
|
+
query: 'in flames',
|
|
78
100
|
sort: 'listed,desc',
|
|
79
101
|
limit: 100,
|
|
80
102
|
})
|
|
@@ -86,167 +108,142 @@ const result = await DiscogsMarketplace.search({
|
|
|
86
108
|
// https://www.discogs.com/sell/list?sort=listed,desc&seller=Kirian_
|
|
87
109
|
// https://www.discogs.com/seller/Kirian_/profile?sort=listed,desc
|
|
88
110
|
const result = await DiscogsMarketplace.search({
|
|
111
|
+
api: 'legacy',
|
|
89
112
|
sort: 'listed,desc',
|
|
90
|
-
searchType: 'q',
|
|
91
113
|
seller: 'Kirian_',
|
|
92
114
|
})
|
|
115
|
+
// OR
|
|
116
|
+
const result = await DiscogsMarketplace.search({
|
|
117
|
+
api: 'v2',
|
|
118
|
+
sort: 'listed,desc',
|
|
119
|
+
sellerIds: [6562907],
|
|
120
|
+
})
|
|
93
121
|
```
|
|
94
122
|
|
|
95
123
|
### 6. Get newest listings of a user's wantlist, on a seller inventory
|
|
96
124
|
|
|
97
125
|
```ts
|
|
98
|
-
// https://www.discogs.com/sell/mywants?sort=listed,desc&seller=Kirian_&user=Kirian_
|
|
99
126
|
// https://www.discogs.com/seller/Kirian_/mywants?sort=listed,desc&user=Kirian_
|
|
100
127
|
const result = await DiscogsMarketplace.search({
|
|
128
|
+
api: 'legacy',
|
|
101
129
|
sort: 'listed,desc',
|
|
102
|
-
searchType: 'user',
|
|
103
|
-
searchValue: 'Kirian_',
|
|
104
130
|
seller: 'Kirian_',
|
|
131
|
+
user: 'Kirian_',
|
|
132
|
+
})
|
|
133
|
+
// OR
|
|
134
|
+
const result = await DiscogsMarketplace.search({
|
|
135
|
+
api: 'v2',
|
|
136
|
+
sort: 'listed,desc',
|
|
137
|
+
wantlist: 'Kirian_',
|
|
138
|
+
sellerIds: [6562907],
|
|
105
139
|
})
|
|
106
140
|
```
|
|
107
141
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
### 1. Extract correct parameters from URL
|
|
142
|
+
### 7. Get listings by a general search query (e.g., "red"), sorted by newest listings, on a master release
|
|
111
143
|
|
|
112
144
|
```ts
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
// page: 2,
|
|
121
|
-
// lang: 'fr',
|
|
122
|
-
// }
|
|
145
|
+
// https://www.discogs.com/sell/list?master_id=28291&q=red
|
|
146
|
+
const result = await DiscogsMarketplace.search({
|
|
147
|
+
api: 'legacy',
|
|
148
|
+
sort: 'listed,desc',
|
|
149
|
+
masterId: 2167270,
|
|
150
|
+
query: 'red',
|
|
151
|
+
})
|
|
123
152
|
```
|
|
124
153
|
|
|
125
154
|
## π§© API Reference
|
|
126
155
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
max: number
|
|
192
|
-
}
|
|
193
|
-
/**
|
|
194
|
-
* If true, only listings that accept offers are returned.
|
|
195
|
-
* @default false
|
|
196
|
-
*/
|
|
197
|
-
isMakeAnOfferOnly?: boolean
|
|
198
|
-
/**
|
|
199
|
-
* Expedition country filter (2-letter country code).
|
|
200
|
-
* @example 'US'
|
|
201
|
-
*/
|
|
202
|
-
from?: From
|
|
203
|
-
/**
|
|
204
|
-
* Seller's username filter.
|
|
205
|
-
*/
|
|
206
|
-
seller?: string
|
|
207
|
-
/**
|
|
208
|
-
* Sort order for the results.
|
|
209
|
-
* @default 'listed,desc'
|
|
210
|
-
*/
|
|
211
|
-
sort?: Sort
|
|
212
|
-
/**
|
|
213
|
-
* Number of results to return per page.
|
|
214
|
-
* Allowed values: 25, 50, 100, 250.
|
|
215
|
-
* @default 25
|
|
216
|
-
*/
|
|
217
|
-
limit?: Limit
|
|
218
|
-
/**
|
|
219
|
-
* Page number of results.
|
|
220
|
-
* Must be less than 401 to avoid Discogs 404 errors.
|
|
221
|
-
* @default 1
|
|
222
|
-
*/
|
|
223
|
-
page?: number
|
|
224
|
-
/**
|
|
225
|
-
* Language code for Discogs interface.
|
|
226
|
-
* @default 'en'
|
|
227
|
-
*/
|
|
228
|
-
lang?: Lang
|
|
229
|
-
}
|
|
230
|
-
```
|
|
231
|
-
|
|
232
|
-
On success, it returns a result matching this interface:
|
|
156
|
+
This library provides two different ways to search the Discogs Marketplace:
|
|
157
|
+
|
|
158
|
+
- **Modern API (`api: 'v2'`)** β JSON API, used by the Discogs "My Wants" page.
|
|
159
|
+
- **Legacy API (`api: 'legacy'`)** β HTML scraping, required for some cases.
|
|
160
|
+
|
|
161
|
+
Both share common search filters and extend them with API-specific options via the `SearchParams` interface.
|
|
162
|
+
|
|
163
|
+
### Modern API (`api: "v2"`), recommended for most use cases
|
|
164
|
+
|
|
165
|
+
| Field | Type | Description | Example | Default |
|
|
166
|
+
|-------------------------|---------------------|------------------------------------|-------------------------|---------|
|
|
167
|
+
| `api` | `'v2'` | Selects the modern API. | `'v2'` | β |
|
|
168
|
+
| `currencies` | `Currency[]` | Filter by multiple currencies. | `['USD', 'EUR']` | β |
|
|
169
|
+
| `conditions` | `Condition[]` | List of media/sleeve conditions. | `['Mint (M)']` | β |
|
|
170
|
+
| `genres` | `Genre[]` | Filter by multiple genres. | `['Rock', 'Jazz']` | β |
|
|
171
|
+
| `from` | `From[]` | Filter by sellerβs countries. | `['FR', 'DE']` | β |
|
|
172
|
+
| `sort` | `Sort` | Sort and sort order. | `'listed,desc'` | `'listed,desc'` |
|
|
173
|
+
| `artistIds` | `number[]` | Filter by artist IDs. | `[123, 456]` | β |
|
|
174
|
+
| `sellerIds` | `number[]` | Filter by seller IDs. | `[789, 1011]` | β |
|
|
175
|
+
| `priceRange.min`/`max` | `number` | Filter by price range. | `{ min: 10, max: 100 }` | β |
|
|
176
|
+
| `sellerRatingMin` | `number (0β100)` | Minimum seller rating. | `90` | `0` |
|
|
177
|
+
| `includeGenericSleeves` | `boolean` | Include generic sleeves. | β | `true` |
|
|
178
|
+
| `includeSleevelessMedia`| `boolean` | Include sleeveless media. | β | `true` |
|
|
179
|
+
| `showUnavailable` | `boolean` | Show unavailable items. | β | `true` |
|
|
180
|
+
| `sellerRatingCountMin` | `number` | Minimum number of seller ratings. | `50` | `0` |
|
|
181
|
+
| `wantlist`* | `string` | Search by wantlist username. | `"username"` | β |
|
|
182
|
+
| `releaseIds`* | `number[]` | Search by release IDs. | `[12345, 67890]` | β |
|
|
183
|
+
|
|
184
|
+
\* Only **one** of `wantlist` or `releaseIds` can be used.
|
|
185
|
+
|
|
186
|
+
### Legacy API (`api: "legacy"`)
|
|
187
|
+
|
|
188
|
+
| Field | Type | Description | Example | Default |
|
|
189
|
+
|--------------|-----------------|------------------------------------|--------------------------------|---------|
|
|
190
|
+
| `api` | `'legacy'` | Selects the legacy API. | `'legacy'` | β |
|
|
191
|
+
| `query` | `string` | Search string. | `"something"` | β |
|
|
192
|
+
| `currency` | `Currency` | Currency code for price filtering. | `'USD'` | β |
|
|
193
|
+
| `condition` | `Condition` | Media/sleeve conditions. | `'Mint (M)'` | β |
|
|
194
|
+
| `genre` | `Genre` | Filter by genre. | `'Rock'` | β |
|
|
195
|
+
| `styles` | `Style[]` | Filter by style. | `['Death Metal', 'Heavy Metal']` | β |
|
|
196
|
+
| `from` | `From` | Filter by sellerβs country. | `'FR'` | β |
|
|
197
|
+
| `sort` | `Sort` | Sort order for results. | `'listed,desc'` | `'listed,desc'` |
|
|
198
|
+
| `seller` | `string` | Filter by seller username. | `"seller_name"` | β |
|
|
199
|
+
| `user` | `string` | Filter by user. | `"my_username"` | β |
|
|
200
|
+
| `lang` | `Lang` | Discogs interface language. | `'en'` | `'en'` |
|
|
201
|
+
| `masterId`* | `number` | Search by master release ID. | `12345` | β |
|
|
202
|
+
| `labelId`* | `number` | Search by label ID. | `67890` | β |
|
|
203
|
+
| `releaseId`* | `number` | Search by release ID. | `11111` | β |
|
|
204
|
+
| `artistId`* | `number` | Search by artist ID. | `22222` | β |
|
|
205
|
+
|
|
206
|
+
\* Only **one** of `masterId`, `labelId`, `releaseId`, or `artistId` can be used.
|
|
207
|
+
|
|
208
|
+
### Common Parameters (all searches)
|
|
209
|
+
|
|
210
|
+
| Field | Type | Description | Example | Default |
|
|
211
|
+
|-----------------------|------------------------------|------------------------------------------------|----------------------------------------|---------|
|
|
212
|
+
| `formats` | `Format[]` | List of formats. | `['Vinyl', 'CD']` | β |
|
|
213
|
+
| `formatDescriptions` | `FormatDescription[]` | List of format descriptions. | `['Limited Edition', 'Numbered']` | β |
|
|
214
|
+
| `years.min` / `max` | `number` | Year range. | `{ min: 1980, max: 1990 }` | β |
|
|
215
|
+
| `isMakeAnOfferOnly` | `boolean` | Only return listings that accept offers. | β | `false` |
|
|
216
|
+
| `limit` | `25 \| 50 \| 100 \| 250` | Number of results per page. | `100` | `25` |
|
|
217
|
+
| `page` | `number` | Page number (must be `< 401` to avoid 404). | `2` | `1` |
|
|
218
|
+
|
|
219
|
+
On success, a `SearchResult` interface is returned:
|
|
233
220
|
|
|
234
221
|
```ts
|
|
235
222
|
interface SearchResult {
|
|
236
223
|
items: Array<{
|
|
237
224
|
id: number
|
|
238
|
-
title:
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
225
|
+
title: string
|
|
226
|
+
artists: Array<{
|
|
227
|
+
id: number | null
|
|
228
|
+
name: string
|
|
229
|
+
url: string | null
|
|
230
|
+
}>
|
|
231
|
+
release: {
|
|
232
|
+
id: number
|
|
233
|
+
name: string
|
|
234
|
+
url: string
|
|
243
235
|
}
|
|
236
|
+
formats: Array<string>
|
|
237
|
+
labels: Array<{
|
|
238
|
+
id: number
|
|
239
|
+
name: string
|
|
240
|
+
url: string
|
|
241
|
+
}>
|
|
244
242
|
url: string
|
|
245
243
|
listedAt: Date | null
|
|
246
|
-
labels: Array<string>
|
|
247
244
|
catnos: Array<string>
|
|
248
|
-
imageUrl: string
|
|
249
|
-
description: string
|
|
245
|
+
imageUrl: string | null
|
|
246
|
+
description: string | null
|
|
250
247
|
isAcceptingOffer: boolean
|
|
251
248
|
isAvailable: boolean
|
|
252
249
|
condition: {
|
|
@@ -255,21 +252,21 @@ interface SearchResult {
|
|
|
255
252
|
short: string
|
|
256
253
|
}
|
|
257
254
|
sleeve: {
|
|
258
|
-
full: string
|
|
259
|
-
short: string
|
|
255
|
+
full: string | null
|
|
256
|
+
short: string | null
|
|
260
257
|
}
|
|
261
258
|
}
|
|
262
259
|
seller: {
|
|
263
260
|
name: string
|
|
264
261
|
url: string
|
|
265
|
-
score: string
|
|
266
|
-
notes: number
|
|
262
|
+
score: string | null
|
|
263
|
+
notes: number | null
|
|
267
264
|
}
|
|
268
265
|
price: {
|
|
269
266
|
/** @example '12.34 USD' */
|
|
270
|
-
base: `${number} ${CurrencyValues}`
|
|
267
|
+
base: `${number} ${CurrencyValues}`
|
|
271
268
|
/** @example '5.67 USD' */
|
|
272
|
-
shipping: `${number} ${CurrencyValues}` |
|
|
269
|
+
shipping: `${number} ${CurrencyValues}` | null
|
|
273
270
|
}
|
|
274
271
|
country: {
|
|
275
272
|
name: string
|
|
@@ -280,10 +277,6 @@ interface SearchResult {
|
|
|
280
277
|
have: number
|
|
281
278
|
want: number
|
|
282
279
|
}
|
|
283
|
-
release: {
|
|
284
|
-
id: number
|
|
285
|
-
url: string
|
|
286
|
-
}
|
|
287
280
|
}>
|
|
288
281
|
page: {
|
|
289
282
|
current: number
|
|
@@ -307,7 +300,7 @@ interface SearchResult {
|
|
|
307
300
|
|
|
308
301
|
## π Known Issues
|
|
309
302
|
|
|
310
|
-
- Requests hitting page >400 will result in a 404.
|
|
303
|
+
- Requests hitting page >400 will result in a 404 on the legacy API.
|
|
311
304
|
- Some search parameters might not be compatible with every type of queries.
|
|
312
305
|
- For other edge cases, feel free to open an [issue on GitHub](https://github.com/KirianCaumes/Discogs-Marketplace-API-NodeJS/issues).
|
|
313
306
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import search from './search.js';
|
|
2
|
-
import
|
|
3
|
-
import type SearchParams from './interfaces/search-params.interface.js';
|
|
2
|
+
import type { SearchParams } from './interfaces/search-params.interface.js';
|
|
4
3
|
import type SearchResult from './interfaces/search-result.interface.js';
|
|
5
4
|
/**
|
|
6
5
|
* Discogs Marketplace API, tools for interacting with the Discogs Marketplace.
|
|
@@ -8,6 +7,5 @@ import type SearchResult from './interfaces/search-result.interface.js';
|
|
|
8
7
|
*/
|
|
9
8
|
export declare const DiscogsMarketplace: {
|
|
10
9
|
search: typeof search;
|
|
11
|
-
getSearchParamsFromUrl: typeof getSearchParamsFromUrl;
|
|
12
10
|
};
|
|
13
11
|
export type { SearchParams, SearchResult };
|
package/dist/index.js
CHANGED
|
@@ -5,9 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.DiscogsMarketplace = void 0;
|
|
7
7
|
const search_1 = __importDefault(require("./search.js"));
|
|
8
|
-
const get_search_params_1 = __importDefault(require("./get-search-params.js"));
|
|
9
8
|
/**
|
|
10
9
|
* Discogs Marketplace API, tools for interacting with the Discogs Marketplace.
|
|
11
10
|
* @see {@link https://github.com/KirianCaumes/Discogs-Marketplace-API-NodeJS GitHub Repository}
|
|
12
11
|
*/
|
|
13
|
-
exports.DiscogsMarketplace = { search: search_1.default
|
|
12
|
+
exports.DiscogsMarketplace = { search: search_1.default };
|