MusixmatchSDK
The MusixmatchSDK
uses the musixmatch
module to access the api. It provides additional features, meta data and additional datasources
.
The current version is 1.0.0
.
Module structure
In the following the library modules structure.
- lib/
- api/
- api.js
- cache/
- persistent.js
- memory.js
- datasource/
- spotify/
- spotify.js
- track.js
- artist.js
- album.js
- playlist.js
- category.js
- spotify/
- config.js
- mxmapi.js
- mxmbase64.js
- mxmlogger.js
- mxmstringutil.js
- mxmutil.js
Import
To import the module the client module shall import musixmatch-sdk
and public interfaces to be used.
// Musixmatch SDKvar MusixmatchSDK = ;var MXMUtil=MusixmatchSDKUtil;var MXMLogger=MusixmatchSDKLogger;var MXMAPI=MusixmatchSDKAPI;
Configuration
There are several configuration options. Possibile configuration values are showed below:
MXMLogger; MXMAPI;
where the options are
logger : MXMLogger // the default logger class debug : false // true | false to debug persistentCache : true // persistently store api responses memCache : false // temporary in-memory storage cacheFolderPath : './cache/' // persistent storage cache folder
Examples
Here several usage examples. More examples in analysis/
folders and tests/
folders.
// Match a Trackvar input = q_track: 'shake it off' q_artist:'taylor swift';MXMAPI;
A more complicated example shows how to nest more calls like GetAPITrackChart
to retrieve tracks chart and then retrieve subtitles
for them with GetAPIAllSubtitles
.
var params = type: "mxmweekly" hasLyrics : true // true to filter tracks with lyrics country : "us" // possibly the client country pageSize : 2 // num of items in a page maxPages : 1 // each page will have pageSize itemsMusixmatchAPI;//MusixmatchSDK.GetAPITrackChart
Another example shows how to use a different datasource
. Here a custom MusixmatchSDK
initialization add a spotifyAccessToken
for Spotify
data source and debug
to active debubbing info. The SpotifyCategory
and SpotifyPlaylist
objects are used as models
for the data coming from Spotify.GetCategories
and Spotify.GetPlaylists
apis. The SpotifyPlaylist.getTracks
is used to retrieve
spotify/track
objects then.
// SDK ConfigurationMusixmatchSDK; // spotify objectsvar SpotifyCategory = ;var SpotifyPlaylist = ; // spotify listsvar Spotify = ; // Get New ReleasesSpotify; // Get Spotify CategoriesSpotify;