Git Product home page Git Product logo

echonest-clojure-api's Introduction

What it is ?

A library to access the echonest API by clojure.

The library is based on http.async.client

Installation

By using lein just add at your dependencies:

(defproject my-project "1.0.0"
  :dependencies [[org.clojure/clojure "1.2.1"]
				 [echonest-api "0.0.2"]])

Code Example

Before to make any operation must be set an API key, the key can be request here

And set your own API key

(set-api-key! "YOUR API KEY")

Find news about "The Beatles"

echonest-api.core> (analyze-response (basic-query "artist" "news" :query {:name "The Beatles"}))
{:response {:status {:version "4.2", :code 0, :message "Success"}, :start 0, :total 4121, :news [{:name "\"Ruby Tuesday,\" The Rolling Stones", :url "http://www.americansongwriter.com/2012/05/ruby-tuesday-the-rolling-stones/", :summary "always enjoy singing it.\" Keith Richards actually did...

Find the twitter account of "shakira"

echonest-api.core> (analyze-response (basic-query "artist" "twitter" :query {:name "shakira"}))
{:response {:status {:version "4.2", :code 0, :message "Success"}, :artist {:twitter "shakira", :id "AR6PJ8R1187FB5AD70", :name "Shakira"}}}

Recognize song

echonest-api.core> (upload-song "/home/siscia/Music/Move Like Jagger - Maroon 5.mp3" :query {:filetype "mp3"})
echonest-api.core> (analyze-response *1)
{:response {:status {:version "4.2", :code 0, :message "Success"}, :track {:status "complete", :audio_md5 "a02d45a7d3d9b9e29343f9b642e4e7ec", :artist "Maroon 5", :samplerate 44100, :title "Moves Like Jagger (Sex Ray Vision Remix)", :analyzer_version "3.1.0_beta_5", :bitrate 320, :release "", :id "TRPIYYY1372839546F", :md5 "44cadacdae7d5331962fd9b2fd35b8ef"}}}

How it's work

To use the library in the best possible way is neccesary know the API, basic-query take two string and a dictionary, the first string rappresent the category you are looking for (artist, song, track, playlist, catalog, sandbox and oauth) the second string rappresent what field you are asking (in the case of song you could ask search, profile, or identify), the dictionary is the parameter you are passing (for song/profille valid paramaters are id, tack_id, format, bucket and limit).

Every request take the :query dictionary, is not necessary pass the api_key every single time.

The function analyze-response take the response returned by basic-query, if everthing worked fine it return a nice map with the info we was looking for, in case of every problems the function will throw an exception.

The library is now work in an asynchronous way, if wait-response is set to false the function will return a promise.

echonest-api.core> (def song (upload-song "/home/simo/Music/Won't go home without you - Maroon 5.mp3" :query {:filetype "mp3"} :wait-response false))
#'echonest-api.core/song
echonest-api.core> song
#<core$future_call$reify__5684@5b9a82ee: :pending>
echonest-api.core> (println "The flow of execution is free to do something else")
The flow of execution is free to do something else
nil
echonest-api.core> (analyze-response @song) ;;Now i am waiting to get my answer
{:response {:status {:version "4.2", :code 0, :message "Success"}, :track {:status "complete", :audio_md5 "a8a7db8491e576451e5a9f7143f55bd3", :artist "Maroon 5", :artist_id "ARF5M7Q1187FB501E8", :samplerate 44100, :title "Won't Go Home Without You", :analyzer_version "3.1.0_beta_5", :bitrate 199, :release "It Won't Be Soon Before Long", :song_id "SOEVAJI135A660B120", :id "TRZUXPX1378F324198", :md5 "789032754d8fa0d3d03ce4cb28af9e9e"}}

echonest-clojure-api's People

Contributors

siscia avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.