Genius API#
This API requires authentication, and here’s an example of how that works.
import requests
# get an access token
access = 't_5_qC1yaHVuFRV0YKc6-QyiT1J5D-iMTRCYCuTLtgbdqLyIjdOqXxRUAVqiw1is'
# pass your access token as a variable into a "headers" dict
headers = {'Authorization': f'Bearer {access}'}
Here I’m using the “Artists” endpoint, which means I already have an artist ID number on hand, by using the
This endpoint returns data about the artist, and you need the artist ID to access it.
# pass your headers dict into the get() request
r = requests.get('https://api.genius.com/artists/530703', headers=headers)
r
<Response [200]>
parsed = r.json()
parsed.keys()
dict_keys(['meta', 'response'])
parsed['response']['artist'].keys()
dict_keys(['alternate_names', 'api_path', 'description', 'facebook_name', 'header_image_url', 'id', 'image_url', 'instagram_name', 'is_meme_verified', 'is_verified', 'name', 'translation_artist', 'twitter_name', 'url', 'current_user_metadata', 'followers_count', 'iq', 'description_annotation', 'user'])
parsed['response']['artist']['name']
'KAROL G'
Using the “songs” endpoint now, to get data about the song
# path for the songs endpoint: /artists/:id/songs
url = 'https://api.genius.com/artists/530703/songs'
r = requests.get(url, headers=headers)
r
<Response [200]>
parsed = r.json()
parsed['response'].keys()
dict_keys(['songs', 'next_page'])
parsed['response']['songs'][0]
{'annotation_count': 0,
'api_path': '/songs/8719369',
'artist_names': "Q' Lokura & Banda Mix",
'full_title': "200 Copas by\xa0Q'\xa0Lokura & Banda\xa0Mix",
'header_image_thumbnail_url': 'https://images.genius.com/54b7e1a701572b780907f1cd0e5c1b30.300x300x1.jpg',
'header_image_url': 'https://images.genius.com/54b7e1a701572b780907f1cd0e5c1b30.1000x1000x1.jpg',
'id': 8719369,
'lyrics_owner_id': 9433615,
'lyrics_state': 'complete',
'path': '/Q-lokura-and-banda-mix-200-copas-lyrics',
'primary_artist_names': "Q' Lokura & Banda Mix",
'pyongs_count': None,
'relationships_index_url': 'https://genius.com/Q-lokura-and-banda-mix-200-copas-sample',
'release_date_components': {'year': 2021, 'month': 11, 'day': 10},
'release_date_for_display': 'November 10, 2021',
'release_date_with_abbreviated_month_for_display': 'Nov. 10, 2021',
'song_art_image_thumbnail_url': 'https://images.genius.com/54b7e1a701572b780907f1cd0e5c1b30.300x300x1.jpg',
'song_art_image_url': 'https://images.genius.com/54b7e1a701572b780907f1cd0e5c1b30.1000x1000x1.jpg',
'stats': {'unreviewed_annotations': 0, 'hot': False},
'title': '200 Copas',
'title_with_featured': '200 Copas',
'url': 'https://genius.com/Q-lokura-and-banda-mix-200-copas-lyrics',
'featured_artists': [],
'primary_artist': {'api_path': '/artists/3405050',
'header_image_url': 'https://images.genius.com/f7d8ec060a8804559cd0d6400c15a5fe.320x320x1.jpg',
'id': 3405050,
'image_url': 'https://images.genius.com/f7d8ec060a8804559cd0d6400c15a5fe.320x320x1.jpg',
'is_meme_verified': False,
'is_verified': False,
'name': 'Q’ Lokura',
'url': 'https://genius.com/artists/Q-lokura'},
'primary_artists': [{'api_path': '/artists/3405050',
'header_image_url': 'https://images.genius.com/f7d8ec060a8804559cd0d6400c15a5fe.320x320x1.jpg',
'id': 3405050,
'image_url': 'https://images.genius.com/f7d8ec060a8804559cd0d6400c15a5fe.320x320x1.jpg',
'is_meme_verified': False,
'is_verified': False,
'name': 'Q’ Lokura',
'url': 'https://genius.com/artists/Q-lokura'},
{'api_path': '/artists/3405051',
'header_image_url': 'https://assets.genius.com/images/default_avatar_300.png?1745879682',
'id': 3405051,
'image_url': 'https://assets.genius.com/images/default_avatar_300.png?1745879682',
'is_meme_verified': False,
'is_verified': False,
'name': 'Banda Mix',
'url': 'https://genius.com/artists/Banda-mix'}]}
id = parsed['response']['songs'][0]['id']
url = f'https://api.genius.com/songs/{id}'
r = requests.get(url, headers=headers)
parsed = r.json()
parsed['response']['song'].keys()
dict_keys(['annotation_count', 'api_path', 'apple_music_id', 'apple_music_player_url', 'artist_names', 'description', 'embed_content', 'featured_video', 'full_title', 'header_image_thumbnail_url', 'header_image_url', 'id', 'language', 'lyrics_owner_id', 'lyrics_state', 'path', 'primary_artist_names', 'pyongs_count', 'recording_location', 'relationships_index_url', 'release_date', 'release_date_for_display', 'release_date_with_abbreviated_month_for_display', 'song_art_image_thumbnail_url', 'song_art_image_url', 'stats', 'title', 'title_with_featured', 'url', 'current_user_metadata', 'song_art_primary_color', 'song_art_secondary_color', 'song_art_text_color', 'album', 'custom_performances', 'description_annotation', 'featured_artists', 'lyrics_marked_complete_by', 'lyrics_marked_staff_approved_by', 'media', 'primary_artist', 'primary_artists', 'producer_artists', 'song_relationships', 'translation_songs', 'verified_annotations_by', 'verified_contributors', 'verified_lyrics_by', 'writer_artists'])
parsed['response']['song']['description_annotation']
{'_type': 'referent',
'annotator_id': 17336116,
'annotator_login': 'Fri',
'api_path': '/referents/27535384',
'classification': 'needs_exegesis',
'fragment': '200 Copas',
'id': 27535384,
'is_description': True,
'path': '/27535384/Q-lokura-and-banda-mix-200-copas/200-copas',
'range': {'content': '200 Copas'},
'song_id': 8719369,
'url': 'https://genius.com/27535384/Q-lokura-and-banda-mix-200-copas/200-copas',
'verified_annotator_ids': [],
'annotatable': {'api_path': '/songs/8719369',
'client_timestamps': {'updated_by_human_at': 1734710338,
'lyrics_updated_at': 1673467189},
'context': "Q' Lokura & Banda Mix",
'id': 8719369,
'image_url': 'https://images.genius.com/54b7e1a701572b780907f1cd0e5c1b30.1000x1000x1.jpg',
'link_title': '200 Copas by\xa0Q’\xa0Lokura & Banda\xa0Mix',
'title': '200 Copas',
'type': 'Song',
'url': 'https://genius.com/Q-lokura-and-banda-mix-200-copas-lyrics'},
'annotations': [{'api_path': '/annotations/27535384',
'body': {'dom': {'tag': 'root'}},
'comment_count': 0,
'community': True,
'custom_preview': None,
'has_voters': False,
'id': 27535384,
'pinned': False,
'share_url': 'https://genius.com/27535384',
'source': None,
'state': 'needs_exegesis',
'url': 'https://genius.com/27535384/Q-lokura-and-banda-mix-200-copas/200-copas',
'verified': False,
'votes_total': 0,
'current_user_metadata': {'permissions': [],
'excluded_permissions': ['vote',
'edit',
'cosign',
'uncosign',
'destroy',
'accept',
'reject',
'see_unreviewed',
'clear_votes',
'propose_edit_to',
'pin_to_profile',
'unpin_from_profile',
'update_source',
'edit_custom_preview',
'report_as_abusive',
'create_comment'],
'interactions': {'cosign': False, 'pyong': False, 'vote': None},
'iq_by_action': {}},
'authors': [{'attribution': 1.0,
'pinned_role': None,
'user': {'api_path': '/users/17336116',
'avatar': {'tiny': {'url': 'https://images.genius.com/avatars/tiny/9a61f8a9ef70f92f5c6c88ef1a5f028f',
'bounding_box': {'width': 16, 'height': 16}},
'thumb': {'url': 'https://images.genius.com/avatars/thumb/9a61f8a9ef70f92f5c6c88ef1a5f028f',
'bounding_box': {'width': 32, 'height': 32}},
'small': {'url': 'https://images.genius.com/avatars/small/9a61f8a9ef70f92f5c6c88ef1a5f028f',
'bounding_box': {'width': 100, 'height': 100}},
'medium': {'url': 'https://images.genius.com/avatars/medium/9a61f8a9ef70f92f5c6c88ef1a5f028f',
'bounding_box': {'width': 300, 'height': 400}}},
'header_image_url': 'https://images.genius.com/a3f3e4fae808e9426937a2b4180993bf.640x908x1.jpg',
'human_readable_role_for_display': 'Moderator',
'id': 17336116,
'iq': 1336991,
'login': 'Fri',
'name': 'Fri',
'role_for_display': 'moderator',
'url': 'https://genius.com/Fri',
'current_user_metadata': {'permissions': [],
'excluded_permissions': ['follow'],
'interactions': {'following': False}}}}],
'cosigned_by': [],
'rejection_comment': None,
'verified_by': None}]}