Skip to content
A lightweight client for the 7Digital API
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

(Note: I am no longer developing this client, and it may be very out-of-date. Please feel free to fork it. If you want to take over responsibility for this repo, please let me know. [4 June 2016])

python-7Digital (py7D)

py7D - A lightweight client for the 7Digital API.


python-oath2 :

xmltodict : pip install xmltodict or clone from git://


py7D is a very lightweight API client for the 7Digital API.

The client is meant to provide a very thin layer of access to the 7Digital API with which you can make any call to any of the valid methods and functions described in the documentation.

The documentation for the API is found here:

The response is converted from XML to a python Ordered Dict, and each node in the XML is converted to a key name.

In the case of a node attribute, the attribute name is converted to a key name preceded by the '@' character. For example, the id attribute on the track node would convert to {'track' : {'@id' : 123, ...}}


# set your oauth_consumer_key, oauth_consumer_secret, and country in the module.
import py7D
results = py7D.request(method, function, page=1, pageSize=10)
results = py7D.request(method, function)


request(method, function, **kwargs)
results = py7D.request('artist', 'search', q='black')
results = py7D.request('artist', 'search', q='black', page=1, pageSize=20)
results = py7D.request('tag', None)
results = py7D.request('artist', 'details', artistId=263)

OAuth signed request:
py7D.oauth_3legged_request(method, function, access_token, **kwargs)
py7D.oauth_2legged_request(method, function, **kwargs)


The module included has been upgraded from it's original to use python-oauth2 instead of python-oauth. It also looks for its settings in the api_settings module.

The original can be found at git://

Its usage to get an access token:

import oauth7digital as oa7d
token = oa7d.request_token()
authorized = oa7d.authorize_request_token(token, debug=True)
access_token = oa7d.request_access_token(token)

Example Output

resp = py7D.request('artist', 'search', q='pink', pageSize=3)
>>> resp.keys()
[u'response', 'http_headers']

print json.dumps(resp['response'], indent=4)

    "@status": "ok", 
    "@xsi:noNamespaceSchemaLocation": "", 
    "@version": "1.2", 
    "@xmlns:xsd": "", 
    "@xmlns:xsi": "", 
    "searchResults": {
        "page": "1", 
        "pageSize": "3", 
        "totalItems": "211", 
        "searchResult": [
                "type": "artist", 
                "score": "2.898118", 
                "artist": {
                    "@id": "447", 
                    "name": "Pink Floyd", 
                    "sortName": "Pink Floyd", 
                    "url": "", 
                    "image": "", 
                    "popularity": "0.73"
                "type": "artist", 
                "score": "2.4674335", 
                "artist": {
                    "@id": "226", 
                    "name": "Pink", 
                    "sortName": "Pink", 
                    "url": "", 
                    "image": "", 
                    "popularity": "0.71"
                "type": "artist", 
                "score": "2.329452", 
                "artist": {
                    "@id": "7522", 
                    "name": "Pink Martini", 
                    "sortName": "Pink Martini", 
                    "url": "", 
                    "image": "", 
                    "popularity": "0.5"

>>> pprint(resp['http_headers'])
{'accept-ranges': 'bytes',
 'access-control-allow-origin': '*',
 'age': '0',
 'cache-control': 'private, max-age=60',
 'connection': 'Keep-Alive',
 'content-length': '1388',
 'content-location': '', #edited for README
 'content-type': 'text/xml; charset=utf-8',
 'date': 'Sat, 08 Sep 2012 18:44:11 GMT',
 'expires': 'Sat, 08 Sep 2012 18:45:11 GMT',
 'last-modified': 'Sat, 08 Sep 2012 18:44:06 GMT',
 'server': 'nginx/0.7.67',
 'set-cookie': ...', #edited for README
 'status': '200',
 'x-7dig': 'aw0',
 'x-aspnet-version': '4.0.30319',
 'x-cdn': 'Served by WebAcceleration',
 'x-ratelimit-current': '24',
 'x-ratelimit-limit': '4000',
 'x-ratelimit-reset': '18953'}
Something went wrong with that request. Please try again.