/Spotify.jl

A Julia wrapper for the Spotify API

Primary LanguageJuliaMIT LicenseMIT

Docs example workflow

Code coverage report

An open-source interface for using the Spotify web API in Julia.

Progress...

Right now, 66 API wrapper functions and 12 aliases have been written, tested and organized by sub-modules as defined in Spotify's documentation:

What can you use this for?

You can

  • play music and prune your playlists through a mini-player REPL mode
  • organize playlists based on audio analysis or each track's popularity in Japan
  • fix your taste profile after that kid's party
  • build social graphs for artists, playlists or users, analyze popularity
  • clean duplicates
  • search podcast metadata
  • create your own visualizations from beat data
  • play with popularity and genre statistics

Easily find the right functions with the select_calls menu and the submodules:

  • Albums, Artists, Categories, Episodes, Genres,
  • Library, Markets, Player, Playlists, Search
  • Shows, Tracks, Users, Profile

Getting started

Loading:

(@v1.8) pkg> add Spotify

julia> using Spotify

This creates 'spotify_credentials.ini' in your homedir(), along with instructions on how to input your user name and client credentials.

julia> select_calls()

This brings up a menu for exploration calls, which works best in the REPL.

Wrapper API

Wrapper functions require different permission scopes, which you grant as needed by pressing 'Accept' in a browser tab which pops up when needed. A granted scope lasts for one hour.

The wrapper functions are duck-typed and will accept strings, vectors of strings or the types below. Functions leniently convert input to these string-like types:

  • SpPlaylistId, SpArtistId, SpTrackId, SpAlbumId
  • SpShowId, SpEpisodeId, SpId, SpCategoryId

Ouput from all wrapper functions is a tuple: (JSON3 object, wait_seconds).

  • wait_seconds is zero except if the API rate limit is temporarily exceeded
  • JSON3 object is an object / dictionary which is easy and fast to inspect and use. See the examples for some ideas

Control of text feedback is provided, see ?LOGSTATE.

Documentation and a bref example

For more detail on setting up your credentials and getting keys please checkout this page in the documentation.

julia> using Spotify, Spotify.Tracks
julia> tracks_get_audio_features("5gZ5YB5SryZdM0GV7mXzDJ")
({
       "danceability": 0.636,
             "energy": 0.699,
                "key": 4,
           "loudness": -7.602,
               "mode": 1,
        "speechiness": 0.0332,
       "acousticness": 0.0297,
   "instrumentalness": 0.0174,
           "liveness": 0.098,
            "valence": 0.964,
              "tempo": 102.019,
               "type": "audio_features",
                 "id": "5gZ5YB5SryZdM0GV7mXzDJ",
                "uri": "spotify:track:5gZ5YB5SryZdM0GV7mXzDJ",
         "track_href": "https://api.spotify.com/v1/tracks/5gZ5YB5SryZdM0GV7mXzDJ",
       "analysis_url": "https://api.spotify.com/v1/audio-analysis/5gZ5YB5SryZdM0GV7mXzDJ",
        "duration_ms": 214267,
     "time_signature": 3
}, 0)

To Do

  • Inline Documentation needs to be completed
  • Wiki
  • Write tests
  • Set up CI
  • Register the package