| Title: | Tools for Working with the 'Genius' API |
|---|---|
| Description: | Provides tools to interact nicely with the 'Genius' API <https://docs.genius.com/>. Search hosted content, extract associated metadata and retrieve lyrics with ease. |
| Authors: | Ewen Henderson [aut, cre] (ORCID: <https://orcid.org/0000-0002-4748-4693>) |
| Maintainer: | Ewen Henderson <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 1.2.1.9000 |
| Built: | 2026-05-22 08:06:54 UTC |
| Source: | https://github.com/ewenme/geniusr |
Convert genius_album object to a data frame
album_to_df(x)album_to_df(x)
x |
a |
a tibble
## Not run: album <- get_album(album_id = 337082) album_to_df(album) ## End(Not run)## Not run: album <- get_album(album_id = 337082) album_to_df(album) ## End(Not run)
Convert genius_artist object to a data frame
artist_to_df(x)artist_to_df(x)
x |
a |
a tibble
## Not run: artist <- get_artist(artist_id = 16775) artist_to_df(artist) ## End(Not run)## Not run: artist <- get_artist(artist_id = 16775) artist_to_df(artist) ## End(Not run)
Opens a browser to https://genius.com/.
browse_genius()browse_genius()
A browser is opened to the Genius website if the session is interactive. The URL is returned as a character string.
browse_genius()browse_genius()
Opens a browser to the Genius url of a Genius "resource" (i.e.
the result of a successful get_album|artist|song() call).
browse_genius_resource(x)browse_genius_resource(x)
x |
a |
A browser is opened to the Genius resource's url if the session is interactive. The URL is returned as a character string.
song <- get_song(song_id = 3039923) browse_genius_resource(song)song <- get_song(song_id = 3039923) browse_genius_resource(song)
The API wrapper functions in this package all rely on a Genius client access token
residing in the environment variable GENIUS_API_TOKEN. The
easiest way to accomplish this is to set it in the '.Renviron' file in your
home directory.
genius_token(force = FALSE)genius_token(force = FALSE)
force |
force setting a new Genius API token for the current environment? |
atomic character vector containing the Genius API token
The Genius API lets you request data for a specific album, given an album ID.
get_album() returns this data in full.
get_album(album_id, access_token = genius_token())get_album(album_id, access_token = genius_token())
album_id |
ID of the album ( |
access_token |
Genius' client access token, defaults to |
a genius_album object that contains the extracted content from the request,
the original JSON response object and the request path.
See get_album_df to return a tidy data frame.
Other album:
get_album_df(),
get_album_tracklist_id(),
get_album_tracklist_search()
## Not run: get_album(album_id = 337082) ## End(Not run)## Not run: get_album(album_id = 337082) ## End(Not run)
The Genius API lets you return data for a specific album, given an album ID.
get_album_meta returns this data in a tidy, but reduced, format.
get_album_df(album_id, access_token = genius_token())get_album_df(album_id, access_token = genius_token())
album_id |
ID of the album ( |
access_token |
Genius' client access token, defaults to |
a tibble
See get_album to return extended data as a list.
Other album:
get_album_tracklist_id(),
get_album_tracklist_search(),
get_album()
## Not run: get_album_df(album_id = 337082) ## End(Not run)## Not run: get_album_df(album_id = 337082) ## End(Not run)
Get an album's tracklisting, and song meta data, given an album ID.
get_album_tracklist_id(album_id, access_token = genius_token())get_album_tracklist_id(album_id, access_token = genius_token())
album_id |
ID of the album ( |
access_token |
Genius' client access token, defaults to |
a tibble
See get_album_tracklist_search to search for
an album tracklist by searching artist/album names.
Other album:
get_album_df(),
get_album_tracklist_search(),
get_album()
## Not run: get_album_tracklist_id(album_id = 337082) ## End(Not run)## Not run: get_album_tracklist_id(album_id = 337082) ## End(Not run)
Attempt to get an album's tracklisting, given an artist and album name.
get_album_tracklist_search(artist_name, album_name)get_album_tracklist_search(artist_name, album_name)
artist_name |
Name of artist |
album_name |
Name of album |
a tibble
See get_album_tracklist_id to search for
an album tracklist using an album ID.
Other album:
get_album_df(),
get_album_tracklist_id(),
get_album()
## Not run: get_album_tracklist_search(artist_name = "Kendrick Lamar", album_name = "DAMN.") ## End(Not run)## Not run: get_album_tracklist_search(artist_name = "Kendrick Lamar", album_name = "DAMN.") ## End(Not run)
The Genius API lets you return data for a specific annotation, given an
annotation ID. get_annotation returns this data in full.
get_annotation(annotation_id, access_token = genius_token())get_annotation(annotation_id, access_token = genius_token())
annotation_id |
ID of the annotation |
access_token |
Genius' client access token, defaults to |
A Genius annotation is a piece of content about a part of a document. The document may be a song (hosted on Genius) or a web page (hosted anywhere). The part of a document that an annotation is attached to is called a referent.
a genius_annotation object that contains the extracted content from the request,
the original JSON response object and the request path.
Other annotation:
get_referent()
## Not run: get_annotation(annotation_id = 16511101) ## End(Not run)## Not run: get_annotation(annotation_id = 16511101) ## End(Not run)
The Genius API lets you return data for a specific artist, given an artist ID.
get_artist returns this data in full.
get_artist(artist_id, access_token = genius_token())get_artist(artist_id, access_token = genius_token())
artist_id |
ID of the artist ( |
access_token |
Genius' client access token, defaults to |
a genius_artist object that contains the extracted content from the request,
the original JSON response object and the request path.
See get_artist_df to return a tidy data frame.
Other artist:
get_artist_df(),
get_artist_songs_df(),
get_artist_songs()
## Not run: get_artist(artist_id = 16775) ## End(Not run)## Not run: get_artist(artist_id = 16775) ## End(Not run)
The Genius API lets you search for meta data for an artist, given an
artist ID. get_artist_df returns this data in a tidy, but
reduced, format.
get_artist_df(artist_id, access_token = genius_token())get_artist_df(artist_id, access_token = genius_token())
artist_id |
ID of the artist ( |
access_token |
Genius' client access token, defaults to |
a tibble
See get_artist to return data in full as a list.
Other artist:
get_artist_songs_df(),
get_artist_songs(),
get_artist()
## Not run: get_artist_df(artist_id = 16751) ## End(Not run)## Not run: get_artist_df(artist_id = 16751) ## End(Not run)
The Genius API lets you search for song metadata of an artist,
given an artist ID. get_artist_songs returns this data
in full.
get_artist_songs( artist_id, sort = c("title", "popularity"), include_features = FALSE, access_token = genius_token() )get_artist_songs( artist_id, sort = c("title", "popularity"), include_features = FALSE, access_token = genius_token() )
artist_id |
ID of the artist ( |
sort |
method to order results; by "title" (default) or by "popularity" |
include_features |
Whether to return results where artist isn't the primary artist (logical, defaults to FALSE) |
access_token |
Genius' client access token, defaults to |
a genius_resource object that contains the extracted content from the request,
the original JSON response object and the request path.
See get_artist_songs_df to return a tidy data frame.
Other artist:
get_artist_df(),
get_artist_songs_df(),
get_artist()
## Not run: get_artist_songs(artist_id = 1421) get_artist_songs(artist_id = 1421, sort = "popularity") get_artist_songs(artist_id = 1421, include_features = TRUE) ## End(Not run)## Not run: get_artist_songs(artist_id = 1421) get_artist_songs(artist_id = 1421, sort = "popularity") get_artist_songs(artist_id = 1421, include_features = TRUE) ## End(Not run)
The Genius API lets you search for song metadata of an artist,
given an artist ID. get_artist_songs_df returns this data
in a tidy, but reduced, format.
get_artist_songs_df( artist_id, sort = c("title", "popularity"), include_features = FALSE, access_token = genius_token() )get_artist_songs_df( artist_id, sort = c("title", "popularity"), include_features = FALSE, access_token = genius_token() )
artist_id |
ID of the artist ( |
sort |
method to order results; by "title" (default) or by "popularity" |
include_features |
Whether to return results where artist isn't the primary artist (logical, defaults to FALSE) |
access_token |
Genius' client access token, defaults to |
a tibble
See get_artist_songs to return data in full as a
list.
Other artist:
get_artist_df(),
get_artist_songs(),
get_artist()
## Not run: get_artist_songs_df(artist_id = 1421) ## End(Not run)## Not run: get_artist_songs_df(artist_id = 1421) ## End(Not run)
Get lyrics from Genius' lyric pages using an associated song ID.
get_lyrics_id(song_id, access_token = genius_token())get_lyrics_id(song_id, access_token = genius_token())
song_id |
ID of the song ( |
access_token |
Genius' client access token, defaults to |
See get_lyrics_url to search lyrics using a song
URL, get_lyrics_search to search using artist name and song
title
Other lyrics:
get_lyrics_search(),
get_lyrics_url()
## Not run: get_lyrics_id(song_id = 3214267) ## End(Not run)## Not run: get_lyrics_id(song_id = 3214267) ## End(Not run)
Attempt to get lyrics from Genius' lyric pages using an associated artist name and song title.
get_lyrics_search(artist_name, song_title)get_lyrics_search(artist_name, song_title)
artist_name |
Name of artist |
song_title |
Title of song |
See get_lyrics_id to search lyrics using a song
ID, get_lyrics_url to search using a song URL
Other lyrics:
get_lyrics_id(),
get_lyrics_url()
## Not run: get_lyrics_search(artist_name = "Anderson .Paak", song_title = "Come Home") ## End(Not run)## Not run: get_lyrics_search(artist_name = "Anderson .Paak", song_title = "Come Home") ## End(Not run)
Scrape lyrics from a Genius' lyric page using it's associated URL. Best used with get_album_tracklist_id, when song IDs aren't returned - otherwise, get_lyrics_id is recommended.
get_lyrics_url(song_lyrics_url)get_lyrics_url(song_lyrics_url)
song_lyrics_url |
song lyrics url (like in |
See get_lyrics_id to search lyrics using a song
ID, get_lyrics_search to search using artist name and song
title
Other lyrics:
get_lyrics_id(),
get_lyrics_search()
## Not run: get_lyrics_url(song_lyrics_url = "https://genius.com/Kendrick-lamar-dna-lyrics") ## End(Not run)## Not run: get_lyrics_url(song_lyrics_url = "https://genius.com/Kendrick-lamar-dna-lyrics") ## End(Not run)
The Genius API lets you return data for a specific referent.
get_referent returns this data in full.
get_referent( created_by_id, song_id, web_page_id, access_token = genius_token() )get_referent( created_by_id, song_id, web_page_id, access_token = genius_token() )
created_by_id |
ID of a user to get referents for |
song_id |
ID of a song to get referents for (pass only one of |
web_page_id |
ID of a web page to get referents for (pass only one of |
access_token |
Genius' client access token, defaults to |
Referents are the sections of a piece of content to which annotations are attached. Each referent is associated with a web page or a song and may have one or more annotations. Referents can be searched by the document they are attached to or by the user that created them.
a genius_referent object that contains the extracted content from the request,
the original JSON response object and the request path.
Other annotation:
get_annotation()
## Not run: get_referent(song_id = 3039923) ## End(Not run)## Not run: get_referent(song_id = 3039923) ## End(Not run)
The Genius API lets you return data for a specific song, given a song ID.
get_song returns this data in full.
get_song(song_id, access_token = genius_token())get_song(song_id, access_token = genius_token())
song_id |
ID of the song ( |
access_token |
Genius' client access token, defaults to |
a genius_song object that contains the extracted content from the request,
the original JSON response object and the request path.
See get_song_df to return a tidy data frame.
Other song:
get_song_df(),
tidy_album_performances(),
tidy_song_performances(),
tidy_song_producers(),
tidy_song_relationships(),
tidy_song_writers()
## Not run: get_song(song_id = 3039923) ## End(Not run)## Not run: get_song(song_id = 3039923) ## End(Not run)
The Genius API lets you search for meta data for a song, given a song ID.
get_song_meta returns this data in a tidy, but reduced, format.
get_song_df(song_id, access_token = genius_token())get_song_df(song_id, access_token = genius_token())
song_id |
ID of the song ( |
access_token |
Genius' client access token, defaults to |
a tibble
See get_song to return data in full as a list.
Other song:
get_song(),
tidy_album_performances(),
tidy_song_performances(),
tidy_song_producers(),
tidy_song_relationships(),
tidy_song_writers()
## Not run: get_song_df(song_id = 3039923) ## End(Not run)## Not run: get_song_df(song_id = 3039923) ## End(Not run)
Slightly more human-readable output for genius_album objects
## S3 method for class 'genius_album' print(x, ...)## S3 method for class 'genius_album' print(x, ...)
x |
a genius_album object |
... |
ignored |
Slightly more human-readable output for genius_annotation objects
## S3 method for class 'genius_annotation' print(x, ...)## S3 method for class 'genius_annotation' print(x, ...)
x |
a genius_annotation object |
... |
ignored |
Slightly more human-readable output for genius_artist objects
## S3 method for class 'genius_artist' print(x, ...)## S3 method for class 'genius_artist' print(x, ...)
x |
a genius_artist object |
... |
ignored |
Slightly more human-readable output for genius_referent objects
## S3 method for class 'genius_referent' print(x, ...)## S3 method for class 'genius_referent' print(x, ...)
x |
a genius_referent object |
... |
ignored |
Slightly more human-readable output for genius_resource objects
## S3 method for class 'genius_resource' print(x, ...)## S3 method for class 'genius_resource' print(x, ...)
x |
a genius_resource object |
... |
ignored |
Slightly more human-readable output for genius_song objects
## S3 method for class 'genius_song' print(x, ...)## S3 method for class 'genius_song' print(x, ...)
x |
a genius_song object |
... |
ignored |
The Genius API lets you search hosted content (all songs). Use search_artist()
to return artist_id, artist_name and artist_url for all unique
artist matches found using a search term.
search_artist(search_term, n_results = 10, access_token = genius_token())search_artist(search_term, n_results = 10, access_token = genius_token())
search_term |
A character string to search for |
n_results |
Maximum no. of search results to return |
access_token |
Genius' client access token, defaults to |
a tibble
Other search:
search_genius(),
search_song()
## Not run: search_artist(search_term = "Lil", n_results = 20) ## End(Not run)## Not run: search_artist(search_term = "Lil", n_results = 20) ## End(Not run)
The Genius API lets you search hosted content (all songs). Use search_genius()
to return hits on for a given search term, in full.
search_genius(search_term, n_results = 10, access_token = genius_token())search_genius(search_term, n_results = 10, access_token = genius_token())
search_term |
A character string to search for |
n_results |
Maximum no. of search results to return |
access_token |
Genius' client access token, defaults to |
a genius_resource object that contains the extracted content from the request,
the original JSON response object and the request path.
Other search:
search_artist(),
search_song()
## Not run: search_genius(search_term = "Lil", n_results = 100) ## End(Not run)## Not run: search_genius(search_term = "Lil", n_results = 100) ## End(Not run)
The Genius API lets you search hosted content (all songs). Use
search_song() to return song_id, song_name,
lyrics_url and artist_id for all unique song matches
found using a search term.
search_song(search_term, n_results = 10, access_token = genius_token())search_song(search_term, n_results = 10, access_token = genius_token())
search_term |
A character string to search for |
n_results |
Maximum no. of search results to return |
access_token |
Genius' client access token, defaults to |
a tibble
Other search:
search_artist(),
search_genius()
## Not run: search_song(search_term = "Gucci", n_results = 50) ## End(Not run)## Not run: search_song(search_term = "Gucci", n_results = 50) ## End(Not run)
Convert genius_song object to a data frame
song_to_df(x)song_to_df(x)
x |
a |
a tibble
## Not run: song <- get_song(song_id = 3039923) song_to_df(song) ## End(Not run)## Not run: song <- get_song(song_id = 3039923) song_to_df(song) ## End(Not run)
Extract "album performances" (i.e. album credits) info from a Genius album object, as a tidy tibble.
tidy_album_performances(x)tidy_album_performances(x)
x |
A |
a tibble
See get_album to generate a Genius album object.
Other song:
get_song_df(),
get_song(),
tidy_song_performances(),
tidy_song_producers(),
tidy_song_relationships(),
tidy_song_writers()
## Not run: album <- get_album(album_id = 337082) tidy_album_performances(album) ## End(Not run)## Not run: album <- get_album(album_id = 337082) tidy_album_performances(album) ## End(Not run)
Extract "custom performances" (i.e. other song credits) info from a Genius song object, as a tidy tibble.
tidy_song_performances(x)tidy_song_performances(x)
x |
A |
a tibble
See get_song to generate a Genius song object.
Other song:
get_song_df(),
get_song(),
tidy_album_performances(),
tidy_song_producers(),
tidy_song_relationships(),
tidy_song_writers()
## Not run: song <- get_song(song_id = 3039923) tidy_song_performances(song) ## End(Not run)## Not run: song <- get_song(song_id = 3039923) tidy_song_performances(song) ## End(Not run)
Extract "producer artists" (i.e. producer credits) info from a Genius song object, as a tidy tibble.
tidy_song_producers(x)tidy_song_producers(x)
x |
A |
a tibble
See get_song to generate a Genius song object.
Other song:
get_song_df(),
get_song(),
tidy_album_performances(),
tidy_song_performances(),
tidy_song_relationships(),
tidy_song_writers()
## Not run: song <- get_song(song_id = 3039923) tidy_song_producers(song) ## End(Not run)## Not run: song <- get_song(song_id = 3039923) tidy_song_producers(song) ## End(Not run)
Extract "song relationships" info from a Genius song object, as a tidy tibble.
tidy_song_relationships(x)tidy_song_relationships(x)
x |
A |
a tibble
See get_song to generate a Genius song object.
Other song:
get_song_df(),
get_song(),
tidy_album_performances(),
tidy_song_performances(),
tidy_song_producers(),
tidy_song_writers()
## Not run: song <- get_song(song_id = 3039923) tidy_song_relationships(song) ## End(Not run)## Not run: song <- get_song(song_id = 3039923) tidy_song_relationships(song) ## End(Not run)
Extract "writer artists" (i.e. writer credits) info from a Genius song object, as a tidy tibble.
tidy_song_writers(x)tidy_song_writers(x)
x |
A |
a tibble
See get_song to generate a Genius song object.
Other song:
get_song_df(),
get_song(),
tidy_album_performances(),
tidy_song_performances(),
tidy_song_producers(),
tidy_song_relationships()
## Not run: song <- get_song(song_id = 3039923) tidy_song_writers(song) ## End(Not run)## Not run: song <- get_song(song_id = 3039923) tidy_song_writers(song) ## End(Not run)