Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lastfm-ts-api

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lastfm-ts-api

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

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
138
decreased by-42.74%
Maintainers
1
Weekly downloads
 
Created
Source

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


Connect with me:


Support and sponsor my work:

Keywords

FAQs

Package last updated on 07 Nov 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc