Skip to main content

Python client for the Last.fm API with a pythonic interface. Also includes an async variant of the client for Tornado.

Usage

Regular

from lastfmclient import LastfmClient

api = LastfmClient(
    api_key=KEY,
    api_secret=SECRET,
    session_key=session_key
)

resp = api.track.update_now_playing(
    track='Paranoid Android',
    artist='Radiohead',
    album='OK Computer',
)

print resp

Asynchronous (uses tornado.httpclient.AsyncHTTPClient)

import tornado.web
import tornado.gen
from lastfmclient.async import AsyncLastfmClient

class Scrobbler(tornado.web.RequestHandler):

    @tornado.gen.coroutine
    def post(self):
        api = AsyncLastfmClient(
            api_key=KEY,
            api_secret=SECRET,
            session_key=session_key
        )

        resp = yield api.track.update_now_playing(
            track='Paranoid Android',
            artist='Radiohead',
            album='OK Computer',
        )
        self.finish(resp)

See also examples.

Client methods

All the methods the Last.fm API provides are mirrored in the client with rich docstrings and arguments description. This code is actually generated directly from the online API documentation pages (see ./generate.py, ./api.json, and ./lastfmclient/api.py).

The defined methods be updated to the current version of the documentation via:

$ pip install -r requirements.txt lxml

# 1. Generate fresh api.json from docs at http://www.last.fm/api:
$ make spec

# 2. Generate `lastfm/api.py` from `api.json`:
$ make code

# Or, all the above in one step:
$ make

Contact

Jakub Roztočil

Metadata

Release files for lastfmclient 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lastfmclient 0.0.4
File Size Uploaded
lastfmclient-0.0.4.tar.gz 17.6 kB Details

Release files / lastfmclient-0.0.4.tar.gz

Download URL lastfmclient-0.0.4.tar.gz
Size 17.6 kB
Tags Source
SHA-256 checksum
How to use checksums
500b836582ec824f62899dccc4ed7b907860036c8b4b394effa2e9e35ec9eddf
BLAKE2b-256 checksum
How to use checksums
6fbc963b98fdbf261b6586788d66ce5e1a738f199da7d5bd84feac89b8756c2a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.0.4 This release

1 release file

0.0.3

1 release file

0.0.2

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page