REST API 2.0 Discogs.com client
go-discogs is a Go client library for the Discogs API. Check the usage section to see how to access the Discogs API.
The lib is under MIT but be sure you are familiar with Discogs API Terms of Use.
Features
- Database
- Releases
- Release Rating
- Master Releases
- Master Versions
- Artists
- Artist Releases
- Label
- All Label Releases
- Search
- User Collection
- Collection Folders
- Folder
- Collection Items by Folder
- Collection Items by Release
- Marketplace
- Price Suggestions
- Release Statistics
Install
go get github.com/irlndts/go-discogs
Usage
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.
import "github.com/irlndts/go-discogs"
Some requests require authentication (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.
client, err := discogs.New(&discogs.Options{
UserAgent: "Some Name",
Currency: "EUR",
Token: "Some Token",
URL: "https://api.discogs.com",
})
Releases
release, _ := client.Release(9893847)
fmt.Println(release.Artists[0].Name, " - ", release.Title)
Search
Issue a search query to discogs database. This endpoint accepts pagination parameters.
Authentication (as any user) is required.
Use SearchRequest
struct to create a request.
type SearchRequest struct {
Q string
Type string
Title string
ReleaseTitle string
Credit string
Artist string
Anv string
Label string
Genre string
Style string
Country string
Year string
Format string
Catno string
Barcode string
Track string
Submitter string
Contributer string
Page int
PerPage int
}
request := discogs.SearchRequest{Artist: "reggaenauts", ReleaseTitle: "river rock", Page: 0, PerPage: 1}
search, _ := client.Search(request)
for _, r := range search.Results {
fmt.Println(r.Title)
}
User Collection
Query a users collection.
Collection Folders
collection, err := client.CollectionFolders("my_user")
Folder
folder, err := client.Folder("my_user", 0)
Collection Items by Folder
items, err := client.CollectionItemsByFolder("my_user", 0, &Pagination{Sort: "artist", SortOrder: "desc", PerPage: 2})
Collection Items by Release
items, err := client.CollectionItemsByRelease("my_user", 12934893)
Marketplace
Query a user's marketplace
Price Suggestions
Retrieve price suggestions for the provided Release ID
suggestions, err := client.PriceSuggestions(12345)
Release Statistics
Retrieve marketplace statistics for the provided Release ID
stats, err := client.ReleaseStatisctics(12345)
...
by the way, this is my discogs page