Documentation
¶
Overview ¶
Package discogs is a Go client library for the Discogs API.
The discogs package provides a client for accessing the Discogs API. First of all import library and init client variable. According to discogs api documentation you must provide your user-agent.
Some requests require authentification (as any user). According to Discogs, to send requests with Discogs Auth, you have two options: sending your credentials in the query string with key and secret parameters or a token parameter. This is token way example:
client, err := discogs.New(&discogs.Options{
UserAgent: "Some Name",
Currency: "EUR", // optional, "USD" (default), "GBP", "EUR", "CAD", "AUD", "JPY", "CHF", "MXN", "BRL", "NZD", "SEK", "ZAR" are allowed
Token: "Some Token", // optional
URL: "https://api.discogs.com", // optional
})
Index ¶
- Variables
- type Alias
- type Artist
- type ArtistReleases
- type ArtistSource
- type BasicInformation
- type CollectionFolders
- type CollectionItemSource
- type CollectionItems
- type CollectionService
- type Community
- type Company
- type Contributor
- type DatabaseService
- type Discogs
- type Error
- type Folder
- type Format
- type Identifier
- type Image
- type Label
- type LabelReleases
- type LabelSource
- type Listing
- type MarketPlaceService
- type Master
- type MasterVersions
- type Member
- type Notes
- type Options
- type Page
- type Pagination
- type PriceListing
- type Rating
- type Release
- type ReleaseRating
- type ReleaseSource
- type Result
- type Search
- type SearchRequest
- type SearchService
- type Series
- type Stats
- type Sublable
- type Submitter
- type Track
- type URLsList
- type Version
- type Video
Constants ¶
This section is empty.
Variables ¶
var ( ErrCurrencyNotSupported = &Error{"currency does not supported"} ErrInvalidReleaseID = &Error{"invalid release id"} ErrInvalidSortKey = &Error{"invalid sort key"} ErrInvalidUsername = &Error{"invalid username"} ErrTooManyRequests = &Error{"too many requests"} ErrUserAgentInvalid = &Error{"invalid user-agent"} )
APIErrors
Functions ¶
This section is empty.
Types ¶
type Alias ¶
type Alias struct {
ID int `json:"id"`
Name string `json:"name"`
ResourceURL string `json:"resource_url"`
}
Alias ...
type Artist ¶
type Artist struct {
ID int `json:"id"`
Name string `json:"name"`
Realname string `json:"realname"`
Members []Member `json:"members,omitempty"`
Aliases []Alias `json:"aliases,omitempty"`
Namevariations []string `json:"namevariations"`
Images []Image `json:"images"`
Profile string `json:"profile"`
ReleasesURL string `json:"releases_url"`
ResourceURL string `json:"resource_url"`
URI string `json:"uri"`
URLs []string `json:"urls"`
Groups []Member `json:"groups,omitempty"`
DataQuality string `json:"data_quality"`
}
Artist resource represents a person in the Discogs database who contributed to a Release in some capacity. More information https://www.discogs.com/developers#page:database,header:database-artist
type ArtistReleases ¶
type ArtistReleases struct {
Pagination Page `json:"pagination"`
Releases []ReleaseSource `json:"releases"`
}
ArtistReleases ...
type ArtistSource ¶
type ArtistSource struct {
Anv string `json:"anv"`
ID int `json:"id"`
Join string `json:"join"`
Name string `json:"name"`
ResourceURL string `json:"resource_url"`
Role string `json:"role"`
Tracks string `json:"tracks"`
}
ArtistSource ...
type BasicInformation ¶ added in v0.3.1
type BasicInformation struct {
ID int `json:"id"`
Artists []ArtistSource `json:"artists"`
CoverImage string `json:"cover_image"`
Formats []Format `json:"formats"`
Labels []LabelSource `json:"labels"`
Genres []string `json:"genres"`
MasterID int `json:"master_id"`
MasterURL *string `json:"master_url"`
ResourceURL string `json:"resource_url"`
Styles []string `json:"styles"`
Thumb string `json:"thumb"`
Title string `json:"title"`
Year int `json:"year"`
}
BasicInformation ...
type CollectionFolders ¶ added in v0.3.1
type CollectionFolders struct {
Folders []Folder `json:"folders"`
}
CollectionFolders serves collection response from discogs.
type CollectionItemSource ¶ added in v0.3.1
type CollectionItemSource struct {
ID int `json:"id"`
BasicInformation BasicInformation `json:"basic_information"`
DateAdded string `json:"date_added"`
FolderID int `json:"folder_id,omitempty"`
InstanceID int `json:"instance_id"`
Notes []Notes `json:"notes,omitempty"`
Rating int `json:"rating"`
}
CollectionItemSource ...
type CollectionItems ¶ added in v0.3.1
type CollectionItems struct {
Pagination Page `json:"pagination"`
Items []CollectionItemSource `json:"releases"`
}
CollectionItems list of items in a user’s collection
type CollectionService ¶ added in v0.3.1
type CollectionService interface {
// Retrieve a list of folders in a user’s collection.
// If folder_id is not 0, authentication as the collection owner is required.
CollectionFolders(username string) (*CollectionFolders, error)
// Retrieve a list of items in a folder in a user’s collection.
// If folderID is not 0, authentication with token is required.
CollectionItemsByFolder(username string, folderID int, pagination *Pagination) (*CollectionItems, error)
// Retrieve the user’s collection folders which contain a specified release.
// The releaseID must be non-zero.
CollectionItemsByRelease(username string, releaseID int) (*CollectionItems, error)
// Retrieve metadata about a folder in a user’s collection.
Folder(username string, folderID int) (*Folder, error)
}
CollectionService is an interface to work with collection.
type Community ¶
type Community struct {
Contributors []Contributor `json:"contributors"`
DataQuality string `json:"data_quality"`
Have int `json:"have"`
Rating Rating `json:"rating"`
Status string `json:"status"`
Submitter Submitter `json:"submitter"`
Want int `json:"want"`
}
Community ...
type Company ¶
type Company struct {
Catno string `json:"catno"`
EntityType string `json:"entity_type"`
EntityTypeName string `json:"entity_type_name"`
ID int `json:"id"`
Name string `json:"name"`
ResourceURL string `json:"resource_url"`
}
Company ...
type Contributor ¶
type Contributor struct {
ResourceURL string `json:"resource_url"`
Username string `json:"username"`
}
Contributor ...
type DatabaseService ¶
type DatabaseService interface {
// Artist represents a person in the discogs database.
Artist(artistID int) (*Artist, error)
// ArtistReleases returns a list of releases and masters associated with the artist.
ArtistReleases(artistID int, pagination *Pagination) (*ArtistReleases, error)
// Label returns a label.
Label(labelID int) (*Label, error)
// LabelReleases returns a list of Releases associated with the label.
LabelReleases(labelID int, pagination *Pagination) (*LabelReleases, error)
// Master returns a master release.
Master(masterID int) (*Master, error)
// MasterVersions retrieves a list of all Releases that are versions of this master.
MasterVersions(masterID int, pagination *Pagination) (*MasterVersions, error)
// Release returns release by release's ID.
Release(releaseID int) (*Release, error)
// ReleaseRating retruns community release rating.
ReleaseRating(releaseID int) (*ReleaseRating, error)
}
DatabaseService is an interface to work with database.
type Discogs ¶
type Discogs interface {
CollectionService
DatabaseService
MarketPlaceService
SearchService
}
Discogs is an interface for making Discogs API requests.
type Folder ¶ added in v0.3.1
type Folder struct {
ID int `json:"id"`
Count int `json:"count"`
Name string `json:"name"`
ResourceURL string `json:"resource_url"`
}
Folder serves folder response from discogs.
type Format ¶
type Format struct {
Descriptions []string `json:"descriptions"`
Name string `json:"name"`
Qty string `json:"qty"`
Text string `json:"text,omitempty"`
}
Format ...
type Identifier ¶
type Identifier struct {
Description string `json:"description,omitempty"`
Type string `json:"type"`
Value string `json:"value"`
}
Identifier ...
type Image ¶
type Image struct {
Height int `json:"height"`
Width int `json:"width"`
ResourceURL string `json:"resource_url"`
Type string `json:"type"`
URI string `json:"uri"`
URI150 string `json:"uri150"`
}
Image ...
type Label ¶
type Label struct {
Profile string `json:"profile"`
ReleasesURL string `json:"releases_url"`
Name string `json:"name"`
ContactInfo string `json:"contact_info"`
URI string `json:"uri"`
Sublabels []Sublable `json:"sublabels"`
URLs []string `json:"urls"`
Images []Image `json:"images"`
ResourceURL string `json:"resource_url"`
ID int `json:"id"`
DataQuality string `json:"data_quality"`
}
Label resource represents a label, company, recording studio, location, or other entity involved with artists and releases.
type LabelReleases ¶
type LabelReleases struct {
Pagination Page `json:"pagination"`
Releases []ReleaseSource `json:"releases"`
}
LabelReleases is a list of Releases associated with the label.
type LabelSource ¶
type LabelSource struct {
Catno string `json:"catno"`
EntityType string `json:"entity_type"`
EntityTypeName string `json:"entity_type_name"`
ID int `json:"id"`
Name string `json:"name"`
ResourceURL string `json:"resource_url"`
}
LabelSource ...
type Listing ¶ added in v0.3.1
Listing is a marketplace listing with the user's currency and a price value
type MarketPlaceService ¶ added in v0.3.1
type Master ¶
type Master struct {
ID int `json:"id"`
Styles []string `json:"styles"`
Genres []string `json:"genres"`
Title string `json:"title"`
Year int `json:"year"`
Tracklist []Track `json:"tracklist"`
Notes string `json:"notes"`
Artists []ArtistSource `json:"artists"`
Images []Image `json:"images"`
Videos []Video `json:"videos"`
NumForSale int `json:"num_for_sale"`
LowestPrice float64 `json:"lowest_price"`
URI string `json:"uri"`
MainRelease int `json:"main_release"`
MainReleaseURL string `json:"main_release_url"`
MostRecentRelease int `json:"most_recent_release"`
MostRecentReleaseURL string `json:"most_recent_release_url"`
VersionsURL string `json:"versions_url"`
ResourceURL string `json:"resource_url"`
DataQuality string `json:"data_quality"`
}
Master resource represents a set of similar releases. Masters (also known as `master releases`) have a `main release` which is often the chronologically earliest. More information https://www.discogs.com/developers#page:database,header:database-master-release
type MasterVersions ¶
type MasterVersions struct {
Pagination Page `json:"pagination"`
Versions []Version `json:"versions"`
}
MasterVersions retrieves a list of all releases that are versions of this master.
type Member ¶
type Member struct {
Active bool `json:"active"`
ID int `json:"id"`
Name string `json:"name"`
ResourceURL string `json:"resource_url"`
}
Member ...
type Options ¶
type Options struct {
// Discogs API endpoint (optional).
URL string
// Currency to use (optional, default is USD).
Currency string
// UserAgent to to call discogs api with.
UserAgent string
// Token provided by discogs (optional).
Token string
}
Options is a set of options to use discogs API client
type Page ¶
type Page struct {
PerPage int `json:"per_page"`
Items int `json:"items"`
Page int `json:"page"`
URLs URLsList `json:"urls"`
Pages int `json:"pages"`
}
Page ...
type Pagination ¶
type Pagination struct {
// TODO(irlndts): validate requested Sort
Sort string // year, title, format etc
// TODO(irlndts): validate requested SortOrder
SortOrder string // asc, desc
Page int
PerPage int
}
Pagination ...
type PriceListing ¶ added in v0.3.1
type PriceListing struct {
VeryGood *Listing `json:"Very Good (VG),omitempty"`
GoodPlus *Listing `json:"Good Plus (G+),omitempty"`
NearMint *Listing `json:"Near Mint (NM or M-)"`
Good *Listing `json:"Good (G),omitempty"`
VeryGoodPlus *Listing `json:"Very Good Plus (VG+),omitempty"`
Mint *Listing `json:"Mint (M),omitempty"`
Fair *Listing `json:"Fair (F),omitempty"`
Poor *Listing `json:"Poor (P),omitempty"`
}
PriceListings are Listings per grading quality
type Release ¶
type Release struct {
Title string `json:"title"`
ID int `json:"id"`
Artists []ArtistSource `json:"artists"`
ArtistsSort string `json:"artists_sort"`
DataQuality string `json:"data_quality"`
Thumb string `json:"thumb"`
Community Community `json:"community"`
Companies []Company `json:"companies"`
Country string `json:"country"`
DateAdded string `json:"date_added"`
DateChanged string `json:"date_changed"`
EstimatedWeight int `json:"estimated_weight"`
ExtraArtists []ArtistSource `json:"extraartists"`
FormatQuantity int `json:"format_quantity"`
Formats []Format `json:"formats"`
Genres []string `json:"genres"`
Identifiers []Identifier `json:"identifiers"`
Images []Image `json:"images"`
Labels []LabelSource `json:"labels"`
LowestPrice float64 `json:"lowest_price"`
MasterID int `json:"master_id"`
MasterURL string `json:"master_url"`
Notes string `json:"notes,omitempty"`
NumForSale int `json:"num_for_sale,omitempty"`
Released string `json:"released"`
ReleasedFormatted string `json:"released_formatted"`
ResourceURL string `json:"resource_url"`
Series []Series `json:"series"`
Status string `json:"status"`
Styles []string `json:"styles"`
Tracklist []Track `json:"tracklist"`
URI string `json:"uri"`
Videos []Video `json:"videos"`
Year int `json:"year"`
}
Release serves relesase response from discogs.
type ReleaseRating ¶
ReleaseRating serves response for community release rating request.
type ReleaseSource ¶
type ReleaseSource struct {
Artist string `json:"artist"`
Catno string `json:"catno"`
Format string `json:"format"`
ID int `json:"id"`
ResourceURL string `json:"resource_url"`
Status string `json:"status"`
Thumb string `json:"thumb"`
Title string `json:"title"`
Year int `json:"year"`
MainRelease int `json:"main_release"`
Role string `json:"role"`
Type string `json:"type"`
}
ReleaseSource ...
type Result ¶
type Result struct {
Style []string `json:"style,omitempty"`
Thumb string `json:"thumb,omitempty"`
CoverImage string `json:"cover_image,omitempty"`
Title string `json:"title,omitempty"`
Country string `json:"country,omitempty"`
Format []string `json:"format,omitempty"`
URI string `json:"uri,omitempty"`
Community Community `json:"community,omitempty"`
Label []string `json:"label,omitempty"`
Catno string `json:"catno,omitempty"`
Year string `json:"year,omitempty"`
Genre []string `json:"genre,omitempty"`
ResourceURL string `json:"resource_url,omitempty"`
Type string `json:"type,omitempty"`
ID int `json:"id,omitempty"`
MasterID int `json:"master_id,omitempty"`
}
Result describes a part of search result
type Search ¶
type Search struct {
Pagination Page `json:"pagination"`
Results []Result `json:"results,omitempty"`
}
Search describes search response
type SearchRequest ¶
type SearchRequest struct {
Q string // search query
Type string // one of release, master, artist, label
Title string // search by combined “Artist Name - Release Title” title field
ReleaseTitle string // search release titles
Credit string // search release credits
Artist string // search artist names
Anv string // search artist ANV
Label string // search label names
Genre string // search genres
Style string // search styles
Country string // search release country
Year string // search release year
Format string // search formats
Catno string // search catalog number
Barcode string // search barcodes
Track string // search track titles
Submitter string // search submitter username
Contributor string // search contributor usernames
Page int
PerPage int
}
SearchRequest describes search request
type SearchService ¶
type SearchService interface {
// Search makes search request to discogs.
// Issue a search query to database. This endpoint accepts pagination parameters.
// Authentication (as any user) is required.
// https://www.discogs.com/developers/#page:database,header:database-search
Search(req SearchRequest) (*Search, error)
}
SearchService is an interface to work with search.
type Series ¶
type Series struct {
Catno string `json:"catno"`
EntityType string `json:"entity_type"`
EntityTypeName string `json:"entity_type_name"`
ID int `json:"id"`
Name string `json:"name"`
ResourceURL string `json:"resource_url"`
ThumbnailURL string `json:"thumbnail_url,omitempty"`
}
Series ...
type Stats ¶ added in v0.3.1
type Stats struct {
LowestPrice *Listing `json:"lowest_price"`
ForSale int `json:"num_for_sale"`
Blocked bool `json:"blocked_from_sale"`
}
Stats returns the marketplace stats summary for a release containing
type Sublable ¶
type Sublable struct {
ResourceURL string `json:"url"`
ID int `json:"id"`
Name string `json:"name"`
}
Sublable ...
type Submitter ¶
type Submitter struct {
ResourceURL string `json:"resource_url"`
Username string `json:"username"`
}
Submitter ...
type Track ¶
type Track struct {
Duration string `json:"duration"`
Position string `json:"position"`
Title string `json:"title"`
Type string `json:"type_"`
Extraartists []ArtistSource `json:"extraartists,omitempty"`
Artists []ArtistSource `json:"artists,omitempty"`
}
Track ...
type Version ¶
type Version struct {
Catno string `json:"catno"`
Country string `json:"country"`
Format string `json:"format"`
ID int `json:"id"`
Label string `json:"label"`
Released string `json:"released"`
ResourceURL string `json:"resource_url"`
Status string `json:"status"`
Thumb string `json:"thumb"`
Title string `json:"title"`
}
Version ...