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 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
- searchType: 'artist_id',
21
- searchValue: 244819,
22
- genre: 'Rock',
23
- sort: 'price,asc',
24
- limit: 50,
25
- page: 1,
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
- searchType: 'artist_id',
39
- searchValue: 244819,
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/sell/mywants?limit=50&user=Kirian_&sort=price,asc
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
- searchType: 'user',
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
- searchType: 'release_id',
66
- searchValue: '767931',
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
- searchType: 'q',
77
- searchValue: 'in flames',
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
- ## πŸ’ Additional Features
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
- const searchParams = DiscogsMarketplace.getSearchParamsFromUrl('https://www.discogs.com/fr/sell/list?sort=listed,desc&limit=250&artist_id=244819&page=2&genre=Rock')
114
- // {
115
- // searchType: 'artist_id',
116
- // searchValue: '244819',
117
- // genre: 'Rock',
118
- // sort: 'listed,desc',
119
- // limit: 250,
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
- The `DiscogsMarketplace.search` function accepts parameters defined by the following interface:
128
-
129
- ```ts
130
- interface SearchParams {
131
- /**
132
- * The type of element to search.
133
- * | Value | Description |
134
- * |-------------|--------------------------------|
135
- * | `q` | Basic query search |
136
- * | `master_id` | Search within a master release |
137
- * | `release_id`| Search within a release |
138
- * | `label_id` | Search within a label |
139
- * | `artist_id` | Search by artist |
140
- * | `user` | Search a user's wantlist |
141
- * @default 'q'
142
- */
143
- searchType: Search
144
- /**
145
- * The search value corresponding to the selected `searchType`.
146
- */
147
- searchValue?: string | number
148
- /**
149
- * Currency code for price filtering.
150
- * @example 'USD'
151
- */
152
- currency?: Currency
153
- /**
154
- * Genre filter.
155
- * @example 'Rock'
156
- */
157
- genre?: Genre
158
- /**
159
- * List of styles.
160
- * @example ['Death Metal', 'Heavy Metal']
161
- */
162
- style?: Array<Style>
163
- /**
164
- * List of formats.
165
- * @example ['Vinyl', 'CD']
166
- */
167
- format?: Array<Format>
168
- /**
169
- * List of format descriptions.
170
- * @example ['Limited Edition', 'Numbered']
171
- */
172
- formatDescription?: Array<FormatDescription>
173
- /**
174
- * List of media conditions.
175
- * @example ['Mint (M)', 'Very Good Plus (VG+)']
176
- */
177
- condition?: Array<Condition>
178
- /**
179
- * Release year.
180
- * Do not use together with `years`.
181
- */
182
- year?: number
183
- /**
184
- * Range of years.
185
- * Do not use together with `year`.
186
- */
187
- years?: {
188
- /** Minimum year */
189
- min: number
190
- /** Maximum year */
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
- original: string
240
- artist: string
241
- item: string
242
- formats: Array<string>
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 getSearchParamsFromUrl from './get-search-params.js';
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, getSearchParamsFromUrl: get_search_params_1.default };
12
+ exports.DiscogsMarketplace = { search: search_1.default };