Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

genius-wrapi

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

genius-wrapi

Wrapper for Genius API

latest
Source
npmnpm
Version
0.1.0
Version published
Maintainers
1
Created
Source

Genius API Wrapper

Client interface for accessing Genius API.

Installation

Install via npm

npm install genius-wrapi --save

Usage

Create a client object with the access_token to connect to Genius API endpoints.

var geniusWrapi = require('genius-wrapi');

var client = new geniusWrapi(GENIUS_ACCESS_TOKEN);

// Now you are ready to make API calls to Genius.

Provide parameters and a callback.

API calls follow this syntax:

client.apimethod(param1, ..., queryString, post_payload, callback);

  • param - (if required) url parameters - eg: For annotations.get the value for :id.
  • queryString - (as required) API method parameters as key-value pairs.
  • post_payload - (as required) payload for POST requests - eg annotations.create

Examples

Get data for a specific annotation.

client.annotations.get('6737668', function(err, data) {
  if (!err) {
    console.log(data);
  } 
});

Creates a new annotation on a public web page.

var payload = {
  "annotation": {
    "body": {
      "markdown": "hello **world!**"
    }
  },
  "referent": {
    "raw_annotatable_url": "http://seejohncode.com/2014/01/27/vim-commands-piping/",
    "fragment": "execute commands",
    "context_for_display": {
      "before_html": "You may know that you can ",
      "after_html": " from inside of vim, with a vim command:"
    }
  },
  "web_page": {
    "canonical_url": null,
    "og_url": null,
    "title": "Secret of Mana"
  }
};
client.annotations.create(payload, function(err, data) {
  if (!err) {
    console.log(data);
  }	
});

Songs for the specified artist.

client.artists.songs('16775', function(err, data) {
  if (!err) {
    console.log(data);
  } 
});

Retrieve information about a web page.

client.webpages.lookup(
  {
    aw_annotatable_url:'https://docs.genius.com'
  }, 
  function(err, data) {
    if (!err) {
      console.log(data);
    } 
  }
);

Search documents hosted on Genius.

client.search(
  {
    q:'Kendrick Lamar'
  }, 
  function(err, data) {
    if (!err) {
      console.log(data);
    } 
  }
);

API Functions

Annotations

  • annotations.get
  • annotations.create
  • annotations.update
  • annotations.delete
  • annotations.upvote
  • annotations.unvote
  • annotations.downvote

Referents

  • referents

Songs

  • songs

Artists

  • artists
  • artists.songs

Web Pages

  • web_pages.lookup
  • search

Account

  • account

License

MIT

Keywords

genius

FAQs

Package last updated on 16 May 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts