@39choko/lastfm is a NodeJS module that allows you to interacting with the LastFM API.
npm install @39choko/lastfm
yarn add @39choko/lastfm
pnpm add @39choko/lastfm
bun add @39choko/lastfm
deno install npm:@39choko/lastfmFirst, you need to obtain an API key from Last.fm. You can get one here: https://www.last.fm/api/account/create
const { Client } = require('@39choko/lastfm');
const lastfm = new Client(
apiKey: 'YOUR_API_KEY', {
/* Optional Parameters: */
apiSecret: 'YOUR_API_SECRET', // Required for some methods like authentication
appName: 'YourAppName' // Optional, but it's recommended
}
);
await lastfm.login() // If you want to login into lastFM <- Need apiSecretGetting Artist Info
await lastfm.artist.getInfo({ artist: "Cher" }).then(console.log);
// Or
const artistGetInfo = await lastfm.artist.getInfo({ artist: "Cher" });
console.log(artistGetInfo);Searching for a Track
await lastfm.track.search({ track: "Believe" }).then(console.log);
// Or
const trackSearch = await lastfm.track.search({ track: "Believe" }).then(console.log);
console.log(trackSearch);Adding a Tag to an Album
// You need to be logged in first
await lastfm.login();
await lastfm.album.addTags({ album: "ECHO", artist: "Crusher-P", tags: ["favorites", "study"] }); // return undefined