1.1.3 • Published 9 years ago

curryfm v1.1.3

Weekly downloads
3
License
ISC
Repository
github
Last release
9 years ago

:curry: curryfm

Curried Node wrapper around the public GET methods of Lastfm API. Uses Ramda, Babel and ES6.

Usage

npm install --save curryfm;

Then package exports a default curried function which takes 4 arguments:

  • api_key
  • resource - (one of 'user', 'track', 'artist', 'album' etc.)
  • method - (method called on resource e.g. 'getTopTracks', 'getInfo' etc.)
  • params

Check LastFM docs for info regarding these arguments. The function finally returns a Promise.

import curryfm from 'curryfm';
import readjson from 'read-json-sync';

const { api_key: API_KEY } = readjson("./config.json");

const client = curryfm(API_KEY);

const userClient = client("user");
const asrtistClient = client("artist");

const userTopTracks = userClient("getTopTracks");
const artistSimilar = asrtistClient("getSimilar");

const log = async (method, params) => {
  try {
    console.log(await method(params));
  } catch (err) {
    console.error(err);
  }
};

let params = {
 user: "sidjain26",
 period: "7day",
 limit: 10,
 format: "json"
};

log(userTopTracks, params);

params = {
  artist: "Drake",
  limit: 10,
  format: "json"
};

log(artistSimilar, params);

curryfm(API_KEY, "album", "search", {album: "Songs About Jane", limit: 10}).then((result) => {
  console.log(result);
}); // Alternatively you can call the function with all arguments
1.1.3

9 years ago

1.1.2

10 years ago

1.1.1

10 years ago

1.1.0

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago