_images/header.png

LyricsGenius: a Python client for the Genius.com API

https://travis-ci.org/johnwmillr/LyricsGenius.svg?branch=master https://badge.fury.io/py/lyricsgenius.svg https://img.shields.io/badge/python-3.x-brightgreen.svg

Genius.com is a fun website. If you aren’t familiar with it, Genius hosts a bunch of song lyrics and lets users highlight and annotate passages with interpretations, explanations, and references. Originally called RapGenius.com and devoted to lyrics from rap and hip-hop songs, the website now includes lyrics and annotations from all genres of music. You can figure out what “Words are flowing out like endless rain into a paper cup” from Across the Universe really means, or what Noname was referring to when she said “Moses wrote my name in gold and Kanye did the eulogy”.

It’s actually not too difficult to start pulling data from the Genius website. Genius is hip enough to provide a free application programming interface (API) that makes it easy for nerds to programmatically access song and artist data from their website. What the Genius API doesn’t provide, however, is a way to download the lyrics themselves. With a little help from Beautiful Soup though, it’s possible to grab the song lyrics without too much extra work. And LyricsGenius has done all of that for you already.

lyricsgenius provides a simple interface to the song, artist, and lyrics data stored on Genius.com.

Using this library you can convienently access the content on Genius.com And much more using the public API.

You can use pip to install lyricsgenius:

pip install lyricsgenius

LyricsGenius provides lots of features to work with. For example, let’s download all the lyrics of an artist’s songs, and save them to a JSON file:

from lyricsgenius import Genius

genius = Genius(token)
genius.search_artist('Andy Shauf')
artist.save_lyrics()

But before using the library you will need to get an access token. Head over to Setup to get started.