Skip to main content

LastFmGet

PyPI Latest Release Tests Current Source Tests

LastFmGet is a Python package for accessing Last.fm scrobble data using the public API.

  • Provides functions for calling specific Last.fm API methods
  • Must use a cfg YAML file and call lastfmget.init() before use
  • Gets a response from the API in JSON and returns a Python dictionary
  • Examples of the response for each method shown in data/dump
  • Use _raw method verions for more direct access to the Last.fm API

Installation

pip install lastfmget

Dependencies

  • python3.10
  • requests
  • requests_cache (used only if configured in api_cfg.yaml)
  • pyyaml

Documentation

lastfmget

Usage

Import

import lastfmget

Config

lastfmget.init('api_cfg.yaml')

api_cfg.yaml example (data/example_api_cfg.yaml)

api_url: http://ws.audioscrobbler.com/2.0/
api_key: <API KEY>
user_agent: <USER AGENT>
call_rate: 5 # Calls per second
cache:
  enable: true
  dir: .cache
  backend: sqlite
  lifetime: 120 # Seconds
# or (defaults)
cache:
  enable: true
# or (disable)
cache:
  enable: false
Field Description
api_url API root URL, should be 'http://ws.audioscrobbler.com/2.0/'
api_key Your private API key. See here
user_agent Identifiable user agent for requests
call_rate Max API requests per second
cache enable: use requests_cache
dir: (optional) cache location
backend: (optional) sqlite recommended
lifetime: (optional) expire_after time in seconds

Code Examples

Getting user information using the user.getInfo method

>>> info = lastfmget.user_info('D3r3k523')
>>> info['playcount']
161602
>>> info['user']['url']
'https://www.last.fm/user/D3r3k523'

Getting a user's top 10 artists using the user.getTopArtists method

>>> topartists = lastfmget.user_top_artists('D3r3k523', 10)
>>> [ artist['name'] for artist in topartists ]
['Radiohead', 'Converge', 'Pink Floyd', 'Queens of the Stone Age', 'Bon Iver', 'Thee Oh Sees', 'Tame Impala', 'Arcade Fire', 'Beach House', 'Mastodon']

Example Projects

Last.fm API Methods Available

Function Last.fm API method
lastfmget.user_info user.getInfo
lastfmget.user_recent_tracks user.getRecentTracks
lastfmget.user_top_artists user.getTopArtists
lastfmget.user_top_albums user.getTopAlbums
lastfmget.user_top_tracks user.getTopTracks
lastfmget.user_weekly_chart_list user.getWeeklyChartList
lastfmget.user_weekly_artist_chart user.getWeeklyArtistChart
lastfmget.user_weekly_album_chart user.getWeeklyAlbumChart
lastfmget.user_weekly_track_chart user.getWeeklyTrackChart

Last.fm API Reference

Metadata

Release files for lastfmget 1.1.0

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

Source distribution (sdist)

Source distribution for lastfmget 1.1.0
File Size Uploaded Provenance Actions
lastfmget-1.1.0.tar.gz 8.2 kB Without provenance Details for lastfmget-1.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for lastfmget 1.1.0
File Interpreter ABI Platform Actions
lastfmget-1.1.0-py3-none-any.whl Python 3 none any Details for lastfmget-1.1.0-py3-none-any.whl

Total release size: 17.6 kB

Release files / lastfmget-1.1.0.tar.gz

Download URL lastfmget-1.1.0.tar.gz
Size 8.2 kB
Tags Source
SHA-256 checksum
How to use checksums
6d2f34e53a518dd42fd9339d8403ee8f98e1aad5ae7014d24faa41b026219e3a
BLAKE2b-256 checksum
How to use checksums
beb24bdcc113b9cbe3fa4c44fae91203d2aaa5d8c66023483cd2fb88cd17e994
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

Release files / lastfmget-1.1.0-py3-none-any.whl

Download URL lastfmget-1.1.0-py3-none-any.whl
Size 9.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
21de7640f0b5077fe92e399658d97cfe81ae722164aa2ddec71df8e6ad653858
BLAKE2b-256 checksum
How to use checksums
cb750604b4be8e5f194ae8abf8e527f8df0be607c12feb4fce6562a49fb6c3ab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

Security for lastfmget 1.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files No provenance

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