Title: | Get 'Spotify' API Multiple Information |
---|---|
Description: | 'DSpoty' R package allows you to retrieve 'Spotify' API Information such as artists, albums, tracks, features tracks, recommendations or related artists. This package allows you to search all the information by name and also includes a distance based algorithm to find similar songs. More information: <https://developer.spotify.com/documentation/web-api/> . |
Authors: | Alberto Almuiña <[email protected]> |
Maintainer: | Alberto Almuiña <[email protected]> |
License: | GPL-3 |
Version: | 0.1.0 |
Built: | 2024-11-02 03:42:07 UTC |
Source: | https://github.com/albertoalmuinha/dspoty |
This function returns the popularity of an album on Spotify.
get_album_popularity(album_uri, limit = 1, offset = 0, access_token = DSpoty::get_spotify_access_token())
get_album_popularity(album_uri, limit = 1, offset = 0, access_token = DSpoty::get_spotify_access_token())
album_uri |
An album uri from Spotify to search for or a group of albums uris separated by a comma |
limit |
Integer indicating the max number of artists to return. Defaults to 1, max of 50. |
offset |
Integer indicating the offset of the first artist to return. Defaults to 0 (Spotify's API default value). |
access_token |
Spotify Web API token. Defaults to DSpoty::get_spotify_access_token() |
Returns an integer vector with the popularity value (0-100).
Alberto Almui?a
## Not run: get_album_popularity('1T2uKSyUf7DBWOABtsmYLM') ## End(Not run)
## Not run: get_album_popularity('1T2uKSyUf7DBWOABtsmYLM') ## End(Not run)
This function searches spotify artists by name
get_artist(artist_name, offset = "0", limit = "1", access_token = DSpoty::get_spotify_access_token())
get_artist(artist_name, offset = "0", limit = "1", access_token = DSpoty::get_spotify_access_token())
artist_name |
String of artist name |
offset |
Integer indicating the offset of the first artist to return. Defaults to 0 (Spotify's API default value). |
limit |
Integer indicating the max number of artists to return. Defaults to 1, max of 50. |
access_token |
Spotify Web API token. Defaults to DSpoty::get_spotify_access_token() |
Returns a data frame with the artist's information
Alberto Almui?a
## Not run: get_artist('Arctic Monkeys') ## End(Not run)
## Not run: get_artist('Arctic Monkeys') ## End(Not run)
This function returns an artist's discography on Spotify.
get_artist_albums(artist_name, album_type = "album", limit = 50, offset = 0, access_token = DSpoty::get_spotify_access_token())
get_artist_albums(artist_name, album_type = "album", limit = 50, offset = 0, access_token = DSpoty::get_spotify_access_token())
artist_name |
String of artist name. |
album_type |
Character vector of album types to include. Valid values are "album", "single", "appears_on", and "compilation". Defaults to "album". |
limit |
Integer indicating the max number of artists to return. Defaults to 50, max of 50. |
offset |
Integer indicating the offset of the first artist to return. Defaults to 0 (Spotify's API default value). |
access_token |
Spotify Web API token. Defaults to DSpoty::get_spotify_access_token() |
Returns a data frame with all the albums of the selected artist
Alberto Almuiña
## Not run: albums <- get_artist_albums('radiohead') ## End(Not run)
## Not run: albums <- get_artist_albums('radiohead') ## End(Not run)
This function returns all the tracks of an artist.
get_artist_tracks(artist_name, limit = 50, offset = 0, access_token = DSpoty::get_spotify_access_token())
get_artist_tracks(artist_name, limit = 50, offset = 0, access_token = DSpoty::get_spotify_access_token())
artist_name |
String of artist name. |
limit |
Integer indicating the max number of artists to return. Defaults to 50, max of 50. |
offset |
Integer indicating the offset of the first artist to return. Defaults to 0 (Spotify's API default value). |
access_token |
Spotify Web API token. Defaults to DSpoty::get_spotify_access_token(). |
Returns a data frame with all the tracks of the selected artist.
Alberto Almui?a
## Not run: tracks <- get_artist_tracks('Shakira') ## End(Not run)
## Not run: tracks <- get_artist_tracks('Shakira') ## End(Not run)
This function returns audio features for all the tracks of a given artist
get_artist_tracks_features(artist_name, limit = 100, offset = 0, access_token = DSpoty::get_spotify_access_token())
get_artist_tracks_features(artist_name, limit = 100, offset = 0, access_token = DSpoty::get_spotify_access_token())
artist_name |
String of an artist name |
limit |
Integer indicating the max number of artists to return. Defaults to 100, max of 100. |
offset |
Integer indicating the offset of the first artist to return. Defaults to 0 (Spotify's API default value). |
access_token |
Spotify Web API token. Defaults to DSpoty::get_spotify_access_token() |
Returns a data frame with the tracks features for all the tracks of an artist
Alberto Almui?a
## Not run: tracks_features<-get_artist_tracks_features('Shakira') ## End(Not run)
## Not run: tracks_features<-get_artist_tracks_features('Shakira') ## End(Not run)
Function to search artists by genre
get_artists_by_genre(genre = is.character(), offset = "0", limit = "10", year = 2019, access_token = DSpoty::get_spotify_access_token())
get_artists_by_genre(genre = is.character(), offset = "0", limit = "10", year = 2019, access_token = DSpoty::get_spotify_access_token())
genre |
String of genre name to search for |
offset |
Integer indicating the offset of the first artist to return. Defaults to 0 (Spotify's API default value). |
limit |
Integer indicating the max number of artists to return. Defaults to 10, max of 50. |
year |
Year to search for |
access_token |
Spotify Web API token. Defaults to DSpoty::get_spotify_access_token() |
Returns a data frame with the artist's information of a determined genre
Alberto Almui?a
## Not run: rock_artists <- get_artists_by_genre("rock") ## End(Not run)
## Not run: rock_artists <- get_artists_by_genre("rock") ## End(Not run)
This function allows you to load several artists in a faster way.
get_several_artists(artist_ids_df, ids_label = 1, access_token = DSpoty::get_spotify_access_token())
get_several_artists(artist_ids_df, ids_label = 1, access_token = DSpoty::get_spotify_access_token())
artist_ids_df |
Dataframe containing the artists ids in one of the columns. |
ids_label |
Integer indicating the column number of the artists ids. Default to 1. |
access_token |
Spotify Web API token. Defaults to DSpoty::get_spotify_access_token() |
Returns a data frame with all the artist's information
Alberto Almui?a
## Not run: get_several_artists(df,1) ## End(Not run)
## Not run: get_several_artists(df,1) ## End(Not run)
This function allows you to load several tracks in a faster way.
get_several_tracks(tracks_id_df, ids_label = 1, access_token = DSpoty::get_spotify_access_token())
get_several_tracks(tracks_id_df, ids_label = 1, access_token = DSpoty::get_spotify_access_token())
tracks_id_df |
Dataframe containing the tracks ids in one of the columns. |
ids_label |
Integer indicating the column number of the tracks ids. Default to 1. |
access_token |
Spotify Web API token. Defaults to DSpoty::get_spotify_access_token() |
Returns a data frame with all the artist's information
Alberto Almui?a
## Not run: get_several_tracks(df,1) ## End(Not run)
## Not run: get_several_tracks(df,1) ## End(Not run)
This function allows you to load several tracks features in a faster way.
get_several_tracks_features(tracks_df, access_token = DSpoty::get_spotify_access_token())
get_several_tracks_features(tracks_df, access_token = DSpoty::get_spotify_access_token())
tracks_df |
Dataframe containing the tracks ids in the first column. |
access_token |
Spotify Web API token. Defaults to DSpoty::get_spotify_access_token(). |
Returns a data frame with all the tracks_features for the selected tracks uris.
Alberto Almui?a
## Not run: get_several_tracks_features(df) ## End(Not run)
## Not run: get_several_tracks_features(df) ## End(Not run)
This function allows you to load several tracks features really fast specially with a large amount of tracks. Improves the performance in comparision with get_several_tracks_features.
get_several_tracks_features_vectorized(tracks_df, access_token = DSpoty::get_spotify_access_token())
get_several_tracks_features_vectorized(tracks_df, access_token = DSpoty::get_spotify_access_token())
tracks_df |
Dataframe containing the tracks ids in the first column. |
access_token |
Spotify Web API token. Defaults to DSpoty::get_spotify_access_token(). |
Returns a data frame with all the tracks_features for the selected tracks uris.
Alberto Almui?a
## Not run: get_several_tracks_features_vectorized(df) ## End(Not run)
## Not run: get_several_tracks_features_vectorized(df) ## End(Not run)
This function returns the Spotify's access token.
get_spotify_access_token(client_id = Sys.getenv("client_id"), client_secret = Sys.getenv("client_secret"))
get_spotify_access_token(client_id = Sys.getenv("client_id"), client_secret = Sys.getenv("client_secret"))
client_id |
String with the Spotify CLIENT_ID. |
client_secret |
String with the Spotify CLIENT_SECRET. |
Returns a string with de access token.
Alberto Almui?a
## Not run: access_token<-get_spotify_access_token(client_id = 'client_id', client_secret = 'client_secret') ## End(Not run)
## Not run: access_token<-get_spotify_access_token(client_id = 'client_id', client_secret = 'client_secret') ## End(Not run)
This function searches spotify item by name
get_spotify_item(name = NULL, type, limit = 1, offset = 0, access_token = DSpoty::get_spotify_access_token(), artist = NULL, album = NULL)
get_spotify_item(name = NULL, type, limit = 1, offset = 0, access_token = DSpoty::get_spotify_access_token(), artist = NULL, album = NULL)
name |
String of item name (artist, album, track...). Default: NULL |
type |
String of the search type. Possible values are 'artist', 'album' and 'track'. |
limit |
Integer indicating the max number of artists to return. Defaults to 1, max of 50. |
offset |
Integer indicating the offset of the first artist to return. Defaults to 0 (Spotify's API default value). |
access_token |
Spotify Web API token. Defaults to DSpoty::get_spotify_access_token() |
artist |
String of album's artist name. Default: NULL |
album |
String of album name. Default: NULL |
You have two options to use this function: Search by parameter name or search by parameters artist + album. In this second case, type must always be 'album'.
Returns a data frame with the item's information
Alberto Almuiña
## Not run: get_spotify_item(name = 'Arctic Monkeys', type = 'artist') get_spotify_item(artist = 'Leiva', album = 'Nuclear', type = 'album') get_spotify_item(name = 'Do I Wanna Know?', type = 'track') ## End(Not run)
## Not run: get_spotify_item(name = 'Arctic Monkeys', type = 'artist') get_spotify_item(artist = 'Leiva', album = 'Nuclear', type = 'album') get_spotify_item(name = 'Do I Wanna Know?', type = 'track') ## End(Not run)
This function that returns the popularity of a track uri on Spotify.
get_track_popularity(track_uri, limit = 1, offset = 0, access_token = DSpoty::get_spotify_access_token())
get_track_popularity(track_uri, limit = 1, offset = 0, access_token = DSpoty::get_spotify_access_token())
track_uri |
A track uri corresponding to one track in Spotify. |
limit |
Integer indicating the max number of artists to return. Defaults to 1, max of 50. |
offset |
Integer indicating the offset of the first artist to return. Defaults to 0 (Spotify's API default value). |
access_token |
Spotify Web API token. Defaults to DSpoty::get_spotify_access_token(). |
Returns an integer vector with the popularity value (0-100).
Alberto Almui?a
## Not run: popularity <- get_track_popularity('0FgNSsaSZTvbLXUumSO8LQ') ## End(Not run)
## Not run: popularity <- get_track_popularity('0FgNSsaSZTvbLXUumSO8LQ') ## End(Not run)
This function returns the recommendend songs by Spotify.
get_tracks_recommendations(artist_uri, track_uri, limit = 10, access_token = DSpoty::get_spotify_access_token())
get_tracks_recommendations(artist_uri, track_uri, limit = 10, access_token = DSpoty::get_spotify_access_token())
artist_uri |
Artist ID. |
track_uri |
Track ID. |
limit |
Integer indicating the max number of artists to return. Default 10. |
access_token |
Spotify Web API token. Defaults to DSpoty::get_spotify_access_token(). |
Returns a data frame with the recommended artists information.
Alberto Almui?a
## Not run: get_tracks_recommendations('7Ln80lUS6He07XvHI8qqHH', '0FgNSsaSZTvbLXUumSO8LQ') ## End(Not run)
## Not run: get_tracks_recommendations('7Ln80lUS6He07XvHI8qqHH', '0FgNSsaSZTvbLXUumSO8LQ') ## End(Not run)
This function returns the recommendend songs by Spotify.
get_tracks_recommendations_by_name(artist_name, track_name, limit = 10, access_token = DSpoty::get_spotify_access_token())
get_tracks_recommendations_by_name(artist_name, track_name, limit = 10, access_token = DSpoty::get_spotify_access_token())
artist_name |
Artist Name character. |
track_name |
Track Name character. |
limit |
Integer indicating the max number of artists to return. Default 10. |
access_token |
Spotify Web API token. Defaults to DSpoty::get_spotify_access_token(). |
Returns a data frame with the recommended songs information.
Alberto Almui?a
## Not run: get_tracks_recommendations_by_name('Arctic Monkeys', 'Do I wanna know?') ## End(Not run)
## Not run: get_tracks_recommendations_by_name('Arctic Monkeys', 'Do I wanna know?') ## End(Not run)