Skip to main content

LlamaIndex Readers Integration: Genius

pip install llama-index-readers-genius

This loader connects to the Genius API and loads lyrics, metadata, and album art into Documents.

As a prerequisite, you will need to register with Genius API and create an app in order to get a client_id and a client_secret. You should then set a redirect_uri for the app. The redirect_uri does not need to be functional. You should then generate an access token as an instantiator for the GeniusReader.

Usage

Here's an example usage of the GeniusReader. It will retrieve songs that match specific lyrics. Acceptable arguments are lyrics (str): The lyric snippet you're looking for and will return List[Document]: A list of documents containing songs with those lyrics.

GeniusReader Class Methods

load_artist_songs

  • Description: Fetches all or a specified number of songs by an artist.
  • Arguments:
    • artist_name (str): The name of the artist.
    • max_songs (Optional[int]): Maximum number of songs to retrieve.
  • Returns: List of Document objects with song lyrics.

load_all_artist_songs

  • Description: Fetches all songs of an artist and saves their lyrics.
  • Arguments:
    • artist_name (str): The name of the artist.
  • Returns: List of Document objects with the artist's song lyrics.

load_artist_songs_with_filters

  • Description: Loads the most or least popular song of an artist based on filters.
  • Arguments:
    • artist_name (str): The artist's name.
    • most_popular (bool): True for most popular song, False for least popular.
    • max_songs (Optional[int]): Max number of songs to consider for popularity.
    • max_pages (int): Max number of pages to fetch.
  • Returns: Document with lyrics of the selected song.

load_song_by_url_or_id

  • Description: Loads a song by its Genius URL or ID.
  • Arguments:
    • song_url (Optional[str]): URL of the song on Genius.
    • song_id (Optional[int]): ID of the song on Genius.
  • Returns: List of Document objects with the song's lyrics.

search_songs_by_lyrics

  • Description: Searches for songs by a snippet of lyrics.
  • Arguments:
    • lyrics (str): Lyric snippet to search for.
  • Returns: List of Document objects with songs matching the lyrics.

load_songs_by_tag

  • Description: Loads songs by a specific tag or genre.
  • Arguments:
    • tag (str): Tag or genre to search for.
    • max_songs (Optional[int]): Max number of songs to fetch.
    • max_pages (int): Max number of pages to fetch.
  • Returns: List of Document objects with song lyrics.
from llama_index.readers.genius import GeniusReader

access_token = "your_generated_access_token"

loader = GeniusReader(access_token)
documents = loader.search_songs_by_lyrics("Imagine")

Example

This loader is designed to be used as a way to load data into LlamaIndex.

LlamaIndex

from llama_index.core import VectorStoreIndex, download_loader

from llama_index.readers.genius import GeniusReader

access_token = "your_generated_access_token"

loader = GeniusReader(access_token)
documents = loader.search_songs_by_lyrics("Imagine")
index = VectorStoreIndex.from_documents(documents)
index.query(
    "What artists have written songs that have the lyrics imagine in them?"
)

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

llama_index_readers_genius-0.6.0.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

llama_index_readers_genius-0.6.0-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file llama_index_readers_genius-0.6.0.tar.gz.

File metadata

  • Download URL: llama_index_readers_genius-0.6.0.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for llama_index_readers_genius-0.6.0.tar.gz
Algorithm Hash digest
SHA256 afb146126fb1c4cfda80205d1906f6a5d5266658397e174bd5cbd9025a19c1b1
MD5 0a0323fb3552d821574f65af93097780
BLAKE2b-256 8dba4992c45445eb11362bfb62977590a6ba86796af55110b4b6b485484a8c82

See more details on using hashes here.

File details

Details for the file llama_index_readers_genius-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: llama_index_readers_genius-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for llama_index_readers_genius-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f65c9f01912fb8d48442eb4d35387859727ba89de7fe885877a14002194d658d
MD5 11ee9f6b967c845a3b86ce13b209b34c
BLAKE2b-256 61958872b8b2531defb9166de21655b161f271ca6e82b8acad9a00369522aa6b

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.6.0 This release

2 files

0.5.0

2 files

0.4.1

2 files

0.4.0

2 files

0.3.0

2 files

0.2.0

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

0.0.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page