Meet npm Pro: unlimited public & private packages + package-based permissions.Learn more »

genius-api

0.4.1 • Public • Published

genius-api Build Status npm version

by Joakim Ahrlin

node.js client for the Genius API

uses ES6 promises to avoid callback hell.

installation

$ npm install genius-api --save

usage

more information about the different options can be found in the Genius API docs

var api = require('genius-api');
var genius = new api(process.env.GENIUS_CLIENT_ACCESS_TOKEN);
 
//get annotation
genius.annotation(6737668).then(function(response) {
  console.log(response.annotation);
});
 
//get referents by song_id, with options
genius.referents({song_id: 378195}, {per_page: 2}).then(function(response) {
  console.log('referents', response.referents);
});
 
//get referents by web_page_id, with options
genius.referents({web_page_id: 10347}, {per_page: 5}).then(function(response) {
  console.log('referents', response.referents);
});
 
//get song
genius.song(378195).then(function(response) {
  console.log('song', response.song);  
});
 
//get artist
genius.artist(16775).then(function(response) {
  console.log('artist', response.artist);
});
 
//get web page, with options
genius.webPage({raw_annotatable_url: 'https://docs.genius.com'}).then(function(response) {
  console.log('web page', response.web_page);
});
 
//search
genius.search('Run the Jewels').then(function(response) {
  console.log('hits', response.hits);
});
 
//error handling á la promise
genius.song(378195).then(function(response) {
  console.log('song', response.song);
}).catch(function(error) {
  console.error(error);
});

tests

$ git clone https://github.com/jahrlin/genius-api.git
cd genius-api
$ GENIUS_CLIENT_ACCESS_TOKEN={ACCESS_TOKEN} mocha

Install

npm i genius-api

DownloadsWeekly Downloads

174

Version

0.4.1

License

MIT

Last publish

Collaborators

  • avatar