Last.fm API for retrieving scrobbling data.
Project description
LastFmGet
Python package for accessing Last.fm scrobble data using the public API.
Installation
pip install lastfmget
Dependencies
- requests
- requests_cache (used only if set in api_cfg.yaml)
- pyyaml
Usage
Import
import lastfmget
Config
lastfmget.init('api_cfg.yaml')
api_cfg.yaml example
api_url: http://ws.audioscrobbler.com/2.0/
api_key: <API KEY>
user_agent: <USER AGENT>
use_cache: true # true, false
call_rate: 5 # Calls per second
Field | Description |
---|---|
api_url | API root URL, should not be changed |
api_key | Your private API key. See here |
user_agent | Identifiable user agent for requests |
use_cache | Use the functionality from requests_cache |
call_rate | Max API requests per second |
Examples
Getting user information using the user.getInfo method
>>> info = lastfmget.user_info('D3r3k523')
>>> info['user']['playcount']
'159635'
>>> 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['topartists']['artist'] ]
['Radiohead', 'Converge', 'Pink Floyd', 'Queens of the Stone Age', 'Bon Iver', 'Thee Oh Sees', 'Tame Impala', 'Arcade Fire', 'Mastodon', 'Beach House']
Example projects
Details
- Provides functions for calling a specific Last.fm API method
- Gets a response from the API in JSON and returns a Python dictionary
- Must use a cfg YAML file and call lastfmget.init() before any API calls
- Data is stored as strings
- Errors:
Last.fm API methods available
- user.getInfo
- user.getRecentTracks
- user.getTopArtists
- user.getTopAlbums
- user.getTopTracks
- user.getWeeklyChartList
- user.getWeeklyArtistsChart
- user.getWeeklyAlbumsChart
- user.getWeeklyTracksChart
Tips
- Use pprint on a response to see how the data is structured
Last.fm API Reference
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
lastfmget-0.1.1.tar.gz
(4.6 kB
view hashes)
Built Distribution
Close
Hashes for lastfmget-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d0d6b14bf27bede0312fdcf0f25a914784c102a90715eb52dceb00f91d6c783b |
|
MD5 | 3fbdaa47f9165462e510e3e5cb5c1fe6 |
|
BLAKE2b-256 | 5e9e618f8fec20f3878972c8a93049accbdae232bb78106a2686cae52aae1cf8 |