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 details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: lastfmxpy-1.0.0.tar.gz
  • Upload date:
  • Size: 12.0 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.0.tar.gz
Algorithm Hash digest
SHA256 90da8ecd6092c3cb97dbdea576379ad5740185e68a3f1b44199dd874b9e5f38f
MD5 b206110628f3dbd731818280d1fdd577
BLAKE2b-256 95ff79d099b77c99b273562e2964d4461d236a6ff2fdd07284ca222100dcc773

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lastfmxpy-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 21.9 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 87b23bcc26847171c672803a20ce3ad188693cb7d81abc612d1bcd2fbcd41f21
MD5 93d18c47ada2ea54d11d3e7b0e33b505
BLAKE2b-256 a7e1f1950daec9452c498383eabed77da9439879e7f4242f290fd451ee6eb68c

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