All Projects → charlie86 → Spotifyr

charlie86 / Spotifyr

Licence: other
R wrapper for Spotify's Web API

Programming Languages

r
7636 projects

Projects that are alternatives of or similar to Spotifyr

spotify-playback-flutter
This is an spotify playback package for flutter
Stars: ✭ 39 (-84.88%)
Mutual labels:  spotify
Spotify-Song-Recommendation-ML
UC Berkeley team's submission for RecSys Challenge 2018
Stars: ✭ 70 (-72.87%)
Mutual labels:  spotify
Quaggify
A spotify clone made in Swift 4 consuming the Spotify API
Stars: ✭ 30 (-88.37%)
Mutual labels:  spotify
spotify-connect-scrobbler
Last.fm scrobbler for Spotify Connect
Stars: ✭ 20 (-92.25%)
Mutual labels:  spotify
Easify-iOS
An iOS application to test out Spotify API. It uses SwiftUI and Combine.
Stars: ✭ 15 (-94.19%)
Mutual labels:  spotify
audius
🎧 A cross-platform app for downloading songs from YouTube and Spotify
Stars: ✭ 19 (-92.64%)
Mutual labels:  spotify
PlaylistPolice
Allows you to whitelist Spotify users for your collaborative playlists
Stars: ✭ 33 (-87.21%)
Mutual labels:  spotify
blade-player
Android music player that plays from local library, Spotify or Deezer
Stars: ✭ 67 (-74.03%)
Mutual labels:  spotify
api-old
The official API for the Spotistats app (Android + iOS) 💚
Stars: ✭ 33 (-87.21%)
Mutual labels:  spotify
larafy
Larafy is a Laravel package for Spotify API. It is more like a wrapper for the Spotify API.
Stars: ✭ 53 (-79.46%)
Mutual labels:  spotify
spotify-lyrics-cli
Migrated to Gitlab, this Github repo will not receive updates.
Stars: ✭ 57 (-77.91%)
Mutual labels:  spotify
passport-examples
A variety of examples using PassportJS with ExpressJS and ReactJS applications
Stars: ✭ 44 (-82.95%)
Mutual labels:  spotify
Spotify-Cards-API
🚀 Unofficial Spotify PromoCards API
Stars: ✭ 13 (-94.96%)
Mutual labels:  spotify
discoverify
Free Spotify add-on that automatically generates a personalized "Discover Daily" playlist, filled with recommendations based on your listening history.
Stars: ✭ 40 (-84.5%)
Mutual labels:  spotify
spotify-url-info
Get metadata from Spotify URL.
Stars: ✭ 34 (-86.82%)
Mutual labels:  spotify
spotify-clone
🎶 Spotify Clone
Stars: ✭ 17 (-93.41%)
Mutual labels:  spotify
ypc
Convert text/spotify/deezer albums/playlists to youtube urls and audio/video files.
Stars: ✭ 17 (-93.41%)
Mutual labels:  spotify
clipinc
A browser extension to record Spotify songs as you listen to them.
Stars: ✭ 17 (-93.41%)
Mutual labels:  spotify
spoti-vote
Web application to vote the next Song in Spotify Queue
Stars: ✭ 14 (-94.57%)
Mutual labels:  spotify
spotify ad muter
No description or website provided.
Stars: ✭ 20 (-92.25%)
Mutual labels:  spotify

spotifyr

CRAN_Status_Badge

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.1.0 (recommended)

install.packages('spotifyr')

Development version

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.

Sys.setenv(SPOTIFY_CLIENT_ID = 'xxxxxxxxxxxxxxxxxxxxx')
Sys.setenv(SPOTIFY_CLIENT_SECRET = 'xxxxxxxxxxxxxxxxxxxxx')

access_token <- get_spotify_access_token()

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?

library(spotifyr)
beatles <- get_artist_audio_features('the beatles')
library(tidyverse)
library(knitr)

beatles %>% 
    count(key_mode, sort = TRUE) %>% 
    head(5) %>% 
    kable()
key_mode n
D major 24
G major 21
A major 13
F major 12
C major 11

Get your most recently played tracks

library(lubridate)

get_my_recently_played(limit = 5) %>% 
    mutate(artist.name = map_chr(track.artists, function(x) x$name[1]),
           played_at = as_datetime(played_at)) %>% 
    select(track.name, artist.name, track.album.name, played_at) %>% 
    kable()
track.name artist.name track.album.name played_at
Hardened Chord - Regis Remix Stave After the Social 2019-07-12 19:04:29
Cells Blenk Shelter 2019-07-12 18:57:59
Suspension Of Consciousness - Original mix Flaminia THEOTHERSIDE 01 2019-07-12 18:52:32
Kerala Bonobo Migration 2019-07-12 18:46:58
Linked Bonobo Linked 2019-07-12 18:45:31

Find your all time favorite artists

get_my_top_artists_or_tracks(type = 'artists', time_range = 'long_term', limit = 5) %>% 
    select(name, genres) %>% 
    rowwise %>% 
    mutate(genres = paste(genres, collapse = ', ')) %>% 
    ungroup %>% 
    kable()
name genres
Radiohead alternative rock, art rock, melancholia, modern rock, oxford indie, permanent wave, rock
Flying Lotus alternative hip hop, escape room, experimental hip hop, glitch, glitch hop, hip hop, indietronica, intelligent dance music, jazztronica, wonky
Onra alternative hip hop, chillhop, trip hop, wonky
Teebs abstract beats, bass music, chillwave, wonky
Pixies alternative rock, boston rock, garage rock, indie rock, modern rock, new wave, noise pop, permanent wave, rock

Find your favorite tracks at the moment

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
Impossible Knots Thom Yorke ANIMA
I Am a Very Rude Person Thom Yorke ANIMA
Traffic Thom Yorke ANIMA
Not The News Thom Yorke ANIMA
Runwayaway Thom Yorke ANIMA

What’s the most joyful Joy Division song?

My favorite audio feature has to be “valence,” a measure of musical positivity.

joy <- get_artist_audio_features('joy division')
joy %>% 
    arrange(-valence) %>% 
    select(track_name, valence) %>% 
    head(5) %>% 
    kable()
track_name valence
Passover - 2007 Remaster 0.941
Colony - 2007 Remaster 0.808
Atrocity Exhibition - 2007 Remaster 0.787
A Means to an End - 2007 Remaster 0.752
Interzone - 2007 Remaster 0.746

Now if only there was some way to plot joy…

Joyplot of the emotional rollercoasters that are Joy Division’s albums

library(ggjoy)

ggplot(joy, aes(x = valence, y = album_name)) + 
    geom_joy() + 
    theme_joy() +
    ggtitle("Joyplot of Joy Division's joy distributions", subtitle = "Based on valence pulled from Spotify's Web API with spotifyr")

Sentify: A Shiny app

This app, powered by spotifyr, allows you to visualize the energy and valence (musical positivity) of all of Spotify’s artists and playlists.

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

Sentiment analysis of musical taste: a cross-European comparison, Paul Elvers

Blue Christmas: A data-driven search for the most depressing Christmas song, Caitlin Hudon

KendRick LamaR, David K. Laing

Vilken är Kents mest deprimerande låt? (What is Kent’s most depressing song?), Filip Wästberg

Чёрное зеркало Arcade Fire (Black Mirror Arcade Fire), TheSociety

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

Long Distance Calling: Data Science meets Post-Rock…, Sebastian Kuhn

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].