The geniusr
package is designed to help you retrieve data from Genius. Most of this data falls into one of two distinct categories:
Functionality in both of these areas will be demonstrated once API authentication is dealt with. Make sure to read more in the docs for detailed guidance on all package features.
geniusr
data retrieval is typically done by making authenticated requests to the Genius API. This necessitates a few common steps:
GENIUS_API_TOKEN
environment variable by explicitly calling the genius_token()
function, or when prompted by other functionsOnce you have set the GENIUS_API_TOKEN
environment variable, it will be active for the rest of the session and automatically called (via genius_token()
) when using geniusr
functions to request data.
The first family of data retrieval functions help with accessing data from various types of Genius Resources, explored in turn below.
Functions for requesting data on songs hosted on Genius take the form get_song_xxx()
. For example, get_song()
returns details about the song itself, as well as user annotations that are attached to it, as a genius_song
object.
For details about the track Sing About Me, I’m Dying of Thirst by Kendrick Lamar:
Functions for requesting data on an artist (i.e. the creator of one or more songs hosted on Genius) take the form get_artist_xxx()
. For example, get_artist()
returns details about the artist as a genius_artist
object
For info about the artist Kendrick Lamar:
Functions for requesting data on an album take the form get_album_xxx()
. For example, get_album()
returns details about the artist as a genius_album
object.
For info on the album Good Kid, M.A.A.D City by Kendrick Lamar:
Functions for searching all content hosted on Genius take the form search_xxx()
. For example, search_genius()
returns documents matching a search term(s) as a genius_resource
object.
We can look for documents that match the search term “Compton”.
The functions introduced above all return fairly complex list objects that are not immediately ready for many analytical workflows. The get_artist|album|song()
functions all have sister functions that prepare a tibble (data frame) for you.
Here’s get_song()
in action…
…and here’s get_song_df()
, retrieving data for the same song:
The get_album|artist|song_df()
output is a somewhat simplified version of the get_album|artist|song()
counterpart, so make sure to check the original function objects if you need the detail.
Furthermore, there are some tidy_xxx()
functions available to help you “un-nest” some of the data holed up in nested lists within genius_song
and genius_album
objects.
For example, tidy_song_producers()
pulls out producer credits from a genius_song()
object as a tidy tibble:
There are also tools to be found in geniusr
that help with Genius lyrics retrieval. These functions take the form…you guessed it…get_lyrics_xxx()
. For example, get_lyrics_id()
finds song lyrics for a given song id, and returns this data as a tidy tibble - each line of the track as an observation (i.e. a row).
To complete the look, here’s song lyrics for Sing About Me, I’m Dying of Thirst: