discogs-marketplace-api-nodejs 1.11.0 → 1.13.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 +108 -107
- package/dist/get-search-params.d.ts +10 -0
- package/dist/get-search-params.js +119 -0
- package/dist/index.d.ts +7 -5
- package/dist/index.js +5 -4
- package/dist/interfaces/api/shop-details-result.api.interface.d.ts +33 -0
- package/dist/interfaces/api/shop-details-result.api.interface.js +2 -0
- package/dist/interfaces/api/shop-result.api.interface.d.ts +111 -0
- package/dist/interfaces/api/shop-result.api.interface.js +2 -0
- package/dist/interfaces/search-params.interface.d.ts +52 -45
- package/dist/interfaces/search-result.interface.d.ts +50 -48
- package/dist/scrapers/legacy.scraper.d.ts +11 -0
- package/dist/{scrape.js → scrapers/legacy.scraper.js} +115 -40
- package/dist/scrapers/modern.scraper.d.ts +14 -0
- package/dist/scrapers/modern.scraper.js +151 -0
- package/dist/scrapers/wantlist.scraper.d.ts +11 -0
- package/dist/scrapers/wantlist.scraper.js +57 -0
- package/dist/search.d.ts +6 -9
- package/dist/search.js +20 -136
- package/dist/types/sort.type.d.ts +4 -1
- package/package.json +18 -18
- package/dist/scrape.d.ts +0 -10
package/README.MD
CHANGED
|
@@ -1,227 +1,235 @@
|
|
|
1
|
-
# Discogs Marketplace API NodeJS
|
|
1
|
+
# 🎧 Discogs Marketplace API NodeJS
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/discogs-marketplace-api-nodejs)  [](https://github.com/KirianCaumes/Discogs-Marketplace-API-NodeJS/blob/master/LICENSE) [](https://www.paypal.me/KirianCaumes)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
A modern TypeScript/Node.js client for scraping and retrieving Discogs Marketplace listings — flexible, type safe, and easy to use. 💿
|
|
6
|
+
> 💪 No Discogs API token required — this client scrapes public Marketplace data.
|
|
6
7
|
|
|
7
|
-
##
|
|
8
|
-
|
|
9
|
-
Run the following command in your project:
|
|
8
|
+
## 🚀 Installation
|
|
10
9
|
|
|
11
10
|
```sh
|
|
12
|
-
npm
|
|
11
|
+
npm install discogs-marketplace-api-nodejs
|
|
13
12
|
```
|
|
14
13
|
|
|
15
|
-
##
|
|
16
|
-
|
|
17
|
-
Import `DiscogsMarketplace` into your project:
|
|
14
|
+
## ⚡ Quick Start
|
|
18
15
|
|
|
19
|
-
```
|
|
16
|
+
```ts
|
|
20
17
|
import { DiscogsMarketplace } from 'discogs-marketplace-api-nodejs'
|
|
18
|
+
|
|
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,
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
console.log(result.items)
|
|
21
29
|
```
|
|
22
30
|
|
|
23
|
-
##
|
|
31
|
+
## 📚 Usage Examples
|
|
24
32
|
|
|
25
|
-
|
|
33
|
+
### 1. Get 250 latest listings by a specific artist in the Rock genre, page 2
|
|
26
34
|
|
|
27
|
-
```
|
|
35
|
+
```ts
|
|
28
36
|
// https://www.discogs.com/sell/list?sort=listed,desc&limit=250&artist_id=244819&page=2&genre=Rock
|
|
29
37
|
const result = await DiscogsMarketplace.search({
|
|
30
|
-
limit: 250,
|
|
31
|
-
page: 2,
|
|
32
|
-
genre: 'Rock',
|
|
33
|
-
sort: 'Listed Newest',
|
|
34
38
|
searchType: 'artist_id',
|
|
35
39
|
searchValue: 244819,
|
|
40
|
+
genre: 'Rock',
|
|
41
|
+
sort: 'listed,desc',
|
|
42
|
+
limit: 250,
|
|
43
|
+
page: 2,
|
|
36
44
|
})
|
|
37
45
|
```
|
|
38
46
|
|
|
39
|
-
|
|
47
|
+
### 2. Get listings of a user's wantlist, sorted by price, limit 50
|
|
40
48
|
|
|
41
|
-
```
|
|
49
|
+
```ts
|
|
42
50
|
// https://www.discogs.com/sell/mywants?limit=50&user=Kirian_&sort=price,asc
|
|
43
51
|
const result = await DiscogsMarketplace.search({
|
|
44
52
|
limit: 50,
|
|
45
|
-
|
|
46
|
-
sort: 'Price Lowest',
|
|
53
|
+
sort: 'price,asc',
|
|
47
54
|
searchType: 'user',
|
|
48
55
|
searchValue: 'Kirian_',
|
|
49
56
|
})
|
|
50
57
|
```
|
|
51
58
|
|
|
52
|
-
|
|
59
|
+
### 3. Get listings on a release, sorted by seller name
|
|
53
60
|
|
|
54
|
-
```
|
|
55
|
-
// https://www.discogs.com/sell/
|
|
61
|
+
```ts
|
|
62
|
+
// https://www.discogs.com/sell/list?release_id=767931&sort=seller,asc&limit=25
|
|
63
|
+
// https://www.discogs.com/sell/release/767931?sort=seller,asc&limit=25
|
|
56
64
|
const result = await DiscogsMarketplace.search({
|
|
57
|
-
sort: 'Seller A-Z',
|
|
58
|
-
page: 1,
|
|
59
65
|
searchType: 'release_id',
|
|
60
66
|
searchValue: '767931',
|
|
67
|
+
sort: 'seller,asc',
|
|
61
68
|
})
|
|
62
69
|
```
|
|
63
70
|
|
|
64
|
-
|
|
71
|
+
### 4. Get listings by a general search query (e.g., "in flames"), sorted by newest listings, limit 100
|
|
65
72
|
|
|
66
|
-
```
|
|
73
|
+
```ts
|
|
67
74
|
// https://www.discogs.com/sell/list?sort=listed,desc&limit=100&q=in+flames&page=1
|
|
68
75
|
const result = await DiscogsMarketplace.search({
|
|
69
|
-
limit: 100,
|
|
70
|
-
page: 1,
|
|
71
|
-
sort: 'Listed Newest',
|
|
72
76
|
searchType: 'q',
|
|
73
77
|
searchValue: 'in flames',
|
|
78
|
+
sort: 'listed,desc',
|
|
79
|
+
limit: 100,
|
|
74
80
|
})
|
|
75
81
|
```
|
|
76
82
|
|
|
77
|
-
|
|
83
|
+
### 5. Get newest listings on a seller inventory
|
|
78
84
|
|
|
79
|
-
```
|
|
80
|
-
// https://www.discogs.com/
|
|
85
|
+
```ts
|
|
86
|
+
// https://www.discogs.com/sell/list?sort=listed,desc&seller=Kirian_
|
|
87
|
+
// https://www.discogs.com/seller/Kirian_/profile?sort=listed,desc
|
|
81
88
|
const result = await DiscogsMarketplace.search({
|
|
82
|
-
sort: '
|
|
83
|
-
page: 1,
|
|
89
|
+
sort: 'listed,desc',
|
|
84
90
|
searchType: 'q',
|
|
85
|
-
searchValue: '',
|
|
86
91
|
seller: 'Kirian_',
|
|
87
92
|
})
|
|
88
93
|
```
|
|
89
94
|
|
|
90
|
-
|
|
95
|
+
### 6. Get newest listings of a user's wantlist, on a seller inventory
|
|
91
96
|
|
|
92
|
-
```
|
|
93
|
-
// https://www.discogs.com/
|
|
97
|
+
```ts
|
|
98
|
+
// https://www.discogs.com/sell/mywants?sort=listed,desc&seller=Kirian_&user=Kirian_
|
|
99
|
+
// https://www.discogs.com/seller/Kirian_/mywants?sort=listed,desc&user=Kirian_
|
|
94
100
|
const result = await DiscogsMarketplace.search({
|
|
95
|
-
sort: '
|
|
96
|
-
page: 1,
|
|
101
|
+
sort: 'listed,desc',
|
|
97
102
|
searchType: 'user',
|
|
98
103
|
searchValue: 'Kirian_',
|
|
99
104
|
seller: 'Kirian_',
|
|
100
105
|
})
|
|
101
106
|
```
|
|
102
107
|
|
|
103
|
-
|
|
108
|
+
## 💁 Additional Features
|
|
104
109
|
|
|
105
|
-
|
|
106
|
-
const browser = await playwright.launch()
|
|
107
|
-
const browserContext = await browser.newContext()
|
|
108
|
-
const browserPage = await browserContext.newPage()
|
|
110
|
+
### 1. Extract correct parameters from URL
|
|
109
111
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
112
|
+
```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
|
+
// }
|
|
114
123
|
```
|
|
115
124
|
|
|
116
|
-
##
|
|
125
|
+
## 🧩 API Reference
|
|
117
126
|
|
|
118
|
-
|
|
127
|
+
The `DiscogsMarketplace.search` function accepts parameters defined by the following interface:
|
|
119
128
|
|
|
120
129
|
```ts
|
|
121
130
|
interface SearchParams {
|
|
122
131
|
/**
|
|
123
|
-
*
|
|
124
|
-
* |
|
|
125
|
-
*
|
|
126
|
-
* | q
|
|
127
|
-
* | master_id
|
|
128
|
-
* | release_id
|
|
129
|
-
* | label_id
|
|
130
|
-
* | artist_id
|
|
131
|
-
* | user
|
|
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 |
|
|
132
141
|
* @default 'q'
|
|
133
142
|
*/
|
|
134
143
|
searchType: Search
|
|
135
144
|
/**
|
|
136
|
-
*
|
|
145
|
+
* The search value corresponding to the selected `searchType`.
|
|
137
146
|
*/
|
|
138
147
|
searchValue?: string | number
|
|
139
148
|
/**
|
|
140
|
-
* Currency
|
|
149
|
+
* Currency code for price filtering.
|
|
141
150
|
* @example 'USD'
|
|
142
151
|
*/
|
|
143
152
|
currency?: Currency
|
|
144
153
|
/**
|
|
145
|
-
* Genre
|
|
154
|
+
* Genre filter.
|
|
146
155
|
* @example 'Rock'
|
|
147
156
|
*/
|
|
148
157
|
genre?: Genre
|
|
149
158
|
/**
|
|
150
|
-
*
|
|
159
|
+
* List of styles.
|
|
151
160
|
* @example ['Death Metal', 'Heavy Metal']
|
|
152
161
|
*/
|
|
153
162
|
style?: Array<Style>
|
|
154
163
|
/**
|
|
155
|
-
*
|
|
164
|
+
* List of formats.
|
|
156
165
|
* @example ['Vinyl', 'CD']
|
|
157
166
|
*/
|
|
158
167
|
format?: Array<Format>
|
|
159
168
|
/**
|
|
160
|
-
*
|
|
169
|
+
* List of format descriptions.
|
|
161
170
|
* @example ['Limited Edition', 'Numbered']
|
|
162
171
|
*/
|
|
163
172
|
formatDescription?: Array<FormatDescription>
|
|
164
173
|
/**
|
|
165
|
-
*
|
|
174
|
+
* List of media conditions.
|
|
166
175
|
* @example ['Mint (M)', 'Very Good Plus (VG+)']
|
|
167
176
|
*/
|
|
168
177
|
condition?: Array<Condition>
|
|
169
178
|
/**
|
|
170
|
-
*
|
|
179
|
+
* Release year.
|
|
180
|
+
* Do not use together with `years`.
|
|
171
181
|
*/
|
|
172
182
|
year?: number
|
|
173
183
|
/**
|
|
174
|
-
*
|
|
184
|
+
* Range of years.
|
|
185
|
+
* Do not use together with `year`.
|
|
175
186
|
*/
|
|
176
187
|
years?: {
|
|
177
|
-
/**
|
|
188
|
+
/** Minimum year */
|
|
178
189
|
min: number
|
|
179
|
-
/**
|
|
190
|
+
/** Maximum year */
|
|
180
191
|
max: number
|
|
181
192
|
}
|
|
182
193
|
/**
|
|
183
|
-
*
|
|
184
|
-
* @default false
|
|
185
|
-
*/
|
|
186
|
-
isAudioSample?: boolean
|
|
187
|
-
/**
|
|
188
|
-
* Is make an offer only ?
|
|
194
|
+
* If true, only listings that accept offers are returned.
|
|
189
195
|
* @default false
|
|
190
196
|
*/
|
|
191
197
|
isMakeAnOfferOnly?: boolean
|
|
192
198
|
/**
|
|
193
|
-
* Expedition country
|
|
199
|
+
* Expedition country filter (2-letter country code).
|
|
194
200
|
* @example 'US'
|
|
195
201
|
*/
|
|
196
202
|
from?: From
|
|
197
203
|
/**
|
|
198
|
-
* Seller
|
|
204
|
+
* Seller's username filter.
|
|
199
205
|
*/
|
|
200
206
|
seller?: string
|
|
201
207
|
/**
|
|
202
|
-
* Sort
|
|
203
|
-
* @default '
|
|
208
|
+
* Sort order for the results.
|
|
209
|
+
* @default 'listed,desc'
|
|
204
210
|
*/
|
|
205
211
|
sort?: Sort
|
|
206
212
|
/**
|
|
207
|
-
*
|
|
213
|
+
* Number of results to return per page.
|
|
214
|
+
* Allowed values: 25, 50, 100, 250.
|
|
208
215
|
* @default 25
|
|
209
216
|
*/
|
|
210
217
|
limit?: Limit
|
|
211
218
|
/**
|
|
212
|
-
* Page
|
|
219
|
+
* Page number of results.
|
|
220
|
+
* Must be less than 401 to avoid Discogs 404 errors.
|
|
213
221
|
* @default 1
|
|
214
222
|
*/
|
|
215
223
|
page?: number
|
|
216
224
|
/**
|
|
217
|
-
*
|
|
225
|
+
* Language code for Discogs interface.
|
|
218
226
|
* @default 'en'
|
|
219
227
|
*/
|
|
220
228
|
lang?: Lang
|
|
221
229
|
}
|
|
222
230
|
```
|
|
223
231
|
|
|
224
|
-
|
|
232
|
+
On success, it returns a result matching this interface:
|
|
225
233
|
|
|
226
234
|
```ts
|
|
227
235
|
interface SearchResult {
|
|
@@ -234,6 +242,7 @@ interface SearchResult {
|
|
|
234
242
|
formats: Array<string>
|
|
235
243
|
}
|
|
236
244
|
url: string
|
|
245
|
+
listedAt: Date | null
|
|
237
246
|
labels: Array<string>
|
|
238
247
|
catnos: Array<string>
|
|
239
248
|
imageUrl: string
|
|
@@ -288,28 +297,20 @@ interface SearchResult {
|
|
|
288
297
|
}
|
|
289
298
|
```
|
|
290
299
|
|
|
291
|
-
##
|
|
300
|
+
## 🛠️ Development & Contribution
|
|
292
301
|
|
|
293
|
-
|
|
302
|
+
- Clone the repo and use the included devcontainer/VSCode setup.
|
|
303
|
+
- Run: `npm install`
|
|
304
|
+
- Add your contribution.
|
|
305
|
+
- Use `npm test` to run unit tests.
|
|
306
|
+
- Open a pull request with your new additions! 🎉
|
|
294
307
|
|
|
295
|
-
|
|
308
|
+
## 👉 Known Issues
|
|
296
309
|
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
You can open a pull request with your new additions.
|
|
302
|
-
|
|
303
|
-
## 🐛 Known issues/problems
|
|
304
|
-
|
|
305
|
-
### Playwright
|
|
306
|
-
|
|
307
|
-
Install system dependencies:
|
|
308
|
-
|
|
309
|
-
```sh
|
|
310
|
-
sudo npx playwright install-deps chromium
|
|
311
|
-
```
|
|
310
|
+
- Requests hitting page >400 will result in a 404.
|
|
311
|
+
- Some search parameters might not be compatible with every type of queries.
|
|
312
|
+
- For other edge cases, feel free to open an [issue on GitHub](https://github.com/KirianCaumes/Discogs-Marketplace-API-NodeJS/issues).
|
|
312
313
|
|
|
313
|
-
|
|
314
|
+
## 📃 License
|
|
314
315
|
|
|
315
|
-
|
|
316
|
+
Licensed under [MIT](https://github.com/KirianCaumes/Discogs-Marketplace-API-NodeJS/blob/master/LICENSE).
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type SearchParams from './interfaces/search-params.interface.js';
|
|
2
|
+
/**
|
|
3
|
+
* Get search parameters from a Discogs Marketplace URL
|
|
4
|
+
* @param url Discogs Marketplace URL
|
|
5
|
+
* @returns Search parameters
|
|
6
|
+
* @example
|
|
7
|
+
* const searchParams = getSearchParamsFromUrl('https://www.discogs.com/sell/list?sort=listed,desc&limit=250&artist_id=244819&page=2&genre=Rock')
|
|
8
|
+
* // { searchType: 'artist_id', searchValue: '244819', genre: 'Rock', sort: 'listed,desc', limit: 250, page: 2 }
|
|
9
|
+
*/
|
|
10
|
+
export default function getSearchParamsFromUrl(url: string): SearchParams;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable no-restricted-syntax */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.default = getSearchParamsFromUrl;
|
|
5
|
+
/**
|
|
6
|
+
* Safely parse an integer from a string
|
|
7
|
+
* @param value String to parse
|
|
8
|
+
* @returns Parsed integer or undefined if parsing fails
|
|
9
|
+
*/
|
|
10
|
+
const safeParseInt = (value) => {
|
|
11
|
+
const parsed = parseInt(value ?? '', 10);
|
|
12
|
+
return isNaN(parsed) ? undefined : parsed;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Get search parameters from a Discogs Marketplace URL
|
|
16
|
+
* @param url Discogs Marketplace URL
|
|
17
|
+
* @returns Search parameters
|
|
18
|
+
* @example
|
|
19
|
+
* const searchParams = getSearchParamsFromUrl('https://www.discogs.com/sell/list?sort=listed,desc&limit=250&artist_id=244819&page=2&genre=Rock')
|
|
20
|
+
* // { searchType: 'artist_id', searchValue: '244819', genre: 'Rock', sort: 'listed,desc', limit: 250, page: 2 }
|
|
21
|
+
*/
|
|
22
|
+
function getSearchParamsFromUrl(url) {
|
|
23
|
+
const { searchParams: urlSearchParams, pathname, host } = new URL(url);
|
|
24
|
+
if (!host.includes('discogs.com')) {
|
|
25
|
+
throw new Error(`Invalid host: ${host}. Expected 'www.discogs.com' or 'discogs.com'.`);
|
|
26
|
+
}
|
|
27
|
+
const searchParams = {
|
|
28
|
+
searchType: 'q', // Default search type
|
|
29
|
+
};
|
|
30
|
+
// Retrieve the search type and value
|
|
31
|
+
const searchType = ['q', 'master_id', 'release_id', 'label_id', 'artist_id', 'user'].find(type => urlSearchParams.has(type));
|
|
32
|
+
if (searchType) {
|
|
33
|
+
searchParams.searchType = searchType;
|
|
34
|
+
const searchValue = urlSearchParams.get(searchType);
|
|
35
|
+
if (searchValue) {
|
|
36
|
+
searchParams.searchValue = searchValue;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
// Retrieve basic search values
|
|
40
|
+
for (const key of ['currency', 'genre', 'ships_from', 'seller', 'sort']) {
|
|
41
|
+
const value = urlSearchParams.get(key);
|
|
42
|
+
if (value) {
|
|
43
|
+
switch (key) {
|
|
44
|
+
case 'ships_from':
|
|
45
|
+
searchParams.from = value;
|
|
46
|
+
break;
|
|
47
|
+
default:
|
|
48
|
+
searchParams[key] = value;
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
// Retrieve number search values
|
|
54
|
+
for (const key of ['limit', 'page']) {
|
|
55
|
+
const value = safeParseInt(urlSearchParams.get(key));
|
|
56
|
+
if (value) {
|
|
57
|
+
switch (key) {
|
|
58
|
+
case 'limit':
|
|
59
|
+
searchParams.limit = value;
|
|
60
|
+
break;
|
|
61
|
+
default:
|
|
62
|
+
searchParams[key] = value;
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
// Retrieve array search values
|
|
68
|
+
for (const key of ['style', 'format', 'format_desc', 'condition']) {
|
|
69
|
+
const values = urlSearchParams.getAll(key);
|
|
70
|
+
if (values.length) {
|
|
71
|
+
switch (key) {
|
|
72
|
+
case 'format_desc':
|
|
73
|
+
searchParams.formatDescription = values;
|
|
74
|
+
break;
|
|
75
|
+
default:
|
|
76
|
+
searchParams[key] = values;
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
// Check if search is on offers only
|
|
82
|
+
if (urlSearchParams.get('offers') === '1') {
|
|
83
|
+
searchParams.isMakeAnOfferOnly = true;
|
|
84
|
+
}
|
|
85
|
+
// Handle year and years
|
|
86
|
+
const year = safeParseInt(urlSearchParams.get('year'));
|
|
87
|
+
const year1 = safeParseInt(urlSearchParams.get('year1'));
|
|
88
|
+
const year2 = safeParseInt(urlSearchParams.get('year2'));
|
|
89
|
+
if (year) {
|
|
90
|
+
searchParams.year = year;
|
|
91
|
+
}
|
|
92
|
+
else if (year1 && year2) {
|
|
93
|
+
searchParams.years = { min: year1, max: year2 };
|
|
94
|
+
}
|
|
95
|
+
// Retrieve the language from the URL path
|
|
96
|
+
const pathSegments = pathname.split('/').filter(x => x);
|
|
97
|
+
if (/^[a-z]{2}$/i.test(pathSegments[0] ?? '')) {
|
|
98
|
+
searchParams.lang = pathSegments[0]?.toLowerCase();
|
|
99
|
+
}
|
|
100
|
+
// Handle specific case for release ID in the URL path
|
|
101
|
+
const releaseIdMatch = /\/sell\/release\/(\d+)/.exec(url);
|
|
102
|
+
if (releaseIdMatch?.[1]) {
|
|
103
|
+
searchParams.searchType = 'release_id';
|
|
104
|
+
searchParams.searchValue = releaseIdMatch[1];
|
|
105
|
+
}
|
|
106
|
+
// Handle specific case for seller profile in the URL path
|
|
107
|
+
const sellerProfileMatch = /\/seller\/([^/]+)\/profile/.exec(url);
|
|
108
|
+
if (sellerProfileMatch?.[1]) {
|
|
109
|
+
searchParams.seller = sellerProfileMatch[1];
|
|
110
|
+
}
|
|
111
|
+
// Handle specific case for seller name on wantlist in the URL path
|
|
112
|
+
const sellerMyWantsMatch = /\/seller\/([^/]+)\/mywants/.exec(url);
|
|
113
|
+
if (sellerMyWantsMatch?.[1]) {
|
|
114
|
+
searchParams.searchType = 'user';
|
|
115
|
+
searchParams.searchValue = urlSearchParams.get('user') ?? '';
|
|
116
|
+
searchParams.seller = sellerMyWantsMatch[1];
|
|
117
|
+
}
|
|
118
|
+
return searchParams;
|
|
119
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import search from './search';
|
|
2
|
-
import
|
|
3
|
-
import type
|
|
1
|
+
import search from './search.js';
|
|
2
|
+
import getSearchParamsFromUrl from './get-search-params.js';
|
|
3
|
+
import type SearchParams from './interfaces/search-params.interface.js';
|
|
4
|
+
import type SearchResult from './interfaces/search-result.interface.js';
|
|
4
5
|
/**
|
|
5
|
-
* Discogs Marketplace API
|
|
6
|
-
* @see https://github.com/KirianCaumes/Discogs-Marketplace-API-NodeJS
|
|
6
|
+
* Discogs Marketplace API, tools for interacting with the Discogs Marketplace.
|
|
7
|
+
* @see {@link https://github.com/KirianCaumes/Discogs-Marketplace-API-NodeJS GitHub Repository}
|
|
7
8
|
*/
|
|
8
9
|
export declare const DiscogsMarketplace: {
|
|
9
10
|
search: typeof search;
|
|
11
|
+
getSearchParamsFromUrl: typeof getSearchParamsFromUrl;
|
|
10
12
|
};
|
|
11
13
|
export type { SearchParams, SearchResult };
|
package/dist/index.js
CHANGED
|
@@ -4,9 +4,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.DiscogsMarketplace = void 0;
|
|
7
|
-
const search_1 = __importDefault(require("./search"));
|
|
7
|
+
const search_1 = __importDefault(require("./search.js"));
|
|
8
|
+
const get_search_params_1 = __importDefault(require("./get-search-params.js"));
|
|
8
9
|
/**
|
|
9
|
-
* Discogs Marketplace API
|
|
10
|
-
* @see https://github.com/KirianCaumes/Discogs-Marketplace-API-NodeJS
|
|
10
|
+
* Discogs Marketplace API, tools for interacting with the Discogs Marketplace.
|
|
11
|
+
* @see {@link https://github.com/KirianCaumes/Discogs-Marketplace-API-NodeJS GitHub Repository}
|
|
11
12
|
*/
|
|
12
|
-
exports.DiscogsMarketplace = { search: search_1.default };
|
|
13
|
+
exports.DiscogsMarketplace = { search: search_1.default, getSearchParamsFromUrl: get_search_params_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
|
+
}
|