Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Table of contents
This documentation provides examples of how to use the synchronous and asynchronous classes and methods, and shows all available methods and parameters
To install this library, you need to enter the following command
pip install -U lastfmxpy
In this example, we use the LastFMApi
class that we previously imported from the api
package,
and then use the post method in which we set the method we will use and the parameter
import json
from lastfmxpy import (
api,
methods,
params,
)
# Initialise our object through which we will interact with last.fm
client = 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 = client.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)
In this example, we use the AsyncLastFMApi
class, which we previously imported from the api
package 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 parameter
import asyncio
import json
from lastfmxpy import (
api,
methods,
params,
)
# Initialise our object through which we will interact with last.fm
client = 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 string
async def main():
# Calling the asynchronous method
response: str = await client.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
)
return data
print(asyncio.run(main()))
from lastfmxpy.methods import (
Album,
Artist,
Auth,
Chart,
Geo,
Library,
Tag,
Track,
User
)
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
)
lastfmxpy
is distributed under the terms of the MIT license.
FAQs
A tool that helps to work effectively with the API from last.fm
We found that lastfmxpy demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.