LastFM API Data Retrieval
Build the LastFmAPI class.
Use the class to pull recent tracks from Last FM, and include only those tracks above a certain playcount threshold.
LastFmAPI
LastFmAPI (region_name)
Provides an interface to the Last.fm API for retrieving top tracks for a user.
Type | Details | |
---|---|---|
region_name | str | The name of the AWS region where the secrets manager is located. |
LastFmAPI.get_secret
LastFmAPI.get_secret (secret_name)
Retrieves the specified secret from AWS Secrets Manager and sets the corresponding environment variables.
Type | Details | |
---|---|---|
secret_name | str | The name of the secret to retrieve. |
LastFmAPI.get_top_tracks
LastFmAPI.get_top_tracks (period='1month', playcount_cutoff=5)
Retrieves the top tracks for the user.
Type | Default | Details | |
---|---|---|---|
period | str | 1month | The time period for which to retrieve the top tracks. Default is ‘1month’. |
playcount_cutoff | int | 5 | The minimum number of plays required for a track to be included in the results. Default is 1. |
Returns | pandas.DataFrame | A DataFrame containing the top tracks for the user. The DataFrame has columns for the track name, artist name, and play count. |