fork of github.com/irlndts/go-discogs because it doesn't properly handle the API
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Go to file
alazyreader 796bff1c6c
properly parse notes array on folder collections (#1)
1 year ago
.github/workflows Version rise up (#49) 2 years ago
vendor Raise go version (#48) 2 years ago
.gitignore Methods moved to interface, vendors updated (#40) 3 years ago
LICENSE.txt Create LICENSE.txt 3 years ago
README.md readme update 2 years ago
database.go Artist's groups omitempty (#52) 1 year ago
database_test.go Methods moved to interface, vendors updated (#40) 3 years ago
discogs.go Handle TooManyRequests error (#53) 1 year ago
discogs_test.go User collection API additions (#42) 2 years ago
doc.go Methods moved to interface, vendors updated (#40) 3 years ago
errors.go Handle TooManyRequests error (#53) 1 year ago
go.mod Raise go version (#48) 2 years ago
go.sum Raise go version (#48) 2 years ago
marketplace.go Add marketplace APIs (#43) 2 years ago
marketplace_test.go Add marketplace APIs (#43) 2 years ago
models.go User collection API additions (#42) 2 years ago
search.go Methods moved to interface, vendors updated (#40) 3 years ago
testing_data.go Add marketplace APIs (#43) 2 years ago
user_collection.go properly parse notes array on folder collections (#1) 1 year ago
user_collection_test.go User collection API additions (#42) 2 years ago

README.md

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", // 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
    })

Releases

  release, _ := client.Release(9893847)
  fmt.Println(release.Artists[0].Name, " - ", release.Title) 
  // St. Petersburg Ska-Jazz Review  -  Elephant Riddim

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 // search query (optional)
    Type          string // one of release, master, artist, label (optional)
    Title         string // search by combined “Artist Name - Release Title” title field (optional)
    ReleaseTitle string // search release titles (optional)
    Credit        string // search release credits (optional)
    Artist        string // search artist names (optional)
    Anv           string // search artist ANV (optional)
    Label         string // search label names (optional)
    Genre         string // search genres (optional)
    Style         string // search styles (optional)
    Country       string // search release country (optional)
    Year          string // search release year (optional)
    Format        string // search formats (optional)
    Catno         string // search catalog number (optional)
    Barcode       string // search barcodes (optional)
    Track         string // search track titles (optional)
    Submitter     string // search submitter username (optional)
    Contributer   string // search contributor usernames (optional)

    Page     int // optional
    PerPage  int // optional
}
  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