├── .gitignore ├── README.md ├── examples ├── artist_blogs.js ├── artist_search.js ├── artist_songs.js ├── codemonkey.mp3 ├── rosetta.js ├── song_search.js ├── tasteprofile.js └── track_upload.js ├── index.js └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # echojs 2 | 3 | An implementation of the Echonest API for Node.js. 4 | 5 | ``` 6 | $ npm install echojs 7 | $ export ECHONEST_KEY= 8 | ``` 9 | 10 | Then to get started: 11 | 12 | ```js 13 | var echojs = require('echojs'); 14 | 15 | var echo = echojs({ 16 | key: process.env.ECHONEST_KEY 17 | }); 18 | 19 | // http://developer.echonest.com/docs/v4/song.html#search 20 | echo('song/search').get({ 21 | artist: 'radiohead', 22 | title: 'karma police' 23 | }, function (err, json) { 24 | console.log(json.response); 25 | }); 26 | ``` 27 | 28 | ## Steps 29 | 30 | * **Register for an API key:** 31 | * **API Documentation:** 32 | * **[Read examples for the Echonest API](https://github.com/tcr/echojs/tree/master/examples)** 33 | * **[Submit issues or pull requests](https://github.com/tcr/echojs/issues)** 34 | 35 | ## Links 36 | 37 | * **[Remix.js](http://echonest.github.com/remix/javascript.html)** — Uses the HTML5 Audio API to remix sound in your browser. 38 | * **[jquery.rdio.js](https://github.com/rdio/jquery.rdio.js)** — Play music from Rdio's Web Playback API. 30 second samples for free, and full music streams available to Rdio subscribers. 39 | 40 | ## License 41 | 42 | MIT -------------------------------------------------------------------------------- /examples/artist_blogs.js: -------------------------------------------------------------------------------- 1 | var echojs = require('echojs'); 2 | 3 | var echo = echojs({ 4 | key: process.env.ECHONEST_KEY 5 | }); 6 | 7 | // http://developer.echonest.com/docs/v4/artist.html#blogs 8 | echo('artist/blogs').get({ 9 | id: 'ARH6W4X1187B99274F' 10 | }, function (err, json) { 11 | console.log('Radiohead blogs (id ARH6W4X1187B99274F)'); 12 | console.log(json.response); 13 | }); -------------------------------------------------------------------------------- /examples/artist_search.js: -------------------------------------------------------------------------------- 1 | var echojs = require('echojs'); 2 | 3 | var echo = echojs({ 4 | key: process.env.ECHONEST_KEY 5 | }); 6 | 7 | // http://developer.echonest.com/docs/v4/artist.html#search 8 | echo('artist/search').get({ 9 | name: 'radiohead' 10 | }, function (err, json) { 11 | console.log(json.response); 12 | }); -------------------------------------------------------------------------------- /examples/artist_songs.js: -------------------------------------------------------------------------------- 1 | var echojs = require('echojs'); 2 | 3 | var echo = echojs({ 4 | key: process.env.ECHONEST_KEY 5 | }); 6 | 7 | // http://developer.echonest.com/docs/v4/artist.html#songs 8 | echo('artist/songs').get({ 9 | id: 'ARH6W4X1187B99274F', 10 | results: 20 11 | }, function (err, json) { 12 | console.log('Radiohead songs (id ARH6W4X1187B99274F)'); 13 | console.log(json.response); 14 | }); -------------------------------------------------------------------------------- /examples/codemonkey.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tcr/echojs/81e72e172c1415fe937939a3ad06b0fed3929762/examples/codemonkey.mp3 -------------------------------------------------------------------------------- /examples/rosetta.js: -------------------------------------------------------------------------------- 1 | var echojs = require('echojs'); 2 | 3 | var echo = echojs({ 4 | key: process.env.ECHONEST_KEY 5 | }); 6 | 7 | // http://developer.echonest.com/docs/v4/artist.html#profile 8 | echo('artist/profile').get({ 9 | id: 'ARH6W4X1187B99274F', 10 | bucket: ['id:7digital-US', 'id:spotify-WW', 'id:twitter'] 11 | }, function (err, json) { 12 | var foreign_ids = json.response.artist.foreign_ids; 13 | console.log('Radiohead\'s IDs on other services:'); 14 | console.log(json.response.artist); 15 | 16 | echo('artist/profile').get({ 17 | id: foreign_ids[0].foreign_id 18 | }, function (err, json) { 19 | console.log('\n...and from', foreign_ids[0].foreign_id, 'back to Echonest:'); 20 | console.log(json.response); 21 | }); 22 | }); -------------------------------------------------------------------------------- /examples/song_search.js: -------------------------------------------------------------------------------- 1 | var echojs = require('echojs'); 2 | 3 | var echo = echojs({ 4 | key: process.env.ECHONEST_KEY 5 | }); 6 | 7 | // http://developer.echonest.com/docs/v4/song.html#search 8 | echo('song/search').get({ 9 | artist: 'radiohead', 10 | title: 'karma police' 11 | }, function (err, json) { 12 | console.log(json.response); 13 | }); -------------------------------------------------------------------------------- /examples/tasteprofile.js: -------------------------------------------------------------------------------- 1 | var echojs = require('echojs'); 2 | 3 | var echo = echojs({ 4 | key: process.env.ECHONEST_KEY 5 | }); 6 | 7 | echo.debug = true; 8 | 9 | // http://developer.echonest.com/docs/v4/catalog.html#create 10 | echo('catalog/create').post({ 11 | type: 'general', 12 | name: Math.random().toString(36).substr(2,10) 13 | }, function (err, json) { 14 | console.log(err, json); 15 | 16 | // Uploaded bundle. You must JSON.stringify this when 17 | // calling catalog/update. 18 | var items = [ 19 | { 20 | "action":"update", 21 | "catalog_keyvalues": { 22 | "type": "station", 23 | "format": "classic rock", 24 | "call-letters": "WGIR", 25 | "zipcode": "03101" 26 | } 27 | } 28 | ]; 29 | 30 | echo('catalog/update').post({ 31 | id: json.response.id, 32 | data: JSON.stringify(items) 33 | }, function (err, json) { 34 | console.log(err, json); 35 | }); 36 | }); -------------------------------------------------------------------------------- /examples/track_upload.js: -------------------------------------------------------------------------------- 1 | var echojs = require('echojs') 2 | , fs = require('fs') 3 | , path = require('path'); 4 | 5 | var echo = echojs({ 6 | key: process.env.ECHONEST_KEY 7 | }); 8 | 9 | // http://developer.echonest.com/docs/v4/song.html#search 10 | var location = __dirname + '/codemonkey.mp3'; 11 | fs.readFile(location, function (err, buffer) { 12 | echo('track/upload').post({ 13 | filetype: path.extname(location).substr(1) 14 | }, 'application/octet-stream', buffer, function (err, json) { 15 | console.log(json.response); 16 | }); 17 | }); -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | var rem = require('rem'); 2 | 3 | module.exports = function (config) { 4 | return rem.connect('echonest.com', '4').configure(config); 5 | }; 6 | 7 | // ~fin~ -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "echojs", 3 | "version": "0.1.4", 4 | "description": "Echonest API for Node.js and browsers.", 5 | "main": "index.js", 6 | "directories": { 7 | "example": "examples" 8 | }, 9 | "dependencies": { 10 | "rem": "~0.6.3-2" 11 | }, 12 | "repository": "http://github.com/tcr/echojs", 13 | "author": "Tim Cameron Ryan", 14 | "license": "MIT" 15 | } 16 | --------------------------------------------------------------------------------