discogs-marketplace-api-nodejs 1.16.8 → 1.17.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.
Files changed (47) hide show
  1. package/README.MD +111 -151
  2. package/dist/data/country.data.d.ts +1 -1
  3. package/dist/data/style.data.d.ts +763 -0
  4. package/dist/data/style.data.js +765 -0
  5. package/dist/index.d.ts +7 -4
  6. package/dist/index.js +3 -2
  7. package/dist/interfaces/api/marketplace-search-result.api.interface.d.ts +148 -0
  8. package/dist/interfaces/api/{shop-details-result.api.interface.d.ts → releases-result.api.interface.d.ts} +4 -1
  9. package/dist/interfaces/api/wantlist-result.api.interface.d.ts +109 -0
  10. package/dist/interfaces/search-params.interface.d.ts +83 -163
  11. package/dist/interfaces/search-result.interface.d.ts +22 -20
  12. package/dist/scrapers/browser-context.d.ts +9 -0
  13. package/dist/scrapers/browser-context.js +28 -0
  14. package/dist/scrapers/marketplace.scraper.d.ts +10 -0
  15. package/dist/scrapers/marketplace.scraper.js +292 -0
  16. package/dist/search.d.ts +6 -9
  17. package/dist/search.js +10 -57
  18. package/dist/types/condition.type.d.ts +4 -0
  19. package/dist/types/currency.type.d.ts +1 -1
  20. package/dist/types/format-description.type.d.ts +1 -1
  21. package/dist/types/from.type.d.ts +1 -1
  22. package/dist/types/sort.type.d.ts +1 -1
  23. package/dist/types/style.type.d.ts +2 -1
  24. package/dist/wantlist.d.ts +28 -0
  25. package/dist/wantlist.js +101 -0
  26. package/package.json +16 -18
  27. package/dist/data/currency.data.d.ts +0 -36
  28. package/dist/data/currency.data.js +0 -35
  29. package/dist/interfaces/api/shop-result-error.api.interface.d.ts +0 -8
  30. package/dist/interfaces/api/shop-result.api.interface.d.ts +0 -111
  31. package/dist/scrapers/extractors/legacy.extractor.d.ts +0 -11
  32. package/dist/scrapers/extractors/legacy.extractor.js +0 -138
  33. package/dist/scrapers/legacy.scraper.d.ts +0 -13
  34. package/dist/scrapers/legacy.scraper.js +0 -75
  35. package/dist/scrapers/modern.scraper.d.ts +0 -13
  36. package/dist/scrapers/modern.scraper.js +0 -199
  37. package/dist/scrapers/wantlist.scraper.d.ts +0 -13
  38. package/dist/scrapers/wantlist.scraper.js +0 -66
  39. package/dist/types/api.type.d.ts +0 -4
  40. package/dist/types/api.type.js +0 -2
  41. package/dist/types/lang.type.d.ts +0 -4
  42. package/dist/types/lang.type.js +0 -2
  43. package/dist/types/limit.type.d.ts +0 -4
  44. package/dist/types/limit.type.js +0 -2
  45. /package/dist/interfaces/api/{shop-details-result.api.interface.js → marketplace-search-result.api.interface.js} +0 -0
  46. /package/dist/interfaces/api/{shop-result-error.api.interface.js → releases-result.api.interface.js} +0 -0
  47. /package/dist/interfaces/api/{shop-result.api.interface.js → wantlist-result.api.interface.js} +0 -0
package/dist/index.d.ts CHANGED
@@ -1,11 +1,14 @@
1
- import search from 'search';
2
- import type { SearchParams } from 'interfaces/search-params.interface';
3
- import type SearchResult from 'interfaces/search-result.interface';
1
+ import search from './search.js';
2
+ import getWantlistReleaseIds from './wantlist.js';
3
+ import type { SearchParams } from './interfaces/search-params.interface.js';
4
+ import type SearchResult from './interfaces/search-result.interface.js';
5
+ import type { WantlistOptions } from './wantlist.js';
4
6
  /**
5
7
  * Discogs Marketplace API, tools for interacting with the Discogs Marketplace.
6
8
  * @see {@link https://github.com/KirianCaumes/Discogs-Marketplace-API-NodeJS GitHub Repository}
7
9
  */
8
10
  export declare const DiscogsMarketplace: {
9
11
  search: typeof search;
12
+ getWantlistReleaseIds: typeof getWantlistReleaseIds;
10
13
  };
11
- export type { SearchParams, SearchResult };
14
+ export type { SearchParams, SearchResult, WantlistOptions };
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 wantlist_1 = __importDefault(require("./wantlist.js"));
8
9
  /**
9
10
  * Discogs Marketplace API, tools for interacting with the Discogs Marketplace.
10
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, getWantlistReleaseIds: wantlist_1.default };
@@ -0,0 +1,148 @@
1
+ /**
2
+ * Response of the `MarketplaceSearch` GraphQL query
3
+ */
4
+ export default interface MarketplaceSearchResultApi {
5
+ /** Data */
6
+ data?: {
7
+ /** MarketplaceSearch */
8
+ marketplaceSearch?: {
9
+ /** Edges */
10
+ edges?: Array<{
11
+ /** Node */
12
+ node?: {
13
+ /** Id */
14
+ id?: string;
15
+ /** OfferOk */
16
+ offerOk?: boolean;
17
+ /** MediaCondition */
18
+ mediaCondition?: string | null;
19
+ /** SleeveCondition */
20
+ sleeveCondition?: string | null;
21
+ /** PublicNotes */
22
+ publicNotes?: string | null;
23
+ /** ListedDate */
24
+ listedDate?: string | null;
25
+ /** ItemPhotos */
26
+ itemPhotos?: Array<{
27
+ /** Position */
28
+ position?: number;
29
+ /** Url */
30
+ url?: string;
31
+ }>;
32
+ /** Price */
33
+ price?: {
34
+ /** Amount */
35
+ amount?: number;
36
+ /** Currency */
37
+ currency?: string;
38
+ };
39
+ /** Shipping */
40
+ shipping?: {
41
+ /** Price */
42
+ price?: {
43
+ /** Amount */
44
+ amount?: number;
45
+ /** Currency */
46
+ currency?: string;
47
+ } | null;
48
+ } | null;
49
+ /** Availability */
50
+ availability?: {
51
+ /** IsAvailable */
52
+ isAvailable?: boolean;
53
+ };
54
+ /** Seller */
55
+ seller?: {
56
+ /** Username */
57
+ username?: string;
58
+ /** DiscogsId */
59
+ discogsId?: number;
60
+ };
61
+ /** SellerInfo */
62
+ sellerInfo?: {
63
+ /** Rating */
64
+ rating?: number | null;
65
+ /** RatingCount */
66
+ ratingCount?: number | null;
67
+ /** IndependentSeller */
68
+ independentSeller?: boolean;
69
+ /** ShipsFrom */
70
+ shipsFrom?: string | null;
71
+ };
72
+ /** Release */
73
+ release?: {
74
+ /** Title */
75
+ title?: string;
76
+ /** DiscogsId */
77
+ discogsId?: number;
78
+ /** Released, as a year or a date with zeros for the unknown parts */
79
+ released?: string | null;
80
+ /** Country */
81
+ country?: string | null;
82
+ /** Labels */
83
+ labels?: Array<{
84
+ /** CatalogNumber */
85
+ catalogNumber?: string | null;
86
+ /** LabelRole */
87
+ labelRole?: string;
88
+ /** Label */
89
+ label?: {
90
+ /** DiscogsId, missing on an unlinked label */
91
+ discogsId?: number;
92
+ /** Name */
93
+ name?: string;
94
+ };
95
+ }>;
96
+ /** FormatSummary */
97
+ formatSummary?: {
98
+ /** PrimaryFormat */
99
+ primaryFormat?: string | null;
100
+ /** RecordingTypes */
101
+ recordingTypes?: Array<string> | null;
102
+ /** Description */
103
+ description?: string | Array<string> | null;
104
+ } | null;
105
+ /** PrimaryArtists */
106
+ primaryArtists?: Array<{
107
+ /** DisplayName */
108
+ displayName?: string;
109
+ /** Artist */
110
+ artist?: {
111
+ /** DiscogsId */
112
+ discogsId?: number;
113
+ } | null;
114
+ }>;
115
+ /** Images */
116
+ images?: {
117
+ /** Edges */
118
+ edges?: Array<{
119
+ /** Node */
120
+ node?: {
121
+ /** Thumbnail */
122
+ thumbnail?: {
123
+ /** WebpUrl */
124
+ webpUrl?: string;
125
+ } | null;
126
+ };
127
+ }>;
128
+ } | null;
129
+ };
130
+ };
131
+ }>;
132
+ /** PageInfo */
133
+ pageInfo?: {
134
+ /** HasNextPage */
135
+ hasNextPage?: boolean;
136
+ /** EndCursor */
137
+ endCursor?: string | null;
138
+ };
139
+ /** TotalCount */
140
+ totalCount?: number;
141
+ };
142
+ };
143
+ /** Errors */
144
+ errors?: Array<{
145
+ /** Message */
146
+ message?: string;
147
+ }>;
148
+ }
@@ -1,4 +1,7 @@
1
- export default interface ShopDetailsResultApi {
1
+ /**
2
+ * Response of the `Releases` GraphQL query
3
+ */
4
+ export default interface ReleasesResultApi {
2
5
  /** Data */
3
6
  data?: {
4
7
  /** Releases */
@@ -0,0 +1,109 @@
1
+ /**
2
+ * Response of the wantlist of a user, from the Discogs API
3
+ * {@link https://www.discogs.com/developers#page:user-wantlist,header:user-wantlist-wantlist}
4
+ */
5
+ export default interface WantlistResultApi {
6
+ /** Message, on error */
7
+ message?: string;
8
+ /** Pagination */
9
+ pagination?: {
10
+ /** Page */
11
+ page?: number;
12
+ /** Pages */
13
+ pages?: number;
14
+ /** Per page */
15
+ per_page?: number;
16
+ /** Items */
17
+ items?: number;
18
+ /** Urls */
19
+ urls?: {
20
+ /** First */
21
+ first?: string;
22
+ /** Prev */
23
+ prev?: string;
24
+ /** Next */
25
+ next?: string;
26
+ /** Last */
27
+ last?: string;
28
+ };
29
+ };
30
+ /** Wants */
31
+ wants?: Array<{
32
+ /** Release ID */
33
+ id?: number;
34
+ /** Resource url */
35
+ resource_url?: string;
36
+ /** Rating */
37
+ rating?: number;
38
+ /** Notes */
39
+ notes?: string;
40
+ /** Date added */
41
+ date_added?: string;
42
+ /** Basic information */
43
+ basic_information?: {
44
+ /** Release ID */
45
+ id?: number;
46
+ /** Master ID */
47
+ master_id?: number;
48
+ /** Master url */
49
+ master_url?: string | null;
50
+ /** Resource url */
51
+ resource_url?: string;
52
+ /** Title */
53
+ title?: string;
54
+ /** Year */
55
+ year?: number;
56
+ /** Formats */
57
+ formats?: Array<{
58
+ /** Name */
59
+ name?: string;
60
+ /** Quantity */
61
+ qty?: string;
62
+ /** Descriptions */
63
+ descriptions?: Array<string>;
64
+ /** Text */
65
+ text?: string;
66
+ }>;
67
+ /** Artists */
68
+ artists?: Array<{
69
+ /** Name */
70
+ name?: string;
71
+ /** Artist name variation */
72
+ anv?: string;
73
+ /** Join */
74
+ join?: string;
75
+ /** Role */
76
+ role?: string;
77
+ /** Tracks */
78
+ tracks?: string;
79
+ /** ID */
80
+ id?: number;
81
+ /** Resource url */
82
+ resource_url?: string;
83
+ }>;
84
+ /** Labels */
85
+ labels?: Array<{
86
+ /** Name */
87
+ name?: string;
88
+ /** Catalog number */
89
+ catno?: string;
90
+ /** Entity type */
91
+ entity_type?: string;
92
+ /** Entity type name */
93
+ entity_type_name?: string;
94
+ /** ID */
95
+ id?: number;
96
+ /** Resource url */
97
+ resource_url?: string;
98
+ }>;
99
+ /** Thumbnail */
100
+ thumb?: string;
101
+ /** Cover image */
102
+ cover_image?: string;
103
+ /** Genres */
104
+ genres?: Array<string>;
105
+ /** Styles */
106
+ styles?: Array<string>;
107
+ };
108
+ }>;
109
+ }
@@ -1,183 +1,83 @@
1
- import type { Condition } from 'types/condition.type';
2
- import type { Currency } from 'types/currency.type';
3
- import type { FormatDescription } from 'types/format-description.type';
4
- import type { Format } from 'types/format.type';
5
- import type { From } from 'types/from.type';
6
- import type { Genre } from 'types/genre.type';
7
- import type { Lang } from 'types/lang.type';
8
- import type { Limit } from 'types/limit.type';
9
- import type { Api } from 'types/api.type';
10
- import type { Sort } from 'types/sort.type';
11
- import type { Style } from 'types/style.type';
12
- interface SearchParamsBase {
1
+ import type { Condition, SleeveCondition } from '../types/condition.type.js';
2
+ import type { Currency } from '../types/currency.type.js';
3
+ import type { FormatDescription } from '../types/format-description.type.js';
4
+ import type { Format } from '../types/format.type.js';
5
+ import type { From } from '../types/from.type.js';
6
+ import type { Genre } from '../types/genre.type.js';
7
+ import type { Sort } from '../types/sort.type.js';
8
+ import type { Style } from '../types/style.type.js';
9
+ /**
10
+ * Parameters used to search listings on the Discogs Marketplace.
11
+ */
12
+ export interface SearchParams {
13
13
  /**
14
- * List of formats.
15
- * @example ['Vinyl', 'CD']
14
+ * Query string to filter.
15
+ * @example 'nirvana nevermind'
16
16
  */
17
- formats?: Array<Format>;
17
+ query?: string;
18
18
  /**
19
- * List of format descriptions.
20
- * @example ['Limited Edition', 'Numbered']
19
+ * List of artist IDs.
21
20
  */
22
- formatDescriptions?: Array<FormatDescription>;
21
+ artistIds?: Array<number>;
23
22
  /**
24
- * Range of years.
23
+ * List of label IDs.
25
24
  */
26
- years?: {
27
- /** Minimum year */
28
- min: number;
29
- /** Maximum year */
30
- max: number;
31
- };
25
+ labelIds?: Array<number>;
32
26
  /**
33
- * If true, only listings that accept offers are returned.
34
- * @default false
27
+ * List of master release IDs.
35
28
  */
36
- isMakeAnOfferOnly?: boolean;
29
+ masterIds?: Array<number>;
37
30
  /**
38
- * Page number of results.
39
- * Must be less than 401 to avoid Discogs 404 errors.
40
- * @default 1
31
+ * List of release IDs, at most 2000. As for every other filter, an empty list means no filter.
32
+ * To search a user's wantlist, get its release IDs with `getWantlistReleaseIds`.
41
33
  */
42
- page?: number;
43
- }
44
- interface SearchParamsLegacyBase extends SearchParamsBase {
34
+ releaseIds?: Array<number>;
45
35
  /**
46
- * Api version to use.
36
+ * List of seller IDs.
47
37
  *
48
- * Choose `legacy` for the legacy API that scrapes HTML page. Required if you want to search on master or label.
49
- */
50
- api: Extract<Api, 'legacy'>;
51
- /**
52
- * Query string to filter.
53
- */
54
- query?: string;
55
- /**
56
- * Currency code for price filtering.
57
- * @example 'USD'
58
- */
59
- currency?: Currency;
60
- /**
61
- * Media conditions.
62
- * @example 'Mint (M)'
38
+ * You can easily find someone's ID via the Discogs API: https://api.discogs.com/users/{seller_name}
63
39
  */
64
- condition?: Condition;
40
+ sellerIds?: Array<number>;
65
41
  /**
66
- * Genre filter.
67
- * @example 'Rock'
42
+ * List of genres.
43
+ * @example ['Rock']
68
44
  */
69
- genre?: Genre;
45
+ genres?: Array<Genre>;
70
46
  /**
71
47
  * List of styles.
72
48
  * @example ['Death Metal', 'Heavy Metal']
73
49
  */
74
50
  styles?: Array<Style>;
75
51
  /**
76
- * Expedition country filter.
77
- * @example 'France'
78
- */
79
- from?: From;
80
- /**
81
- * Sort order for the results.
82
- * @default 'listed,desc'
83
- */
84
- sort?: Sort;
85
- /**
86
- * Number of results to return per page.
87
- * Allowed values: 25, 50, 100, 250.
88
- * @default 25
89
- */
90
- limit?: Limit;
91
- /**
92
- * Seller's name.
93
- */
94
- seller?: string;
95
- /**
96
- * User's name.
97
- */
98
- user?: string;
99
- /**
100
- * Language code for Discogs interface.
101
- * @default 'en'
102
- */
103
- lang?: Lang;
104
- }
105
- /**
106
- * Parameters used to search listings on the Discogs Marketplace via new old HTML Scraping.
107
- */
108
- export type SearchParamsLegacy = ({
109
- /** Master release ID. */
110
- masterId?: number;
111
- labelId?: never;
112
- releaseId?: never;
113
- artistId?: never;
114
- } | {
115
- masterId?: never;
116
- /** Label ID. */
117
- labelId?: number;
118
- releaseId?: never;
119
- artistId?: never;
120
- } | {
121
- masterId?: never;
122
- labelId?: never;
123
- /** Release ID. */
124
- releaseId?: number;
125
- artistId?: never;
126
- } | {
127
- masterId?: never;
128
- labelId?: never;
129
- releaseId?: never;
130
- /** Artist ID. */
131
- artistId?: number;
132
- }) & SearchParamsLegacyBase;
133
- interface SearchParamsModernBase extends SearchParamsBase {
134
- /**
135
- * Api version to use.
136
- *
137
- * Choose `v2` for the modern API that uses JSON (used in the `https://www.discogs.com/shop/mywants` page).
52
+ * List of formats.
53
+ * @example ['Vinyl', 'CD']
138
54
  */
139
- api: Extract<Api, 'v2'>;
55
+ formats?: Array<Format>;
140
56
  /**
141
- * List of currency codes for price filtering.
142
- * @example ['USD']
57
+ * List of format descriptions.
58
+ * @example ['Limited Edition', 'Numbered']
143
59
  */
144
- currencies?: Array<Currency>;
60
+ formatDescriptions?: Array<FormatDescription>;
145
61
  /**
146
62
  * List of media conditions.
147
63
  * @example ['Mint (M)', 'Very Good Plus (VG+)']
148
64
  */
149
- conditions?: Array<Condition>;
65
+ mediaConditions?: Array<Condition>;
150
66
  /**
151
- * List of genres.
152
- * @example ['Rock']
67
+ * List of sleeve conditions.
68
+ * @example ['Mint (M)', 'Generic']
153
69
  */
154
- genres?: Array<Genre>;
70
+ sleeveConditions?: Array<SleeveCondition>;
155
71
  /**
156
- * Expedition country filter.
157
- * @example 'France'
72
+ * List of expedition countries.
73
+ * @example ['FR']
158
74
  */
159
75
  from?: Array<From>;
160
76
  /**
161
- * Sort order for the results.
162
- * @default 'listed,desc'
163
- */
164
- sort?: Exclude<Sort, 'label,asc' | 'label,desc'>;
165
- /**
166
- * Number of results to return per page.
167
- * It must be less than or equal to 250.
168
- * @default 25
169
- */
170
- limit?: number;
171
- /**
172
- * List of artist IDs.
173
- */
174
- artistIds?: Array<number>;
175
- /**
176
- * List of seller IDs.
177
- *
178
- * You can easily find someone's ID via the Discogs API: https://api.discogs.com/users/{seller_name}
77
+ * List of currency codes for price filtering.
78
+ * @example ['USD']
179
79
  */
180
- sellerIds?: Array<number>;
80
+ currencies?: Array<Currency>;
181
81
  /**
182
82
  * Price range filter.
183
83
  */
@@ -188,10 +88,34 @@ interface SearchParamsModernBase extends SearchParamsBase {
188
88
  max: number;
189
89
  };
190
90
  /**
191
- * Minimum seller rating, from 0 to 100.
91
+ * Range of years.
92
+ */
93
+ years?: {
94
+ /** Minimum year */
95
+ min: number;
96
+ /** Maximum year */
97
+ max: number;
98
+ };
99
+ /**
100
+ * Minimum seller rating, from 0 to 100. Unrated sellers are still returned.
192
101
  * @default 0
193
102
  */
194
103
  sellerRatingMin?: number;
104
+ /**
105
+ * Minimum seller rating count.
106
+ * @default 0
107
+ */
108
+ sellerRatingCountMin?: number;
109
+ /**
110
+ * If true, only listings that accept offers are returned.
111
+ * @default false
112
+ */
113
+ isMakeAnOfferOnly?: boolean;
114
+ /**
115
+ * If true, only listings with photos of the item are returned.
116
+ * @default false
117
+ */
118
+ hasItemPhotos?: boolean;
195
119
  /**
196
120
  * Hide generic sleeves.
197
121
  * @default false
@@ -208,22 +132,18 @@ interface SearchParamsModernBase extends SearchParamsBase {
208
132
  */
209
133
  showUnavailable?: boolean;
210
134
  /**
211
- * Minimum seller rating count.
212
- * @default 0
135
+ * Sort order for the results.
136
+ * @default 'listed,desc'
213
137
  */
214
- sellerRatingCountMin?: number;
138
+ sort?: Sort;
139
+ /**
140
+ * Number of results to return per page.
141
+ * It must be less than or equal to 250.
142
+ * @default 25
143
+ */
144
+ limit?: number;
145
+ /**
146
+ * Cursor of the page to get, as returned by `nextCursor` in the previous result.
147
+ */
148
+ after?: string;
215
149
  }
216
- /**
217
- * Parameters used to search listings on the Discogs Marketplace via new new modern API.
218
- */
219
- export type SearchParamsModern = ({
220
- /** User's wantlist name. */
221
- wantlist?: string;
222
- releaseIds?: never;
223
- } | {
224
- wantlist?: never;
225
- /** List of release IDs. */
226
- releaseIds?: Array<number>;
227
- }) & SearchParamsModernBase;
228
- export type SearchParams = SearchParamsLegacy | SearchParamsModern;
229
- export {};