npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

lastfm-ts-api

v2.1.0

Published

An API client for the Last.FM API written in TypeScript

Downloads

839

Readme

Github Build Codacy Badge Codebeat Badge CodeFactor Badge DeepScan grade Analytics

Last.FM TypeScript API Client

A API client for the Last.FM API written in TypeScript

See the Last.FM API for information about the Last.Fm API, including details on how to register an account and get your API key, shared secret, and session key.

Visitor stats

GitHub stars GitHub forks GitHub watchers GitHub followers

Code stats

GitHub code size in bytes GitHub repo size GitHub language count GitHub top language GitHub last commit

Installation

npm install lastfm-ts-api

# or

yarn add lastfm-ts-api

Usage

lastfm-ts-api exposes several classes which interact with different parts of the Last.FM API. These classes can be used to interact with the corresponding parts of the Last.FM API. First, you must instantiate these classes with arguments containing the details of your API account. apiKey is required, however since many endpoints of the API do not require authentication, secret and sessionKey are optional.

// To interact with the Album API:
import { LastFMAlbum } from 'lastfm-ts-api';

const album = new LastFMAlbum('API_KEY', 'SECRET', 'SESSION_KEY');

// To interact with the Artist API:
import { LastFMArtist } from 'lastfm-ts-api';

const artist = new LastFMArtist('API_KEY', 'SECRET', 'SESSION_KEY');

// To interact with the Auth API:
import { LastFMAuth } from 'lastfm-ts-api';

const auth = new LastFMAuth('API_KEY', 'SECRET', 'SESSION_KEY');

// To interact with the Chart API:
import { LastFMChart } from 'lastfm-ts-api';

const chart = new LastFMChart('API_KEY', 'SECRET', 'SESSION_KEY');

// To interact with the Geo API:
import { LastFMGeo } from 'lastfm-ts-api';

const geo = new LastFMGeo('API_KEY', 'SECRET', 'SESSION_KEY');

// To interact with the Library API:
import { LastFMLibrary } from 'lastfm-ts-api';

const library = new LastFMLibrary('API_KEY', 'SECRET', 'SESSION_KEY');

// To interact with the Tag API:
import { LastFMTag } from 'lastfm-ts-api';

const tag = new LastFMTag('API_KEY', 'SECRET', 'SESSION_KEY');

// To interact with the Track API:
import { LastFMTrack } from 'lastfm-ts-api';

const track = new LastFMTrack('API_KEY', 'SECRET', 'SESSION_KEY');

// To interact with the User API:
import { LastFMUser } from 'lastfm-ts-api';

const user = new LastFMUser('API_KEY', 'SECRET', 'SESSION_KEY');

Making Requests

Each of the Last.FM classes contains methods which directly correspond to the Last.FM API methods. For example, endpoint User.getRecentTracks is accessed as user.getRecentTracks() (after instantiating the class as described above).

Parameters can be passed to the API through the params argument as an object that will be sent directly with the request, either as a query for a GET request, or a body for a POST request. The property names will not be transformed or abstracted, and so they must match the endpoint parameters exactly. This is where the TypeScript definitions play significant role - they get picked up by the IDE automatically so you don't need to worry about including/importing them.

user.getRecentTracks({
	user: 'USER'
});

LICENSE

MIT