Tap into The Echo Nest's Musical Brain for the best music search, information, recommendations and remix tools on the web.
Pyechonest is an open source Python library for the Echo Nest API. With Pyechonest you have Python access to the entire set of API methods including:
- artist - search for artists by name, description, or attribute, and get back detailed information about any artist including audio, similar artists, blogs, familiarity, hotttnesss, news, reviews, urls and video.
- song - search songs by artist, title, description, or attribute (tempo, duration, etc) and get detailed information back about each song, such as hotttnesss, audio_summary, or tracks.
- track - upload a track to the Echo Nest and receive summary information about the track including key, duration, mode, tempo, time signature along with detailed track info including timbre, pitch, rhythm and loudness information.
There are a few different ways you can install pyechonest:
- Use setuptools:
easy_install -U pyechonest - Download the zipfile from the releases page and install it.
- Checkout the source:
git clone git://github.com/echonest/pyechonest.gitand install it yourself.
- Install Pyechonest
- Get an API key - to use the Echo Nest API you need an Echo Nest API key. You can get one for free at developer.echonest.com.
- Set the API key - you can do this one of two ways:
- set an environment variable named
ECHO_NEST_API_KEYto your API key - Include this snippet of code at the beginning of your python scripts:
frompyechonestimportconfigconfig.ECHO_NEST_API_KEY="YOUR API KEY"- Check out the docs and examples below.
All examples assume you have already setup your api key!
Find artists that are similar to 'Bikini Kill':
frompyechonestimportartistbk=artist.Artist('bikini kill')
print"Artists similar to: %s:"% (bk.name,)
forsimilar_artistinbk.similar: print"\t%s"% (similar_artist.name,)Search for artist:
frompyechonestimportartistweezer_results=artist.search(name='weezer')
weezer=weezer_results[0]
weezer_blogs=weezer.blogsprint'Blogs about weezer:', [blog.get('url') forbloginweezer_blogs]Get an artist by name:
frompyechonestimportartista=artist.Artist('lady gaga')
printa.idGet an artist by Musicbrainz ID:
frompyechonestimportartista=artist.Artist('musicbrainz:artist:a74b1b7f-71a5-4011-9441-d0b5e4122711')
printa.nameGet the top hottt artists:
frompyechonestimportartistforhottt_artistinartist.top_hottt():
printhottt_artist.name, hottt_artist.hotttnesssSearch for songs:
frompyechonestimportsongrkp_results=song.search(artist='radiohead', title='karma police')
karma_police=rkp_results[0]
printkarma_police.artist_locationprint'tempo:',karma_police.audio_summary['tempo'],'duration:',karma_police.audio_summary['duration']Get a song's audio_url and analysis_url:
frompyechonestimportsongss_results=song.search(artist='the national', title='slow show', buckets=['id:7digital-US', 'tracks'], limit=True)
slow_show=ss_results[0]
ss_tracks=slow_show.get_tracks('7digital-US')
printss_tracks[0].get('preview_url')