Skip to main content

A tool that helps to work effectively with the API from last.fm

Project description

Last FM API (lastfmxpy)

Static Badge GitHub License GitHub issues GitHub commit activity (branch) GitHub contributors


  • lastfmxpy (Last FM Api) - is a mono-repository that has a user-friendly interface for interacting with the largest music service last.fm. This library implements all the standard methods available on this page.

Table of contents

Project goals

  • Implement all existing methods in the Last FM API Docs
  • Provide a convenient interface for sending requests to the server
  • Add doc-strings to each method or class
  • Add support for documentation in different languages
  • Add asynchronous support

Documentation

Installation: To install this library, you need to enter the following command

pip install -U lastfmxpy

Usage:

import json

from lastfmxpy import (
    api,
    methods,
    params,
)

# Initialise our object through which we will interact with last.fm
api = api.LastFMApi(
    api_key="...", # Get here https://www.last.fm/api/account/create,
    shared_secret="..." # Also get here ( ̄︶ ̄)↗ 
)

# Get all information about the artist in JSON as a string 
response: str = api.post(
    
    # Specify which method we will use
    method=methods.User.GET_INFO,
    
    # Let us specify our parameters
    params=params.UserGetInfo(
        user="pkeorley"
    ),
    
    # We can also specify additional parameters
    additional_params=dict(format="json")

)

# Let's show our data in a convenient form on the screen
data: str = json.dumps(
    json.loads(response),
    indent=4,
    ensure_ascii=False
)

print(data)

All available methods (./methods/__init__.py)

from lastfmxpy.methods import (
    Album,
    Artist,
    Auth,
    Chart,
    Geo,
    Library,
    Tag,
    Track,
    User
)

All available parameters (./params/__init__.py):

from lastfmxpy.params import (
    AlbumAddTags,
    AlbumGetInfo,
    AlbumGetTags,
    AlbumGetTopTags,
    AlbumRemoveTag,
    AlbumSearch
)

from lastfmxpy.params import (
    AlbumAddTags,
    AlbumGetInfo,
    AlbumGetTags,
    AlbumGetTopTags,
    AlbumRemoveTag,
    AlbumSearch
)
from lastfmxpy.params import (
    ArtistAddTags,
    ArtistGetCorrection,
    ArtistGetInfo,
    ArtistGetSimilar,
    ArtistGetTags,
    ArtistGetTopAlbums,
    ArtistGetTopTags,
    ArtistGetTopTracks,
    ArtistRemoveTag,
    ArtistSearch
)
from lastfmxpy.params import (
    AuthGetMobileSession,  # deprecated as last.fm
    AuthGetSession,
    AuthGetToken
)
from lastfmxpy.params import (
    ChartGetTopArtists,
    ChartGetTopTags,
    ChartGetTopTracks
)
from lastfmxpy.params import (
    GeoGetTopArtists,
    GeoGetTopTracks
)
from lastfmxpy.params import (
    LibraryGetArtists
)
from lastfmxpy.params import (
    TagGetInfo,
    TagGetSimilar,
    TagGetTopAlbums,
    TagGetTopArtists,
    TagGetTopTracks,
    TagGetWeeklyChartList
)
from lastfmxpy.params import (
    TrackAddTags,
    TrackGetCorrection,
    TrackGetInfo,
    TrackGetSimilar,
    TrackGetTags,
    TrackGetTopTags,
    TrackLove,
    TrackRemoveTag,
    TrackScrobble,
    TrackSearch,
    TrackUnlove,
    TrackUpdateNowPlaying
)
from lastfmxpy.params import (
    UserGetFriends,
    UserGetInfo,
    UserGetLovedTracks,
    UserGetPersonalTags,
    UserGetRecentTracks,
    UserGetTopAlbums,
    UserGetTopArtists,
    UserGetTopTags,
    UserGetTopTracks,
    UserGetWeeklyAlbumChart,
    UserGetWeeklyArtistChart,
    UserGetWeeklyChartList,
    UserGetWeeklyTrackChart
)

License

lastfmxpy is distributed under the terms of the MIT license.

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

lastfmxpy-1.0.1.tar.gz (15.7 kB view details)

Uploaded Source

Built Distribution

lastfmxpy-1.0.1-py3-none-any.whl (26.2 kB view details)

Uploaded Python 3

File details

Details for the file lastfmxpy-1.0.1.tar.gz.

File metadata

  • Download URL: lastfmxpy-1.0.1.tar.gz
  • Upload date:
  • Size: 15.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for lastfmxpy-1.0.1.tar.gz
Algorithm Hash digest
SHA256 de116a29e29f6c9525d6fe3055322d00d88c83c6cb249ea351eb79812d8ad571
MD5 74d1dcfda0aca1a8caf6b50e0d628f3c
BLAKE2b-256 6637d9998a63eb5281b7e9f87f9d95fab886bc61f31ab33332edcc9bd4cf49dd

See more details on using hashes here.

File details

Details for the file lastfmxpy-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: lastfmxpy-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 26.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for lastfmxpy-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7a61757178a138d4131a63f05743c1b9d35382200cbe0eec1360d640e324afbe
MD5 84aab2cce44c151daba3da4751700e63
BLAKE2b-256 6d33db79c83fda0b14871225adc5daa0e793ecab057978eca018605ec48e73e4

See more details on using hashes here.

Supported by

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