GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com โ€” GitHub - mrcl29/go-discogs-client: A professional, feature-rich, and idiomatic Go client for the Discogs API.

BranchesTags
Open more actions menu

Latest commit

 

History

9 Commits
9 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
cmd/example
cmd/example
 
 
docs
docs
 
 
examples
examples
 
 
.gitignore
.gitignore
 
 
CHANGELOG.md
CHANGELOG.md
 
 
CONTRIBUTING.md
CONTRIBUTING.md
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
auth.go
auth.go
 
 
client.go
client.go
 
 
client_test.go
client_test.go
 
 
collection.go
collection.go
 
 
collection_test.go
collection_test.go
 
 
database.go
database.go
 
 
database_test.go
database_test.go
 
 
doc.go
doc.go
 
 
estructura.txt
estructura.txt
 
 
example_test.go
example_test.go
 
 
go.mod
go.mod
 
 
go.sum
go.sum
 
 
inventory.go
inventory.go
 
 
lists.go
lists.go
 
 
marketplace.go
marketplace.go
 
 
marketplace_test.go
marketplace_test.go
 
 
models.go
models.go
 
 
options.go
options.go
 
 
pagination.go
pagination.go
 
 
user.go
user.go
 
 
user_test.go
user_test.go
 
 
wantlist.go
wantlist.go
 
 
wantlist_test.go
wantlist_test.go
 
 

Repository files navigation

go-discogs-client

Go Version License Go Reference CI

A professional, feature-rich, and idiomatic Go client for the Discogs API v2.0.

Built with scalability and idiomatic Go in mind, this library provides a complete interface to Discogs' vast music database and marketplace, handling authentication and rate limiting automatically so you can focus on your application logic.

โœจ Features

  • Full Service Coverage: Implementation for Database, Marketplace, Inventory, User, Collection, Wantlist, and Lists services.
  • Multiple Authentication Support: Native support for Anonymous, Personal Access Token, Consumer Key/Secret, and full OAuth 1.0a flows.
  • Automatic Rate Limiting: Intelligent local rate limiting based on your authentication tier (60 req/min for auth, 25 req/min for unauth) using token buckets.
  • Context Support: Every API call supports context.Context for proper timeout and cancellation management.
  • Functional Options: Clean client initialization using the functional options pattern.
  • Strongly Typed Models: Comprehensive and documented Go structs for all API responses, ensuring type safety and easy development.
  • Modern Go: Leverages Go 1.26.3 features and follows standard project layout conventions.

๐Ÿš€ Installation

go get github.com/mrcl29/go-discogs-client

๐Ÿ› ๏ธ Quick Start

1. Simple Metadata Retrieval (Anonymous)

package main

import (
    "context"
    "fmt"
    "github.com/mrcl29/go-discogs-client"
)

func main() {
    // Initialize a simple client (limited to 25 req/min)
    client := discogs.NewClient(discogs.WithUserAgent("MyMusicApp/1.0"))
    ctx := context.Background()

    // Fetch a release by ID
    release, err := client.Database.GetRelease(ctx, 249504) // Nirvana - Nevermind
    if err != nil {
        panic(err)
    }
    
    fmt.Printf("Release: %s (%d)\n", release.Title, release.Year)
}

2. Authenticated Search & Pagination

package main

import (
    "context"
    "fmt"
    "github.com/mrcl29/go-discogs-client"
)

func main() {
    auth := &discogs.PersonalTokenAuth{Token: "YOUR_PERSONAL_TOKEN"}
    client := discogs.NewClient(
        discogs.WithUserAgent("MyMusicApp/1.0"),
        discogs.WithAuth(auth),
    )
    ctx := context.Background()

    // Search with filters and pagination
    opts := &discogs.PageOptions{PerPage: 5}
    filters := map[string]string{"format": "Vinyl", "year": "1991"}
    
    res, err := client.Database.Search(ctx, "Nevermind", opts, filters)
    if err != nil {
        panic(err)
    }

    for _, result := range res.Results {
        fmt.Printf("Found: %s (ID: %d)\n", result.Title, result.ID)
    }
}

3. Collection Management (Requires Token/OAuth)

package main

import (
    "context"
    "github.com/mrcl29/go-discogs-client"
)

func main() {
    // ... client initialization with auth ...
    
    // Add a release to your 'Uncategorized' folder
    item, err := client.Collection.AddToCollectionFolder(ctx, "my_username", 1, 249504)
    if err != nil {
        panic(err)
    }
    
    fmt.Printf("Added with Instance ID: %d\n", item.InstanceID)
}

๐Ÿ—๏ธ Architecture & Design

Service-Oriented Design

The client is organized into domain-specific services, accessible directly from the main Client struct:

  • client.Database: Search, Releases, Masters, Artists, and Labels.
  • client.Marketplace: Listings, Orders, Price Suggestions, and Fee calculation.
  • client.Inventory: Inventory Export (CSV) and Batch Uploads.
  • client.User: Identity, Profiles, Submissions, and Contributions.
  • client.Collection: Folder management, item instances, and collection valuation.
  • client.Wantlist: Manage your personal release wantlist.
  • client.Lists: Access user-created lists.

Resilience & Thread Safety

The client is designed to be thread-safe and includes a built-in rate limiter that prevents your application from hitting the API limits by pacing requests locally. All network operations use http.Client timeouts and support Go's context package for cancellation.

๐Ÿ“š Examples

Check the examples/ directory for more detailed use cases:

  • Authentication Flows: Setting up different auth strategies.
  • Database Search: Advanced searching with filters.
  • Marketplace & Pricing: Managing listings and checking prices.
  • Collection Operations: Organizing your personal database.

๐Ÿงช Testing

The library is designed with testability as a core principle. All services can be easily tested using the provided mock server patterns.

Run tests:

go test -v ./...

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

About

A professional, feature-rich, and idiomatic Go client for the Discogs API.

Topics

clientdiscogsdiscogs-apidiscogs-clientgogolang

Resources

Readme
MIT license

Contributing

Contributing
Activity

Stars

1 star

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Used by

Contributors

Languages

You are visitor 01402775 โ€” GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800ร—600. No cookies required.