Science Score: 49.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
✓DOI references
Found 3 DOI reference(s) in README -
✓Academic publication links
Links to: zenodo.org -
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (18.6%) to scientific vocabulary
Keywords
Repository
R wrapper for Spotify's Web API
Basic Info
- Host: GitHub
- Owner: charlie86
- License: other
- Language: R
- Default Branch: master
- Homepage: http://www.rcharlie.com/spotifyr
- Size: 4.34 MB
Statistics
- Stars: 377
- Watchers: 16
- Forks: 69
- Open Issues: 45
- Releases: 4
Topics
Metadata Files
README.md
spotifyr
Overview
spotifyr is an R wrapper for pulling track audio features and other information from Spotify’s Web API in bulk. By automatically batching API requests, it allows you to enter an artist’s name and retrieve their entire discography in seconds, along with Spotify’s audio features and track/album popularity metrics. You can also pull song and playlist information for a given Spotify User (including yourself!).
Installation
CRAN version 2.2.3 (recommended)
r
install.packages('spotifyr')
Development version
r
devtools::install_github('charlie86/spotifyr')
Authentication
First, set up a Dev account with Spotify to access their Web API
here.
This will give you your Client ID and Client Secret. Once you have
those, you can pull your access token into R with
get_spotify_access_token().
The easiest way to authenticate is to set your credentials to the System
Environment variables SPOTIFY_CLIENT_ID and SPOTIFY_CLIENT_SECRET.
The default arguments to get_spotify_access_token() (and all other
functions in this package) will refer to those. Alternatively, you can
set them manually and make sure to explicitly refer to your access token
in each subsequent function call.
``` r Sys.setenv(SPOTIFYCLIENTID = 'xxxxxxxxxxxxxxxxxxxxx') Sys.setenv(SPOTIFYCLIENTSECRET = 'xxxxxxxxxxxxxxxxxxxxx')
accesstoken <- getspotifyaccesstoken() ```
Authorization Code Flow
For certain functions and applications, you’ll need to log in as a
Spotify user. To do this, your Spotify Developer application needs to
have a callback url. You can set this to whatever you want that will
work with your application, but a good default option is
http://localhost:1410/ (see image below). For more information on
authorization, visit the offical Spotify Developer
Guide.

Usage
What Was the Beatles’ Favorite Key?
r
library(spotifyr)
beatles <- get_artist_audio_features('the beatles')
``` r library(dplyr) library(purrr) library(knitr)
beatles %>% count(key_mode, sort = TRUE) %>% head(5) %>% kable() ```
| key_mode | n | |:----------|----:| | D major | 115 | | C major | 111 | | G major | 90 | | A major | 80 | | E major | 68 |
Get your most recently played tracks
``` r library(lubridate)
> Warning: package 'lubridate' was built under R version 4.1.1
getmyrecentlyplayed(limit = 5) %>% mutate( artist.name = mapchr(track.artists, function(x) x$name[1]), playedat = asdatetime(playedat) ) %>% select( allof(c("track.name", "artist.name", "track.album.name", "played_at")) ) %>% kable() ```
| track.name | artist.name | track.album.name | played_at | |:-----------------------------|:------------|:---------------------------------------------------------------------------------------------------|:--------------------| | Look For Me (I’ll Be Around) | Neko Case | Blacklisted | 2021-11-01 17:16:12 | | Don’t Forget Me | Neko Case | Middle Cyclone | 2021-11-01 17:12:50 | | Magpie to the Morning | Neko Case | The Worse Things Get, The Harder I Fight, The Harder I Fight, The More I Love You (Deluxe Edition) | 2021-11-01 17:09:42 | | Margaret vs. Pauline | Neko Case | Fox Confessor Brings The Flood (Bonus Track Version) | 2021-11-01 17:06:45 | | Runnin’ Out Of Fools | Neko Case | Blacklisted | 2021-11-01 17:03:52 |
Find Your All Time Favorite Artists
r
get_my_top_artists_or_tracks(type = 'artists',
time_range = 'long_term',
limit = 5) %>%
select(.data$name, .data$genres) %>%
rowwise %>%
mutate(genres = paste(.data$genres, collapse = ', ')) %>%
ungroup %>%
kable()
| name | genres | |:--------------------|:------------------------------------------------------| | Japanese Breakfast | art pop, eugene indie, indie pop, philly indie | | Balthazar | belgian indie, belgian rock, dutch indie, ghent indie | | Haley Bonar | melancholia, stomp and holler | | Angus & Julia Stone | australian indie folk, indie folk, stomp and holler | | Buildings Breeding | indie fuzzpop |
Find your favorite tracks at the moment
r
get_my_top_artists_or_tracks(type = 'tracks',
time_range = 'short_term',
limit = 5) %>%
mutate(
artist.name = map_chr(artists, function(x) x$name[1])
) %>%
select(name, artist.name, album.name) %>%
kable()
| name | artist.name | album.name | |:-------------------------------------|:--------------|:---------------------------------| | Can’t Walk That Back | Tristen | Can’t Walk That Back | | You’re Too Weird | Fruit Bats | Tripper | | California (All the Way) | Luna | Bewitched | | Don’t Blame Your Daughter (Diamonds) | The Cardigans | Super Extra Gravity (Remastered) | | Born In The ’70s | Fruit Bats | Spelled In Bones |
What’s the most joyful Joy Division song?
My favorite audio feature has to be “valence,” a measure of musical positivity.
r
joy <- get_artist_audio_features('joy division')
r
joy %>%
arrange(-valence) %>%
select(.data$track_name, .data$valence) %>%
head(5) %>%
kable()
| track_name | valence | |:------------------------------------------|--------:| | Passover - 2020 Digital Master | 0.946 | | Passover - 2007 Remaster | 0.941 | | Colony - 2020 Digital Master | 0.829 | | Colony - 2007 Remaster | 0.808 | | Atrocity Exhibition - 2020 Digital Master | 0.790 |
Now if only there was some way to plot joy…
Joyplot of the emotional rollercoasters that are Joy Division’s albums
``` r library(ggplot2) library(ggridges)
ggplot( joy, aes(x = valence, y = albumname) ) + geomdensityridges() + themeridges() + labs(title = "Joyplot of Joy Division's joy distributions", subtitle = "Based on valence pulled from Spotify's Web API with spotifyr") ```

Dope Stuff Other People Have Done with spotifyr
The coolest thing about making this package has definitely been seeing all the awesome stuff other people have done with it. Here are a few examples:
Exploring the Spotify API with R: A tutorial for beginners, by a beginner, Mia Smith
Blue Christmas: A data-driven search for the most depressing Christmas song, Caitlin Hudon
Sente-se triste quando ouve “Amar pelos dois”? Não é o único (Do you feel sad when you hear “Love for both?” You’re not alone), Rui Barros, Rádio Renascença
Using Data to Find the Angriest Death Grips Song, Evan Oppenheimer
Hierarchical clustering of David Bowie records, Alyssa Goldberg
tayloR, Simran Vatsa
Code of Conduct
Please note that the spotifyr project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.
CodeMeta (codemeta.json)
{
"@context": "https://doi.org/10.5063/schema/codemeta-2.0",
"@type": "SoftwareSourceCode",
"identifier": "spotifyr",
"description": "An R wrapper for pulling data from the 'Spotify' Web API <https://developer.spotify.com/documentation/web-api/> in bulk, or post items on a 'Spotify' user's playlist.",
"name": "spotifyr: R Wrapper for the 'Spotify' Web API",
"codeRepository": "https://github.com/charlie86/spotifyr",
"issueTracker": "https://github.com/charlie86/spotifyr/issues",
"license": "https://spdx.org/licenses/MIT",
"version": "2.2.5",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
"url": "https://r-project.org"
},
"runtimePlatform": "R version 4.4.0 (2024-04-24 ucrt)",
"author": [
{
"@type": "Person",
"givenName": "Charlie",
"familyName": "Thompson",
"email": "chuck@rcharlie.com"
},
{
"@type": "Person",
"givenName": "Daniel",
"familyName": "Antal",
"email": "daniel.antal@dataobservatory.eu",
"@id": "https://orcid.org/0000-0001-7513-6760"
},
{
"@type": "Person",
"givenName": "Josiah",
"familyName": "Parry",
"email": "josiah.parry@yahoo.com",
"@id": "https://orcid.org/0000-0001-9910-865X"
},
{
"@type": "Person",
"givenName": "Donal",
"familyName": "Phipps",
"email": "donal.phipps@gmail.com"
},
{
"@type": "Person",
"givenName": "Tom",
"familyName": "Wolff",
"email": "tom.wolff@duke.edu"
}
],
"contributor": [
{
"@type": "Person",
"givenName": "Stephen",
"familyName": "Holsenbeck"
},
{
"@type": "Person",
"givenName": "Peter",
"familyName": "Harrison"
}
],
"maintainer": [
{
"@type": "Person",
"givenName": "Daniel",
"familyName": "Antal",
"email": "daniel.antal@dataobservatory.eu",
"@id": "https://orcid.org/0000-0001-7513-6760"
}
],
"softwareSuggestions": [
{
"@type": "SoftwareApplication",
"identifier": "ggridges",
"name": "ggridges",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=ggridges"
},
{
"@type": "SoftwareApplication",
"identifier": "spelling",
"name": "spelling",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=spelling"
},
{
"@type": "SoftwareApplication",
"identifier": "testthat",
"name": "testthat",
"version": ">= 3.0.0",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=testthat"
}
],
"softwareRequirements": {
"1": {
"@type": "SoftwareApplication",
"identifier": "R",
"name": "R",
"version": ">= 3.3.0"
},
"2": {
"@type": "SoftwareApplication",
"identifier": "dplyr",
"name": "dplyr",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=dplyr"
},
"3": {
"@type": "SoftwareApplication",
"identifier": "purrr",
"name": "purrr",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=purrr"
},
"4": {
"@type": "SoftwareApplication",
"identifier": "httr",
"name": "httr",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=httr"
},
"5": {
"@type": "SoftwareApplication",
"identifier": "lubridate",
"name": "lubridate",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=lubridate"
},
"6": {
"@type": "SoftwareApplication",
"identifier": "jsonlite",
"name": "jsonlite",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=jsonlite"
},
"7": {
"@type": "SoftwareApplication",
"identifier": "readr",
"name": "readr",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=readr"
},
"8": {
"@type": "SoftwareApplication",
"identifier": "rvest",
"name": "rvest",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=rvest"
},
"9": {
"@type": "SoftwareApplication",
"identifier": "stringr",
"name": "stringr",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=stringr"
},
"10": {
"@type": "SoftwareApplication",
"identifier": "tibble",
"name": "tibble",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=tibble"
},
"11": {
"@type": "SoftwareApplication",
"identifier": "janitor",
"name": "janitor",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=janitor"
},
"12": {
"@type": "SoftwareApplication",
"identifier": "rlang",
"name": "rlang",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=rlang"
},
"13": {
"@type": "SoftwareApplication",
"identifier": "magrittr",
"name": "magrittr",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=magrittr"
},
"14": {
"@type": "SoftwareApplication",
"identifier": "assertthat",
"name": "assertthat",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=assertthat"
},
"15": {
"@type": "SoftwareApplication",
"identifier": "xml2",
"name": "xml2",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=xml2"
},
"SystemRequirements": null
},
"fileSize": "615.75KB",
"releaseNotes": "https://github.com/charlie86/spotifyr/blob/master/NEWS.md",
"readme": "https://github.com/charlie86/spotifyr/blob/master/README.md",
"keywords": [
"spotify",
"music-information-retrieval"
]
}
GitHub Events
Total
- Issues event: 14
- Watch event: 12
- Issue comment event: 20
- Push event: 6
- Pull request event: 13
- Fork event: 3
Last Year
- Issues event: 14
- Watch event: 12
- Issue comment event: 20
- Push event: 6
- Pull request event: 13
- Fork event: 3
Committers
Last synced: over 2 years ago
Top Committers
| Name | Commits | |
|---|---|---|
| charlie86 | c****k@s****m | 110 |
| Daniel Antal | a****l@u****m | 77 |
| charliet | c****t@s****m | 36 |
| charlie86 | c****0@g****m | 15 |
| antaldaniel | a****l@g****m | 11 |
| Josiah | j****y@g****m | 8 |
| Stephen Holsenbeck | s****n@v****o | 7 |
| Chuck Thompson | c****k@C****l | 7 |
| BradHill | b****9@g****m | 3 |
| c****k@g****n | 2 | |
| Brad Hill | 3****d@u****m | 2 |
| Donal Phipps | d****s@g****m | 2 |
| Maria Paula Caldas | m****s@g****m | 2 |
| charlie86 | 9****6@u****m | 2 |
| donal | d****l@d****e | 2 |
| filipwastberg | f****g@g****m | 2 |
| Jan Simson | j****m@u****m | 1 |
| annnvv | 1****v@u****m | 1 |
| Sam Albers | s****s@g****m | 1 |
| Thomas Niessen | t****n@w****e | 1 |
| bernicecu | b****u@g****m | 1 |
| JedrzejF | 4****F@u****m | 1 |
| 我是洗衣机 | w****1@u****m | 1 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 81
- Total pull requests: 45
- Average time to close issues: 3 months
- Average time to close pull requests: 3 months
- Total issue authors: 63
- Total pull request authors: 13
- Average comments per issue: 2.19
- Average comments per pull request: 0.56
- Merged pull requests: 38
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 13
- Pull requests: 10
- Average time to close issues: 12 days
- Average time to close pull requests: 10 days
- Issue authors: 6
- Pull request authors: 3
- Average comments per issue: 0.62
- Average comments per pull request: 1.0
- Merged pull requests: 7
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- antaldaniel (12)
- AtomicNess123 (5)
- JosiahParry (3)
- pmcharrison (2)
- yogat3ch (2)
- tom-pham (1)
- eledroos (1)
- erikgregorywebb (1)
- jaburgoyne (1)
- NoahFHenry (1)
- adapkus (1)
- harshvardhaniimi (1)
- Toozig (1)
- apsteinmetz (1)
- KewKalustian (1)
Pull Request Authors
- antaldaniel (32)
- pmcharrison (6)
- andodet (3)
- yogat3ch (2)
- bradisbrad (2)
- t-davidson (2)
- womeimingzi11 (1)
- annnvv (1)
- mpaulacaldas (1)
- JedrzejF (1)
- baumanno (1)
- JosiahParry (1)
- niessen (1)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 2
-
Total downloads:
- cran 1,340 last-month
-
Total dependent packages: 0
(may contain duplicates) -
Total dependent repositories: 5
(may contain duplicates) - Total versions: 14
- Total maintainers: 1
cran.r-project.org: spotifyr
R Wrapper for the 'Spotify' Web API
- Homepage: https://github.com/charlie86/spotifyr
- Documentation: http://cran.r-project.org/web/packages/spotifyr/spotifyr.pdf
- License: MIT + file LICENSE
-
Latest release: 2.2.5
published over 1 year ago
Rankings
Maintainers (1)
conda-forge.org: r-spotifyr
- Homepage: http://github.com/charlie86/spotifyr
- License: MIT
-
Latest release: 2.2.3
published over 4 years ago
Rankings
Dependencies
- R >= 3.3.0 depends
- assertthat * imports
- dplyr * imports
- genius * imports
- ggridges * imports
- httr * imports
- janitor * imports
- jsonlite * imports
- lubridate * imports
- magrittr * imports
- purrr * imports
- readr * imports
- rlang * imports
- rvest * imports
- stringr * imports
- tibble * imports
- tidyr * imports
- xml2 * imports
- testthat >= 3.0.0 suggests
- r-hub/actions/checkout v1 composite
- r-hub/actions/platform-info v1 composite
- r-hub/actions/run-check v1 composite
- r-hub/actions/setup v1 composite
- r-hub/actions/setup-deps v1 composite
- r-hub/actions/setup-r v1 composite