pydrag is a modern api wrapper for the api with a fluent syntax!

Quick Start

Apply for a api key and write down your key and secret.


$ pip install pydrag


>>> from pydrag import User, configure
>>> configure(api_key='54062d8af7afdc_not_real_3459048a4')
>>> rj = User.find("RJ")
>>> rj.real_name
'Richard Jones '
>>> recent = rj.get_recent_tracks(limit=1, page=1)
>>> first = recent.pop()
>>> similar = first.get_similar(limit=1)
>>> similar[0].name
'Family Business'
>>> similar[0]
>>> for friend in rj.get_friends(recent_tracks=True):
('meichi', 'Pi')
('demkod', '(bottle back)')
('STBKilla', 'Nowhere Fast')
('keret221', 'Letter Home')
('Lilfix', 'Namorar pra Quê?')
('Yoji', 'Empire State of Mind (feat. Alicia Keys)')
('Kastishka', 'Wipe Your Eyes')
('comingsoon_', 'I Want It All')
('Bagheera', 'Welcome Home')


Use you favorite tool to create a python >= 3.6 virtual environment

$ git clone
$ pip install .[dev]
$ pre-commit install
$ pytest
$ tox

pydrag uses vcrpy library to record and replay responses for its unit tests and python-dotenv to auto-configure itself.

All sensitive information like keys and credentials are automatically censored.

So when it’s necessary to record a new response it’s super useful to have a .env file with your configuration!


Advanced example

For write operations you need to be authenticated. has multiple ways to authenticate users the most simple is to provide your full credentials.

Find a track by artist and name, retrieve the album, add some user tags and love the Back in Black

>>> import pydrag

>>> pydrag.configure("<api_key>", "<api_secret>", "<username>", "<password>")
lets say it worked
>>> track = pydrag.Track.find(artist="AC / DC", track="Hells Bell")
>>> album = track.album
>>> album.to_dict()
{'attr': {'position': 1}, 'name': 'Back in Black', 'mbid': '38914b29-7788-4cff-80b7-1ced523f8675', 'url': '', 'image': [{'size'
: 'small', 'text': ''}, {'size': 'medium', 'text': '
359b955132742bc2fc3eacdff90b8c.png'}, {'size': 'large', 'text': ''}, {'size': 'extralarge', 'te
xt': ''}], 'artist': {'name': 'AC/DC'}}
>>> full_album_info = track.album.get_info()
>>> full_album_info.add_tags(["awesome", "love"])
>>> back_in_black = next(track for track in full_album_info.tracks if == "Back in Black")
>>> write_op = back_in_black.get_info().love()
>>> write_op.params
{'method': '', 'artist': 'AC/DC', 'track': 'Back in Black'}

Indices and tables