1.0.0 • Published 5 years ago
discogs-markeplace-api-nodejs v1.0.0
Discogs Marketplace API
Another (better ?) NodeJs library to fetch data from Discog's marketplace
Usage
Install
npm install discogs-marketplace-api
Import and search
In Typescript
import DiscogsMarketplace, { EType, IOutputSuccess, IOutputError } from 'discogs-markeplace-api-test'
DiscogsMarketplace.search({ searchType: EType.ARTIST, searchValue: 244819 })
.then((res: IOutputSuccess) => {
console.log(res)
})
.catch((err: IOutputError) => {
console.error(err)
})
In plain Javascript
const DiscogsMarketplace = require('discogs-markeplace-api-test').default
const { EType } = require('discogs-markeplace-api-test')
DiscogsMarketplace.search({ searchType: EType.ARTIST, searchValue: 244819 })
.then(res => {
console.log(res)
})
.catch(err => {
console.error(err)
})
Data format
Data that must provided to the search function must looks like this (other interfaces can be found in "lib/enum" ) :
interface IInput {
/**
* Type of elements to search
*/
searchType: EType,
/**
* Value to search corresponding to searchType
*/
searchValue: string | number | undefined,
/**
* Currency
*/
currency?: ECurrency | undefined,
/**
* Genre
*/
genre?: EGenre | undefined,
/**
* Styles
*/
style?: EStyle[]
/**
* Formats
*/
format?: EFormat[]
/**
* Format descriptions
*/
formatDescription?: EFormatDescription[]
/**
* Media conditions
*/
mediaCondition?: EMediaCondition[]
/**
* Year (Do not use it with years)
*/
year?: number | undefined,
/**
* Interval of years (Do not use it with year)
*/
years?: IYears | undefined,
/**
* Is audio sample ?
*/
isAudioSample?: boolean,
/**
* Is make an offer only ?
*/
isMakeAnOfferOnly?: boolean,
/**
* Expedition country
*/
from?: EFrom | undefined,
/**
* Sort elements by
*/
sort?: ESort,
/**
* Limit of elements to search (25 | 50 | 100 | 250)
*/
limit?: TLimit,
/**
* Page (Must be < 401 or discogs will return an error 404)
*/
page?: number,
/**
* Lang to use for Discogs
*/
lang?: ELang
}
If success, it will return :
interface IOutputSuccess {
result: IItem[],
page: {
current: number,
total: number
},
item: {
total: number,
per_page: number,
},
search: {
value: string | number | undefined,
type: EType
},
url_generated: string | null,
}
interface IItem {
title: string | null | undefined,
url: string | null | undefined,
labels: (string | null)[] | null | undefined,
catnos: string[] | null | undefined,
imageUrl: string | null | undefined,
description: string | null | undefined,
isAcceptingOffer: boolean | null | undefined,
isAvailable: boolean | null | undefined,
condition: {
media: {
full: string | null | undefined,
short: string | null | undefined
},
sleeve: {
full: string | null | undefined,
short: string | null | undefined
}
},
seller: {
name: string | null | undefined,
score: string | null | undefined,
notes: string | null | undefined
},
price: {
base: string | null | undefined,
shipping: string | null | undefined,
from: string | null | undefined
},
community: {
have: number | null | undefined,
want: number | null | undefined
},
release_url: string | null | undefined
}
If error, it will return :
interface IOutputError {
message: string,
code: number | undefined
}
1.0.0
5 years ago