Skip to content
Go to file

Latest commit

Remove deprecated Artist.get_cover_image, User.get_artist_tracks and STATUS_TOKEN_ERROR

Git stats


Failed to load latest commit information.


PyPI version Supported Python versions PyPI downloads Build status Coverage (Codecov) Coverage (Coveralls) Code style: black DOI

A Python interface to and other API-compatible websites such as

Use the pydoc utility for help on usage or see tests/ for examples.


Install via pip:

pip install pylast

Install latest development version:

pip install -U git+

Or from requirements.txt:

-e git://


  • pyLast 4.0.0+ supports Python 3.6-3.9.
  • pyLast 3.2.0 - 3.3.0 supports Python 3.5-3.8.
  • pyLast 3.0.0 - 3.1.0 supports Python 3.5-3.7.
  • pyLast 2.2.0 - 2.4.0 supports Python 2.7.10+, 3.4-3.7.
  • pyLast 2.0.0 - 2.1.0 supports Python 2.7.10+, 3.4-3.6.
  • pyLast 1.7.0 - 1.9.0 supports Python 2.7, 3.3-3.6.
  • pyLast 1.0.0 - 1.6.0 supports Python 2.7, 3.3-3.4.
  • pyLast 0.5 supports Python 2, 3.
  • pyLast < 0.5 supports Python 2.


  • Simple public interface.
  • Access to all the data exposed by the web services.
  • Scrobbling support.
  • Full object-oriented design.
  • Proxy support.
  • Internal caching support for some web services calls (disabled by default).
  • Support for other API-compatible networks like

Getting started

Here's some simple code example to get you started. In order to create any object from pyLast, you need a Network object which represents a social music network that is or any other API-compatible one. You can obtain a pre-configured one for and use it as follows:

import pylast

# You have to have your own unique two values for API_KEY and API_SECRET
# Obtain yours from for
API_KEY = "b25b959554ed76058ac220b7b2e0a026"  # this is a sample key
API_SECRET = "425b55975eed76058ac220b7b4e8a054"

# In order to perform a write operation you need to authenticate yourself
username = "your_user_name"
password_hash = pylast.md5("your_password")

network = pylast.LastFMNetwork(api_key=API_KEY, api_secret=API_SECRET,
                               username=username, password_hash=password_hash)

# Now you can use that object everywhere
artist = network.get_artist("System of a Down")

track = network.get_track("Iron Maiden", "The Nomad")
track.add_tags(("awesome", "favorite"))

# Type help(pylast.LastFMNetwork) or help(pylast) in a Python interpreter
# to get more help about anything and see examples of how it works

More examples in hugovk/lastfm-tools and tests/.


The tests/ directory contains integration and unit tests with, and plenty of code examples.

For integration tests you need a test account at that will become cluttered with test data, and an API key and secret. Either copy example_test_pylast.yaml to test_pylast.yaml and fill out the credentials, or set them as environment variables like:


To run all unit and integration tests:

pip install pytest flaky

Or run just one test case:

pytest -k test_scrobble

To run with coverage:

pytest -v --cov pylast --cov-report term-missing
coverage report # for command-line report
coverage html   # for HTML report
open htmlcov/index.html


To enable from your own code:

import logging
import pylast


network = pylast.LastFMNetwork(...)

To enable from pytest:

pytest --log-cli-level debug -k test_album_search_images
You can’t perform that action at this time.