PHPackages                             corncodecreators/discogs-api-client - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. corncodecreators/discogs-api-client

ActiveLibrary[API Development](/categories/api)

corncodecreators/discogs-api-client
===================================

Unofficial official client for Discogs API

1.0.1(1y ago)2101MITPHPPHP ^8.1

Since Jan 31Pushed 1y agoCompare

[ Source](https://github.com/CornCodeCreators/discogs-api-client)[ Packagist](https://packagist.org/packages/corncodecreators/discogs-api-client)[ RSS](/packages/corncodecreators-discogs-api-client/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (8)Versions (3)Used By (0)

**The official unofficial**

Discogs-Api-Client for PHP
==========================

[](#discogs-api-client-for-php)

This API-Client was built on PHP to interact with [Discogs API](https://www.discogs.com/developers/) by supporting both authentication methods and providing a clean way to act with the data via DTO-Objects.

> **Remark:**
> This Client supports already the main required functions, improvements will come over time, and contribution is always welcome.

Quick'n Dirty Example
---------------------

[](#quickn-dirty-example)

This client will provide you quickly access to the Discogs API and deliver nice DTO-objects holding the data, so that you can easily use it in your PHP-application.

```
// create your client object
$discogsApiClient = new PersonalTokenClient();

// load the desired release-data from the Discogs API
$release = $discogsApiClient->requestDatabase()->getRelease(123);

// get the title of the release
$title = $release->getTitle();

// show all images of the release
foreach ($release->getImages() as $image) {
    $url = $image->getResourceUrl();
    echo "";
}
```

Features
--------

[](#features)

- **Easy:** This client is super easy to use!
- **Interaction with Discogs API:** Get all data you need from Discogs and interact with it!
- **Support for both Authentication Methods**: Easily switch between OAuth 1.0a and Discogs Token.
    - **Personal Access Tokens**: For accessing public resources and private user data.
    - **OAuth**: For more complex scenarios requiring user authorization.
- **DTO-Based Design**: The library is designed with a strong emphasis on Data Transfer Objects (DTOs), promoting clean and maintainable PHP code. The use of DTOs ensures well-structured and type-safe data handling and readable code.

Requirements
------------

[](#requirements)

- PHP 8.1 or higher
- A valid Discogs account and API key/token

Setup
-----

[](#setup)

### Installation

[](#installation)

Use Composer to add the client to your project:

```
composer require corncodecreators/discogs-api-client
```

### Configure your credentials (optional)

[](#configure-your-credentials-optional)

Put these variables into your `.env`-file, so you do not to need to put your credentials into the constructor of the API-Client.

```
DISCOGS_USER_AGENT=your_agent_name
DISCOGS_USER_TOKEN=your_token
```

or

```
DISCOGS_USER_AGENT=your_agent_name
DISCOGS_CONSUMER_KEY=your_consumer_key
DISCOGS_CONSUMER_SECRET=your_consumer_secret
```

Client-Initialization
---------------------

[](#client-initialization)

There are two clients to interact with the API. Either you use your PersonTokenClient, or the OAuth-client.

### Personal-Token-Client

[](#personal-token-client)

This is the simplest way to interact with Discogs API and is supporting access to everything you can get from Discogs. You should start with this solution and only swap to the OAuth-Client, if you really see a need.

#### Using Env-Variables

[](#using-env-variables)

```
use CornCodeCreators\Discogs\Client\PersonalTokenClient;

$discogsApiClient = new PersonalTokenClient();
$release = $discogsApiClient->requestDatabase()->getRelease(1234);

// ...
```

#### Using Parameters

[](#using-parameters)

*Remark:* You should try to avoid this solution to avoid compromising your credentials.

```
use CornCodeCreators\Discogs\Client\PersonalTokenClient;

$userAgent = 'MyAgent';
$userToken = 'abcdefg';

$discogsApiClient = new PersonalTokenClient($userAgent, $userToken);
$release = $discogsApiClient->requestDatabase()->getRelease(1234);

// ...
```

### OAuth-Client

[](#oauth-client)

#### Using Env-Variables

[](#using-env-variables-1)

```
use CornCodeCreators\Discogs\Client\OAuthClient;

$discogsApiClient = new OAuthClient();
$release = $discogsApiClient->requestDatabase()->getRelease(1234);

// ...
```

##### Using Parameters

[](#using-parameters-1)

*Remark:* You should try to avoid this solution to avoid compromising your credentials.

```
use CornCodeCreators\Discogs\Client\OAuthClient;

$userAgent      = 'MyAgent';
$consumerKey    = 'abcdefg';
$consumerSecret = '1234567';

$discogsApiClient = new OAuthClient($userAgent, $consumerKey, $consumerSecret);
$release = $discogsApiClient->requestDatabase()->getRelease(1234);
```

##### Symfony example

[](#symfony-example)

The OAuth-Flow requires multiple interaction steps between your application via this client and the Discogs-Server. This requires typically multiple controllers on your side. The example below is using Symfony

```
namespace App\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use CornCodeCreators\Discogs\Client\OAuthClient;

class OAuthController extends AbstractController
{
    private $discogsApiClient;

    public function __construct(
    ) {
        $this->discogsApiClient = new OAuthClient();
    }

    #[Route('/oauth', name: 'app_oauth_step1')]
    public function oauth(): RedirectResponse
    {
        $callbackUrl = $this->generateUrl('discogs_callback', [], UrlGeneratorInterface::ABSOLUTE_URL);
        $tokens      = $this->discogsApiClient->getRequestToken($callbackUrl);

        return $this->redirect($this->discogsApiClient->getAuthorizeUrl());
    }

    #[Route('/callback', name: 'discogs_callback')]
    public function callback(Request $request): RedirectResponse
    {
        $oauthVerifier = $request->query->get('oauth_verifier');
        $tokens        = $this->discogsApiClient->getAccessToken($oauthVerifier);

        return $this->redirectToRoute('app_homepage');
    }

    #[Route('/home', name: 'app_homepage')]
    public function home(): void
    {
        dump("Hello world! -> 'Dummy Homepage");

        $release = $this->discogsApiClient->requestDatabase()->getRelease(249504);

        dd($release);
    }
}
```

Making Requests
---------------

[](#making-requests)

The requests follow the structure provided by the API-Documentation

1. Database
2. UserIdentity
3. (more to come)

> **Remark:** This is not an exhausting list, but only good examples to start!

### Database

[](#database)

```
$data = $discogsApiClient->requestDatabase()->getRelease(249504);
$data = $discogsApiClient->requestDatabase()->getReleaseRatingOfUser(399193, 'Someone');
$data = $discogsApiClient->requestDatabase()->getReleaseRatingOfCommunity(399193);
$data = $discogsApiClient->requestDatabase()->getReleaseStats(399193);
$data = $discogsApiClient->requestDatabase()->getMasterRelease(1000);
$data = $discogsApiClient->requestDatabase()->getMasterReleaseVersions(1000);
$data = $discogsApiClient->requestDatabase()->getArtist(108713);
$data = $discogsApiClient->requestDatabase()->getLabel(1);
$data = $discogsApiClient->requestDatabase()->getArtistReleases(108713, ['per_page' => 42]);
$data = $discogsApiClient->requestDatabase()->getLabelReleases(1, ['per_page' => 5]);
$data = $discogsApiClient->requestDatabase()->searchAllTypes(['q' => 'Nirvana', 'per_page' => 5]);
$data = $discogsApiClient->requestDatabase()->addReleaseRatingOfUser(400788, 'Someone', 3);
$data = $discogsApiClient->requestDatabase()->removeReleaseRatingOfUser(400788, 'Someone');
```

### UserIdentity

[](#useridentity)

```
$data = $discogsApiClient->requestUser()->getIdentity();
$data = $discogsApiClient->requestUser()->getProfile("Someone");
$data = $discogsApiClient->requestUser()->getSubmissions("Someone");
$data = $discogsApiClient->requestUser()->getContributions("Someone");
$data = $discogsApiClient->requestUser()->updateProfile("Someone", ['name' => 'Jon Doe', 'profile' => 'Someone nobody knows']);
```

Documentation
-------------

[](#documentation)

Refer to the [Discogs Developer Documentation](https://www.discogs.com/developers/#page:authentication) for detailed information on API endpoints and authentication methods.

Contributing
------------

[](#contributing)

Feel free to fork this repository and contribute by submitting a pull request. Any contributions to enhance functionality or add features are welcome!

License
-------

[](#license)

This project is licensed under the MIT License. See the [MIT License](LICENSE). file for more details.

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance43

Moderate activity, may be stable

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1 days

Total

2

Last Release

471d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e01bad6c4c81d29bb9909f13aeefe042a5253b5f9c3a0f1f6b1029721332b427?d=identicon)[DigitalTimK](/maintainers/DigitalTimK)

---

Top Contributors

[![DigitalTimK](https://avatars.githubusercontent.com/u/45600940?v=4)](https://github.com/DigitalTimK "DigitalTimK (3 commits)")

---

Tags

phpapiclientdtodiscogs

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/corncodecreators-discogs-api-client/health.svg)

```
[![Health](https://phpackages.com/badges/corncodecreators-discogs-api-client/health.svg)](https://phpackages.com/packages/corncodecreators-discogs-api-client)
```

###  Alternatives

[kunalvarma05/dropbox-php-sdk

Dropbox PHP API V2 SDK (Unofficial)

3633.0M18](/packages/kunalvarma05-dropbox-php-sdk)[mozex/anthropic-php

Anthropic PHP is a supercharged community-maintained PHP API client that allows you to interact with Anthropic API.

46365.1k13](/packages/mozex-anthropic-php)[google-gemini-php/symfony

Symfony Bundle for Gemini

149.4k1](/packages/google-gemini-php-symfony)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
