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
2017-04-26 15:57:03 +03:00
examples DSCGS-4 Logic improved 2017-04-26 15:57:03 +03:00
artists_test.go DISCOGS-2 Search implementation 2017-02-14 22:01:50 +03:00
artists.go Artist Releases block 2016-03-11 17:07:35 +03:00
discogs_test.go DISCOGS-2 Search implementation 2017-02-14 22:01:50 +03:00
discogs.go DSCGS-4 Logic improved 2017-04-26 15:57:03 +03:00
errors.go DSCGS-4 Logic improved 2017-04-26 15:57:03 +03:00
labels_test.go DSCGS-4 enough for today 2017-04-25 19:39:32 +03:00
labels.go DISCOGS-2 Search implementation 2017-02-14 22:01:50 +03:00
masters_test.go DISCOGS-2 Search implementation 2017-02-14 22:01:50 +03:00
masters.go oi! oi! oi! 2016-03-10 17:25:55 +03:00
models.go DISCOGS-2 Fix for the day 2017-02-13 19:40:27 +03:00
README.md DSCGS-4 enough for today 2017-04-25 19:39:32 +03:00
releases_test.go DSCGS-4 enough for today 2017-04-25 19:39:32 +03:00
releases.go DSCGS-4 enough for today 2017-04-25 19:39:32 +03:00
search.go DSCGS-4 enough for today 2017-04-25 19:39:32 +03:00

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.

Changelog

14.02.2017 
- search is implemented
- minor improvements

Feauteres

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

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"
client := discogs.NewClient("TestDiscogsClient/0.0.1 +example.com", "")

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. Key-secret doesn't implemented yet, but token is yes.

client := discogs.NewClient("TestDiscogsClient/0.0.1 +example.com", "sometoken")

Releases

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

Artists

  params := &discogs.LabelParams{Label_id: "890477", Page: 2, Per_page: 3}
  label, _, err := client.Label.Releases(params)

  for _, release := range label.Releases {
    fmt.Println(release.Title)
  }

  /*
    Someday / I Hate Everything About You
    Spy Potion
    Surf Attack From Russia
  */

Issue a search query to discogs database. This endpoint accepts pagination parameters Authentication (as any user) is required.

Use SearchRequest struc 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)
    Release_title 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
    Per_page int // optional
}

Example

  request:= &discogs.SearchRequest{Artist: "reggaenauts", Release_title: "river rock", Page: 0, Per_page: 1}
  search, _, err := client.Search(request)

  for _, r := range search.Results {
    fmt.Println(r.Title)
  }

etc. More examples - soon