Andrea Franz

musiXmatch API library for NodeJS

I've just published my first NPM package, and it's called musixmatch. With this library you can easily use the musiXmatch API with a few lines of javascript. Install it with NPM:

npm install -g musixmatch

And here an example:

var util  = require("util");
var mXm   = require("musixmatch");

mXm.Config.API_KEY = "YOUR_API_KEY";

var successCallback = function(modelOrCollection) {
  console.log("Success:");
  console.log("  " + util.inspect(modelOrCollection));
};

var errorCallback = function(response) {
  console.log("Error callback:");
  console.log("  " + util.inspect(response));
};

mXm.API.getTrack(TRACK_ID, successCallback, errorCallback);
mXm.API.getLyrics(LYRICS_ID, successCallback, errorCallback);
mXm.API.getArtist(ARTIST_ID, successCallback, errorCallback);
mXm.API.getAlbum(ALBUM_ID, successCallback, errorCallback);
mXm.API.getSubtitle(TRACK_ID, successCallback, errorCallback);
mXm.API.searchTrack({q: QUERY}, successCallback);

If you want you can set your musiXmatch API KEY as an environment variable, and you won't need to set it in your code:

export MUSIX_MATCH_API_KEY="YOUR_API_KEY"

You can find the source code on github.

#javascript #nodejs

comments powered by Disqus