was a fork of github.com/irlndts/go-discogs because it didn't properly handle the API, but does as of the v0.3.6 release!
This repository has been archived on 2023-04-13. You can view files and clone it, but cannot push or open issues or pull requests.
Go to file
Philip Luyckx e1e0446c29 Add 'Artists' field to 'Track'
Some tracks contain different artists than specified in the release. In
this case there is a field 'artists' in the JSON response. This field is
added to the 'Track' struct. When the field 'artists' is available in the
JSON response, the length of 'Artists' is not 0. Otherwise the 'Artists'
from the release should be used.

Signed-off-by: Philip Luyckx <philip.luyckx@gmail.com>
2018-04-30 10:37:04 +02:00
examples Added several tests 2018-03-24 16:14:54 +03:00
vendor DSCGS-17 Use github.com/google/go-querystring/ 2018-03-17 21:58:56 +03:00
.travis.yml added travis-ci.yml 2018-03-28 20:11:47 +03:00
database_test.go Move services to database 2018-03-21 21:17:40 +03:00
database.go fix 2018-04-10 15:39:54 +03:00
discogs_test.go Added several tests 2018-03-24 16:17:35 +03:00
discogs.go Added several tests 2018-03-24 16:14:54 +03:00
errors.go fix 2018-04-10 15:39:54 +03:00
models.go Add 'Artists' field to 'Track' 2018-04-30 10:37:04 +02:00
README.md goreportcard 2018-03-28 20:18:24 +03:00
search.go goreportcard 2018-03-28 20:18:24 +03:00

REST API 2.0 Discogs.com client

Build StatusGo Report Card

go-discogs is a Go client library for the Discogs API. Check the usage section to see how to access the Discogs API.

Feauteres

  • Database
  • Releases
  • Release Rating
  • Master Releases
  • Master Versions
  • Artists
  • Artist Releases
  • Label
  • All Label Releases
  • Search

Install

go get -u 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 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.NewClient(&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
    })

Releases

  release, _ := client.Database.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
}

Example

  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)
  }

etc.