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 lastfm_api 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 lastfm_api.methods import (
    Album,
    Artist,
    Auth,
    Chart,
    Geo,
    Library,
    Tag,
    Track,
    User
)

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

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

from lastfm_api.params import (
    AlbumAddTags,
    AlbumGetInfo,
    AlbumGetTags,
    AlbumGetTopTags,
    AlbumRemoveTag,
    AlbumSearch
)
from lastfm_api.params import (
    ArtistAddTags,
    ArtistGetCorrection,
    ArtistGetInfo,
    ArtistGetSimilar,
    ArtistGetTags,
    ArtistGetTopAlbums,
    ArtistGetTopTags,
    ArtistGetTopTracks,
    ArtistRemoveTag,
    ArtistSearch
)
from lastfm_api.params import (
    AuthGetMobileSession,  # deprecated as last.fm
    AuthGetSession,
    AuthGetToken
)
from lastfm_api.params import (
    ChartGetTopArtists,
    ChartGetTopTags,
    ChartGetTopTracks
)
from lastfm_api.params import (
    GeoGetTopArtists,
    GeoGetTopTracks
)
from lastfm_api.params import (
    LibraryGetArtists
)
from lastfm_api.params import (
    TagGetInfo,
    TagGetSimilar,
    TagGetTopAlbums,
    TagGetTopArtists,
    TagGetTopTracks,
    TagGetWeeklyChartList
)
from lastfm_api.params import (
    TrackAddTags,
    TrackGetCorrection,
    TrackGetInfo,
    TrackGetSimilar,
    TrackGetTags,
    TrackGetTopTags,
    TrackLove,
    TrackRemoveTag,
    TrackScrobble,
    TrackSearch,
    TrackUnlove,
    TrackUpdateNowPlaying
)
from lastfm_api.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.0.tar.gz (12.0 kB view hashes)

Uploaded Source

Built Distribution

lastfmxpy-1.0.0-py3-none-any.whl (21.9 kB view hashes)

Uploaded Python 3

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