Package: lastfmxpy
Last FM API (lastfmxpy)lastfmxpy(Last FM Api)- is a mono-repository that has a user-friendly interface for interacting with the largest music servicelast.fm. This library implements all the standard methods available onthis page.Table of contentsProject goalsDocumentationInstallationSynchronous usageAsynchronous usageAll available methodsAll available parametersLicenceProject goalsImplement all existing methods in theLast FM API DocsProvide a convenient interface for sending requests to the serverAdd doc-strings to each method or classAdd asynchronous supportAdd testsAdd support for documentation in different languagesDocumentationThis documentation provides examples of how to use thesynchronousandasynchronousclasses and methods,
and shows all availablemethodsandparametersInstallationTo install this library, you need to enter the following commandpipinstall-UlastfmxpyExample of SYNCHRONOUS usageIn this example, we use theLastFMApiclass that we previously imported from theapipackage,
and then use the post method in which we set the method we will use and the parameterimportjsonfromlastfmxpyimport(api,methods,params,)# Initialise our object through which we will interact with last.fmclient=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 stringresponse:str=client.post(# Specify which method we will usemethod=methods.User.GET_INFO,# Let us specify our parametersparams=params.UserGetInfo(user="pkeorley"),# We can also specify additional parametersadditional_params=dict(format="json"))# Let's show our data in a convenient form on the screendata:str=json.dumps(json.loads(response),indent=4,ensure_ascii=False)print(data)Example of ASYNCHRONOUS usageIn this example, we use theAsyncLastFMApiclass, which we previously imported from theapipackage in the same way as in the case of the previous class, and then use
the post method in which we set the method we will use and the parameterimportasyncioimportjsonfromlastfmxpyimport(api,methods,params,)# Initialise our object through which we will interact with last.fmclient=api.AsyncLastFMApi(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 stringasyncdefmain():# Calling the asynchronous methodresponse:str=awaitclient.post(# Specify which method we will usemethod=methods.User.GET_INFO,# Let us specify our parametersparams=params.UserGetInfo(user="pkeorley"),# We can also specify additional parametersadditional_params=dict(format="json"))# Let's show our data in a convenient form on the screendata:str=json.dumps(json.loads(response),indent=4,ensure_ascii=False)returndataprint(asyncio.run(main()))All available methods:fromlastfmxpy.methodsimport(Album,Artist,Auth,Chart,Geo,Library,Tag,Track,User)All available parameters:fromlastfmxpy.paramsimport(AlbumAddTags,AlbumGetInfo,AlbumGetTags,AlbumGetTopTags,AlbumRemoveTag,AlbumSearch)fromlastfmxpy.paramsimport(AlbumAddTags,AlbumGetInfo,AlbumGetTags,AlbumGetTopTags,AlbumRemoveTag,AlbumSearch)fromlastfmxpy.paramsimport(ArtistAddTags,ArtistGetCorrection,ArtistGetInfo,ArtistGetSimilar,ArtistGetTags,ArtistGetTopAlbums,ArtistGetTopTags,ArtistGetTopTracks,ArtistRemoveTag,ArtistSearch)fromlastfmxpy.paramsimport(AuthGetMobileSession,# deprecated as last.fmAuthGetSession,AuthGetToken)fromlastfmxpy.paramsimport(ChartGetTopArtists,ChartGetTopTags,ChartGetTopTracks)fromlastfmxpy.paramsimport(GeoGetTopArtists,GeoGetTopTracks)fromlastfmxpy.paramsimport(LibraryGetArtists)fromlastfmxpy.paramsimport(TagGetInfo,TagGetSimilar,TagGetTopAlbums,TagGetTopArtists,TagGetTopTracks,TagGetWeeklyChartList)fromlastfmxpy.paramsimport(TrackAddTags,TrackGetCorrection,TrackGetInfo,TrackGetSimilar,TrackGetTags,TrackGetTopTags,TrackLove,TrackRemoveTag,TrackScrobble,TrackSearch,TrackUnlove,TrackUpdateNowPlaying)fromlastfmxpy.paramsimport(UserGetFriends,UserGetInfo,UserGetLovedTracks,UserGetPersonalTags,UserGetRecentTracks,UserGetTopAlbums,UserGetTopArtists,UserGetTopTags,UserGetTopTracks,UserGetWeeklyAlbumChart,UserGetWeeklyArtistChart,UserGetWeeklyChartList,UserGetWeeklyTrackChart)Licenselastfmxpyis distributed under the terms of theMITlicense.