Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
PHP 5.4 Implementation of the Discogs API
branch: master

Merge pull request #26 from ricbra/update_travis

Added php 5.6 and hhvm to Travis configuration
latest commit 125a52c252
@ricbra authored

Discogs Api

Build Status Latest Stable Version Total Downloads License Quality

This library is a PHP 5.4 implementation of the Discogs API v2.0. The Discogs API is a REST-based interface. By using this library you don't have to worry about communicating with the API: all the hard work has already be done.

This API is build upon the shoulders of a giant: Guzzle 4.0. This is an absolutely awesome library.


This library is released under the MIT license. See the complete license in the LICENSE file.


Start by installing composer. Next do:

$ composer require ricbra/php-discogs-api


PHP >=5.4.0


Creating a new instance is as simple as:

$client = Discogs\ClientFactory::factory([]);


Discogs requires that you supply a User-Agent. You can do this easily:

$client = Discogs\ClientFactory::factory([
    'defaults' => [
        'headers' => ['User-Agent' => 'your-app-name/0.1 +'],


Discogs doesn't like it when you hit their API at a too high connection rate. Use the ThrottleSubscriber to prevent getting errors or banned:


$client = Discogs\ClientFactory::factory();
$client->getHttpClient()->getEmitter()->attach(new Discogs\Subscriber\ThrottleSubscriber());


There are a lot of endpoints which require OAuth. Lucky for you using Guzzle this is peanuts. If you're having trouble obtaining the token and token_secret, please check out my example implementation.


$client = Discogs\ClientFactory::factory([]);
$oauth = new GuzzleHttp\Subscriber\Oauth\Oauth1([
    'consumer_key'    => $consumerKey, // from Discogs developer page
    'consumer_secret' => $consumerSecret, // from Discogs developer page
    'token'           => $token['oauth_token'], // get this using a OAuth library
    'token_secret'    => $token['oauth_token_secret'] // get this using a OAuth library

$response = $client->search([
    'q' => 'searchstring'


Another cool plugin is the History plugin:


$client = Discogs\ClientFactory::factory([]);
$history = new GuzzleHttp\Subscriber\History();

$response = $client->search([
    'q' => 'searchstring'

foreach ($history as $row) {
    print (string) $row['request'];
    print (string) $row['response'];

More info and plugins

For more information about Guzzle and its plugins checkout the docs.

Perform a search:

Per august 2014 a signed OAuth request is required for this endpoint.


$response = $client->search([
    'q' => 'Meagashira'
// Loop through results
foreach ($response['results'] as $result) {
// Pagination data

// Dump all data

Get information about a label:


$label = $service->getLabel([
    'id' => 1

Get information about an artist:


$artist = $service->getArtist([
    'id' => 1

Get information about a release:


$release = $service->getRelease([
    'id' => 1

echo $release['title']."\n";

Get information about a master release:


$master  = $service->getMaster([
    'id' => 1

echo $master['title']."\n";


Further documentation can be found at the Discogs API v2.0 Documentation.


Implemented a missing call? PR's are welcome!

Bitdeli Badge

Something went wrong with that request. Please try again.