Instantiating the client object

import discogs_client
d = discogs_client.Client('ExampleApplication/0.1')

The string passed into the Client class is your User-Agent. A User-Agent is required for Discogs API requests, as it identifies your application to the Discogs servers.

There are more parameters the Client class accepts on instantiation; please refer to the authentication chapter for more details.

Once instantiated, you can either start making requests to endpoints that do not require authentication, or you can authenticate and make requests to a wider range of endpoints.

release = d.release(1293022)
artists = release.artists

As you can see, once you fetch data from an endpoint, you can call various properties and methods on those objects.


Note that for searching Discogs via the API you need to be an authenticated user already.

Simple example:

results = d.search('Can I borrow a feeling?')

The search method allows for all of the parameters that the raw Discogs API allows. A full list of available parameters is found here.

Examples using parameters:

results = d.search('Can I borrow a feeling?', type='release')
results = d.search('Can I borrow a feeling?', type='release,master')
results = d.search('Can I borrow a feeling?', artist='Kirk', type='release')
results = d.search('Can I borrow a feeling?', genre='Hip Hop')

The results object is a paginated list, so you need to specify which page of results to view, like so:


Most other objects

Objects contain many callable properties. Some examples are shown in the fetching data section. For a full list of properties, call the Python dir() function with the object as a parameter.

Also look into the documentation of the models module at discogs_client.models, to find out what properties are available.

Not all information available in the API response is mapped out, so if you need more information, you can look in the data property of the Release object:

release = d.release(1)