Options
All
  • Public
  • Public/Protected
  • All
Menu

Discojs

Easiest way to use the Discogs API in Javascript - now with Typescript support! :musical_note:

CircleCI Coverage Status

Installation

yarn add discojs

Usage example

import {Discojs} from 'discojs'

const client = new Discojs({
  userToken: process.env.USER_TOKEN,
})

client
  .searchArtist('Jacob Desvarieux')
  .then(data => doSomethingWith(data))

API Reference

v2

Documentation for discojs@2.x is available on GitHub Pages;

v1

Documentation for discojs@1.x is available in the wiki.

Tests

As several methods need authentication, you'll need 2 environment variables: DGS_USERNAME_ and _USER_TOKEN.

Create a .env file at the root of the directory, and add the following lines:

DGS_USERNAME=0ctocat
USER_TOKEN=7h1515myu53r70k3n

:warning: Use a test account as public information will be edited.

As stated by Discogs API, some methods need a seller account. As I do not have one, I could not test them (which explains the coverage).

npm run test

When running tests, go grab a cup of coffee as this may be long because of Discogs API rate limiting.

Credits

Inspired by disconnect from @bartve

Index

Type aliases

AddToFolderResponse

AddToFolderResponse: t.TypeOf<typeof AddToFolderResponseIO>

AddToWantlistResponse

AddToWantlistResponse: t.TypeOf<typeof AddToWantlistResponseIO>

Artist

Artist: t.TypeOf<typeof ArtistIO>

ArtistReleasesResponse

ArtistReleasesResponse: t.TypeOf<typeof ArtistReleasesResponseIO>

AuthOptions

CollectionValueResponse

CollectionValueResponse: t.TypeOf<typeof CollectionValueIO>

CommunityReleaseRatingResponse

CommunityReleaseRatingResponse: t.TypeOf<typeof CommunityReleaseRatingResponseIO>

ConsumerKeyAuth

ConsumerKeyAuth: { consumerKey: string; consumerSecret: string; oAuthToken: string; oAuthTokenSecret: string }

Type declaration

  • consumerKey: string

    Consumer key.

  • consumerSecret: string

    Consumer secret.

  • oAuthToken: string

    OAuth token.

  • oAuthTokenSecret: string

    OAuth token secret.

CreateListingResponse

CreateListingResponse: t.TypeOf<typeof CreateListingResponseIO>

CustomFieldsResponse

CustomFieldsResponse: t.TypeOf<typeof CustomFieldsResponseIO>

DiscojsOptions

DiscojsOptions: Partial<AuthOptions> & LimiterOptions & { fetchOptions?: RequestInit; outputFormat?: OutputFormat; userAgent?: undefined | string }

EditUserProfileResponse

EditUserProfileResponse: t.TypeOf<typeof UserIO>

EmptyResponse

EmptyResponse: {}

Type declaration

Fee

Fee: t.TypeOf<typeof FeeIO>

Folder

Folder: t.TypeOf<typeof FolderIO>

FolderReleasesResponse

FolderReleasesResponse: t.TypeOf<typeof FolderReleasesResponseIO>

FoldersResponse

FoldersResponse: t.TypeOf<typeof FoldersResponseIO>

IdentityResponse

IdentityResponse: t.TypeOf<typeof IdentityIO>

InventoryResponse

InventoryResponse: t.TypeOf<typeof InventoryResponseIO>

Label

Label: t.TypeOf<typeof LabelIO>

LabelReleasesResponse

LabelReleasesResponse: t.TypeOf<typeof LabelReleasesResponseIO>

Limiter

Limiter: Bottleneck

LimiterOptions

LimiterOptions: { requestLimit?: undefined | number; requestLimitAuth?: undefined | number; requestLimitInterval?: undefined | number }

Type declaration

  • Optional requestLimit?: undefined | number

    Number of requests per interval for unauthenticated requests. Defaults to 25.

  • Optional requestLimitAuth?: undefined | number

    Number of requests per interval for authenticated requests. Defaults to 60.

  • Optional requestLimitInterval?: undefined | number

    Interval to use to throttle requests. Defaults to 60 seconds.

Listing

Listing: t.TypeOf<typeof ListingIO>

ListingOptions

ListingOptions: { allowOffers?: undefined | false | true; comments?: undefined | string; condition: ReleaseConditionsEnum; externalId?: undefined | string; formatQuantity?: "auto" | number; location?: undefined | string; price: number; releaseId: number; sleeveCondition?: SleeveConditionsEnum; status: ListingStatusesEnum; weight?: "auto" | number }

Type declaration

  • Optional allowOffers?: undefined | false | true
  • Optional comments?: undefined | string
  • condition: ReleaseConditionsEnum
  • Optional externalId?: undefined | string
  • Optional formatQuantity?: "auto" | number
  • Optional location?: undefined | string
  • price: number
  • releaseId: number
  • Optional sleeveCondition?: SleeveConditionsEnum
  • status: ListingStatusesEnum
  • Optional weight?: "auto" | number

MarketplaceStatisticsResponse

MarketplaceStatisticsResponse: t.TypeOf<typeof MarketplaceStatisticsResponseIO>

Master

Master: t.TypeOf<typeof MasterIO>

MasterVersionsResponse

MasterVersionsResponse: t.TypeOf<typeof MasterVersionsResponseIO>

Order

Order: t.TypeOf<typeof OrderIO>

OrderMessage

OrderMessage: t.TypeOf<typeof OrderMessageIO>

OrderMessagesResponse

OrderMessagesResponse: t.TypeOf<typeof OrderMessagesResponseIO>

OutputFormat

OutputFormat: "discogs"

PriceSuggestionsResponse

PriceSuggestionsResponse: t.TypeOf<typeof PriceSuggestionsResponseIO>

ProfileOptions

ProfileOptions: { currAbbr?: CurrenciesEnum; homePage?: undefined | string; location?: undefined | string; name?: undefined | string; profile?: undefined | string; username?: undefined | string }

Type declaration

  • Optional currAbbr?: CurrenciesEnum
  • Optional homePage?: undefined | string
  • Optional location?: undefined | string
  • Optional name?: undefined | string
  • Optional profile?: undefined | string
  • Optional username?: undefined | string

RatingValues

RatingValues: t.TypeOf<typeof RatingValuesIO>

Release

Release: t.TypeOf<typeof ReleaseIO>

ReleaseRatingResponse

ReleaseRatingResponse: t.TypeOf<typeof ReleaseRatingResponseIO>

ReleaseStatsResponse

ReleaseStatsResponse: t.TypeOf<typeof ReleaseStatsResponseIO>

SearchOptions

SearchOptions: { anv?: undefined | string; artist?: undefined | string; barcode?: undefined | string; catno?: undefined | string; contributor?: undefined | string; country?: undefined | string; credit?: undefined | string; format?: undefined | string; genre?: undefined | string; label?: undefined | string; query?: undefined | string; releaseTitle?: undefined | string; style?: undefined | string; submitter?: undefined | string; title?: undefined | string; track?: undefined | string; type?: SearchTypeEnum; year?: string | number }

Type declaration

  • Optional anv?: undefined | string
  • Optional artist?: undefined | string
  • Optional barcode?: undefined | string
  • Optional catno?: undefined | string
  • Optional contributor?: undefined | string
  • Optional country?: undefined | string
  • Optional credit?: undefined | string
  • Optional format?: undefined | string
  • Optional genre?: undefined | string
  • Optional label?: undefined | string
  • Optional query?: undefined | string
  • Optional releaseTitle?: undefined | string
  • Optional style?: undefined | string
  • Optional submitter?: undefined | string
  • Optional title?: undefined | string
  • Optional track?: undefined | string
  • Optional type?: SearchTypeEnum
  • Optional year?: string | number

SearchResponse

SearchResponse: t.TypeOf<typeof SearchResponseIO>

SetAuthorizationHeaderFunction

SetAuthorizationHeaderFunction: (url?: undefined | string, method?: HTTPVerbsEnum) => string

Type declaration

    • (url?: undefined | string, method?: HTTPVerbsEnum): string
    • Parameters

      • Optional url: undefined | string
      • Optional method: HTTPVerbsEnum

      Returns string

UserContributionsResponse

UserContributionsResponse: t.TypeOf<typeof UserContributionsResponseIO>

UserListItemsResponse

UserListItemsResponse: t.TypeOf<typeof UserListItemsResponseIO>

UserListsResponse

UserListsResponse: t.TypeOf<typeof UserListsResponseIO>

UserProfileResponse

UserProfileResponse: t.TypeOf<typeof UserIO>

UserSubmissionsResponse

UserSubmissionsResponse: t.TypeOf<typeof UserSubmissionsResponseIO>

UserTokenAuth

UserTokenAuth: { userToken: string }

Type declaration

  • userToken: string

    User token.

WantlistResponse

WantlistResponse: t.TypeOf<typeof WantlistResponseIO>

Variables

Const DEFAULT_PAGE

DEFAULT_PAGE: 1 = 1

Const DEFAULT_PER_PAGE

DEFAULT_PER_PAGE: 50 = 50

Functions

applyMixins

  • applyMixins(derivedCtor: any, constructors: any[]): void

makeSetAuthorizationHeader

Legend

Generated using TypeDoc