lastfm-nodejs-client
v1.5.2
Published
A NodeJS wrapper client for LastFm API. Fetching public data by username using the LastFm public API
Downloads
49
Maintainers
Readme
LastFm NodeJs client
A Node JS wrapper client for fetching public data from LastFm API.
Fetch server side or client side, thanks to cross-fetch
How to use the client
Install the npm package in your project.
pnpm install
Consider PNPM ▶️
Import it
Import the client module:
import { lastFm } from 'lastfm-nodejs-client';
Import the Types as type:
import type {
Artist,
Track,
User,
WeeklyAlbum,
} from 'lastfm-nodejs-client/dist/@types/lastfm.types';
Working on getting these into DefinitelyTyped
Use it
const lastFm = LastFmApi();
const { config, method } = lastFm;
const getTopArtists = async () => {
const data = await lastFm.getTopArtists(
method.user.top_artists,
config.username,
'overall',
'200',
);
const { topartists } = data;
return topartists;
};
🚀 Gives you:
Developing client
Written in TypeScript, compiles down to ES2015, provides the types for the lastFm entities.
Fork repo
gh repo fork mannuelf/lastfm-nodejs-client
What's gh? Get it here
Postman collections
A list of endpoints currently mapped to this client. Still under development, not feature complete.
ENV
Create .env
file in project root:
You do not need an API key to query the public USER entity, add only base url and a username to env file.
LASTFM_API_BASE_URL=""
LASTFM_USER=""
For everything else you will need to include:
LASTFM_API_KEY=""
LASTFM_APPNAME=""
Create them here.
Develop
pnpm test
pnpm lint
pnpm lint-fix
Build
pnpm build
Publish
pnpm prepare
pnpm publish
Why I built this?
I was building a scrobbles page https://mannuelferreira.com/scrobbles and I thought others might want it to.
TODO
- move types into DefinitelyTyped