discogs-marketplace-api-nodejs 1.12.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,184 +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. Reuse a Playwright `Page` instance for faster scraping
111
-
112
- ```ts
113
- const browser = await playwright.launch()
114
- const browserContext = await browser.newContext()
115
- const browserPage = await browserContext.newPage()
116
-
117
- const result = await DiscogsMarketplace.search({ searchType: 'q'}, browserPage)
118
-
119
- await browserContext.close()
120
- await browser.close()
121
- ```
122
-
123
- ### 2. 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
124
143
 
125
144
  ```ts
126
- const searchParams = DiscogsMarketplace.getSearchParamsFromUrl('https://www.discogs.com/fr/sell/list?sort=listed,desc&limit=250&artist_id=244819&page=2&genre=Rock')
127
- // {
128
- // searchType: 'artist_id',
129
- // searchValue: '244819',
130
- // genre: 'Rock',
131
- // sort: 'listed,desc',
132
- // limit: 250,
133
- // page: 2,
134
- // lang: 'fr',
135
- // }
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
+ })
136
152
  ```
137
153
 
138
154
  ## 🧩 API Reference
139
155
 
140
- The `DiscogsMarketplace.search` function accepts parameters defined by the following interface:
141
-
142
- ```ts
143
- interface SearchParams {
144
- /**
145
- * The type of element to search.
146
- * | Value | Description |
147
- * |-------------|--------------------------------|
148
- * | `q` | Basic query search |
149
- * | `master_id` | Search within a master release |
150
- * | `release_id`| Search within a release |
151
- * | `label_id` | Search within a label |
152
- * | `artist_id` | Search by artist |
153
- * | `user` | Search a user's wantlist |
154
- * @default 'q'
155
- */
156
- searchType: Search
157
- /**
158
- * The search value corresponding to the selected `searchType`.
159
- */
160
- searchValue?: string | number
161
- /**
162
- * Currency code for price filtering.
163
- * @example 'USD'
164
- */
165
- currency?: Currency
166
- /**
167
- * Genre filter.
168
- * @example 'Rock'
169
- */
170
- genre?: Genre
171
- /**
172
- * List of styles.
173
- * @example ['Death Metal', 'Heavy Metal']
174
- */
175
- style?: Array<Style>
176
- /**
177
- * List of formats.
178
- * @example ['Vinyl', 'CD']
179
- */
180
- format?: Array<Format>
181
- /**
182
- * List of format descriptions.
183
- * @example ['Limited Edition', 'Numbered']
184
- */
185
- formatDescription?: Array<FormatDescription>
186
- /**
187
- * List of media conditions.
188
- * @example ['Mint (M)', 'Very Good Plus (VG+)']
189
- */
190
- condition?: Array<Condition>
191
- /**
192
- * Release year.
193
- * Do not use together with `years`.
194
- */
195
- year?: number
196
- /**
197
- * Range of years.
198
- * Do not use together with `year`.
199
- */
200
- years?: {
201
- /** Minimum year */
202
- min: number
203
- /** Maximum year */
204
- max: number
205
- }
206
- /**
207
- * If true, only listings that accept offers are returned.
208
- * @default false
209
- */
210
- isMakeAnOfferOnly?: boolean
211
- /**
212
- * Expedition country filter (2-letter country code).
213
- * @example 'US'
214
- */
215
- from?: From
216
- /**
217
- * Seller's username filter.
218
- */
219
- seller?: string
220
- /**
221
- * Hours range for wantlist searches.
222
- * @example '0-24'
223
- */
224
- hoursRange?: HoursRange
225
- /**
226
- * Sort order for the results.
227
- * @default 'listed,desc'
228
- */
229
- sort?: Sort
230
- /**
231
- * Number of results to return per page.
232
- * Allowed values: 25, 50, 100, 250.
233
- * @default 25
234
- */
235
- limit?: Limit
236
- /**
237
- * Page number of results.
238
- * Must be less than 401 to avoid Discogs 404 errors.
239
- * @default 1
240
- */
241
- page?: number
242
- /**
243
- * Language code for Discogs interface.
244
- * @default 'en'
245
- */
246
- lang?: Lang
247
- }
248
- ```
249
-
250
- 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:
251
220
 
252
221
  ```ts
253
222
  interface SearchResult {
254
223
  items: Array<{
255
224
  id: number
256
- title: {
257
- original: string
258
- artist: string
259
- item: string
260
- 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
261
235
  }
236
+ formats: Array<string>
237
+ labels: Array<{
238
+ id: number
239
+ name: string
240
+ url: string
241
+ }>
262
242
  url: string
263
- labels: Array<string>
243
+ listedAt: Date | null
264
244
  catnos: Array<string>
265
- imageUrl: string
266
- description: string
245
+ imageUrl: string | null
246
+ description: string | null
267
247
  isAcceptingOffer: boolean
268
248
  isAvailable: boolean
269
249
  condition: {
@@ -272,21 +252,21 @@ interface SearchResult {
272
252
  short: string
273
253
  }
274
254
  sleeve: {
275
- full: string
276
- short: string
255
+ full: string | null
256
+ short: string | null
277
257
  }
278
258
  }
279
259
  seller: {
280
260
  name: string
281
261
  url: string
282
- score: string
283
- notes: number
262
+ score: string | null
263
+ notes: number | null
284
264
  }
285
265
  price: {
286
266
  /** @example '12.34 USD' */
287
- base: `${number} ${CurrencyValues}` | ''
267
+ base: `${number} ${CurrencyValues}`
288
268
  /** @example '5.67 USD' */
289
- shipping: `${number} ${CurrencyValues}` | ''
269
+ shipping: `${number} ${CurrencyValues}` | null
290
270
  }
291
271
  country: {
292
272
  name: string
@@ -297,10 +277,6 @@ interface SearchResult {
297
277
  have: number
298
278
  want: number
299
279
  }
300
- release: {
301
- id: number
302
- url: string
303
- }
304
280
  }>
305
281
  page: {
306
282
  current: number
@@ -324,8 +300,7 @@ interface SearchResult {
324
300
 
325
301
  ## 👉 Known Issues
326
302
 
327
- - Ensure all Playwright requirements are installed (see [Install system dependencies](https://playwright.dev/docs/browsers#install-system-dependencies)).
328
- - Requests hitting page >400 will result in a 404.
303
+ - Requests hitting page >400 will result in a 404 on the legacy API.
329
304
  - Some search parameters might not be compatible with every type of queries.
330
305
  - For other edge cases, feel free to open an [issue on GitHub](https://github.com/KirianCaumes/Discogs-Marketplace-API-NodeJS/issues).
331
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 };
@@ -0,0 +1,33 @@
1
+ export default interface ShopDetailsResultApi {
2
+ /** Data */
3
+ data?: {
4
+ /** Releases */
5
+ releases?: Array<{
6
+ /** InWantlistCount */
7
+ inWantlistCount?: number;
8
+ /** InCollectionCount */
9
+ inCollectionCount?: number;
10
+ /** Images */
11
+ images?: {
12
+ /** Edges */
13
+ edges?: Array<{
14
+ /** Node */
15
+ node?: {
16
+ /** Thumbnail */
17
+ thumbnail?: {
18
+ /** WebpUrl */
19
+ webpUrl?: string;
20
+ };
21
+ };
22
+ }>;
23
+ };
24
+ /** Ratings */
25
+ ratings?: {
26
+ /** AverageRating */
27
+ averageRating?: number;
28
+ };
29
+ /** DiscogsId */
30
+ discogsId?: number;
31
+ }>;
32
+ };
33
+ }
@@ -0,0 +1,111 @@
1
+ export default interface ShopResultApi {
2
+ /** Items */
3
+ items?: Array<{
4
+ /** ItemId */
5
+ itemId?: number;
6
+ /** AllowsOffers */
7
+ allowsOffers?: boolean;
8
+ /** Comments */
9
+ comments?: string;
10
+ /** ImageUrl */
11
+ imageUrl?: string;
12
+ /** InCart */
13
+ inCart?: boolean;
14
+ /** ListedDate */
15
+ listedDate?: string;
16
+ /** MediaCondition */
17
+ mediaCondition?: string;
18
+ /** PreviousPrice */
19
+ previousPrice?: string;
20
+ /** Price */
21
+ price?: {
22
+ /** Amount */
23
+ amount?: number;
24
+ /** AmountUsd */
25
+ amountUsd?: number;
26
+ /** CurrencyCode */
27
+ currencyCode?: string;
28
+ /** BuyerItemPrice */
29
+ buyerItemPrice?: string;
30
+ /** BuyerCurrencyCode */
31
+ buyerCurrencyCode?: string;
32
+ };
33
+ /** Release */
34
+ release?: {
35
+ /** ReleaseId */
36
+ releaseId?: number;
37
+ /** Artists */
38
+ artists?: Array<{
39
+ /** ArtistId */
40
+ artistId?: number;
41
+ /** Name */
42
+ name?: string;
43
+ }>;
44
+ /** Country */
45
+ country?: string;
46
+ /** FormatNames */
47
+ formatNames?: Array<string>;
48
+ /** Genres */
49
+ genres?: Array<{
50
+ /** GenreId */
51
+ genreId?: number;
52
+ /** Name */
53
+ name?: string;
54
+ }>;
55
+ /** Labels */
56
+ labels?: Array<{
57
+ /** LabelId */
58
+ labelId?: number;
59
+ /** Name */
60
+ name?: string;
61
+ }>;
62
+ /** MajorFormat */
63
+ majorFormat?: string;
64
+ /** Rating */
65
+ rating?: number;
66
+ /** Title */
67
+ title?: string;
68
+ /** Year */
69
+ year?: number;
70
+ };
71
+ /** Seller */
72
+ seller?: {
73
+ /** Uid */
74
+ uid?: number;
75
+ /** Name */
76
+ name?: string;
77
+ /** Rating */
78
+ rating?: number;
79
+ /** RatingCount */
80
+ ratingCount?: number;
81
+ /** ShipsFrom */
82
+ shipsFrom?: string;
83
+ /** MinBuyerRating */
84
+ minBuyerRating?: number;
85
+ /** IndependentSeller */
86
+ independentSeller?: boolean;
87
+ };
88
+ /** Shipping */
89
+ shipping?: {
90
+ /** ShippingPrice */
91
+ shippingPrice?: number;
92
+ /** BuyerShippingPrice */
93
+ buyerShippingPrice?: number;
94
+ /** FreeShippingMin */
95
+ freeShippingMin?: number;
96
+ };
97
+ /** SleeveCondition */
98
+ sleeveCondition?: string;
99
+ }>;
100
+ /** TotalCount */
101
+ totalCount?: number;
102
+ /** CompleteLookup */
103
+ completeLookup?: {
104
+ /** Artists */
105
+ artists?: string;
106
+ /** Sellers */
107
+ sellers?: string;
108
+ /** Releases */
109
+ releases?: Record<string, string>;
110
+ };
111
+ }