Skip to main content

An API library to interact with the LastFM API written in Python

Project description

pylastfmapi

CI Documentation Status

This package provides an interface to interact with the LastFM API. It includes methods to retrieve various types of data from albums, artists, tracks, tags, users, LastFM charts, and user charts.

Read the docs here.

Installation

To install the package, use the following command:

pip install pylastfmapi

Basic usage

Get an API key

First of all, you need to get an API key from LastFM official website. For this, you will need a LastFM account here. With your user profile, create an API account here; you only need the contact email and application name and an API key will be given to you.

Go to Python script

To interact with the LastFM API you can simply import pylastfmapi and create a LastFM client object with your username as USER_AGENT and the API key from the previous step as API_KEY:

from pylastfmapi.client import LastFM

# Your LastFM API credentials
USER_AGENT = 'user-agent'
API_KEY = 'api-key'

# Initialize the LastFM client with your USER_AGENT and API_KEY
client = LastFM(USER_AGENT, API_KEY)

# Fetch information about a specific artist
artist_info = client.get_artist_info(artist="Miley Cyrus")
print(artist_info)
# {'name': 'Miley Cyrus', 'mbid': '7e9bd05a-117f-4cce-8...

Error Handling

The package raises LastFMException for various error conditions such as invalid parameters or request limits. Handle these exceptions to ensure your application can gracefully manage errors.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pylastfmapi-0.1.0.tar.gz (17.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pylastfmapi-0.1.0-py3-none-any.whl (17.9 kB view details)

Uploaded Python 3

File details

Details for the file pylastfmapi-0.1.0.tar.gz.

File metadata

  • Download URL: pylastfmapi-0.1.0.tar.gz
  • Upload date:
  • Size: 17.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.4 Linux/6.10.3-200.fc40.x86_64

File hashes

Hashes for pylastfmapi-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8db851ecba6bcc7de90f7cd5e134567c524b73f8197925c66152bd5b01d1f483
MD5 e25b149fb1382e8333335c2a9af0df37
BLAKE2b-256 8ae50d493f0c9e60371aaf187f9013ee22f284d239a0b0d51e82e6776e87293c

See more details on using hashes here.

File details

Details for the file pylastfmapi-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pylastfmapi-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 17.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.4 Linux/6.10.3-200.fc40.x86_64

File hashes

Hashes for pylastfmapi-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 19c438c8c6fcbbabf80fbc178d2430e3e99e26899569caceae55f28ed91d0a23
MD5 06665edd4b8eb41e77eedb1ee0ba5beb
BLAKE2b-256 38b9931317de1fc5252dec073602e2dd3a490b0d0dec1f41af2b8f44657273a4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page