Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/scriptex/lastfm-ts-api
API client for Last.FM with full TypeScript support
https://github.com/scriptex/lastfm-ts-api
lastfm-api
Last synced: 10 days ago
JSON representation
API client for Last.FM with full TypeScript support
- Host: GitHub
- URL: https://github.com/scriptex/lastfm-ts-api
- Owner: scriptex
- License: mit
- Created: 2021-03-17T06:50:07.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-05-14T11:37:51.000Z (6 months ago)
- Last Synced: 2024-05-14T12:44:02.132Z (6 months ago)
- Topics: lastfm-api
- Language: TypeScript
- Homepage: https://atanas.info/portfolio/open-source/lastfm-ts-api
- Size: 286 KB
- Stars: 13
- Watchers: 5
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
[![Github Build](https://github.com/scriptex/lastfm-ts-api/workflows/Build/badge.svg)](https://github.com/scriptex/lastfm-ts-api/actions?query=workflow%3ABuild)
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/34d3d75710534dc6a38c3584a1dcd068)](https://www.codacy.com/gh/scriptex/lastfm-ts-api/dashboard?utm_source=github.com&utm_medium=referral&utm_content=scriptex/lastfm-ts-api&utm_campaign=Badge_Grade)
[![Codebeat Badge](https://codebeat.co/badges/d765a4c8-2c0e-44f2-89c3-fa364fdc14e6)](https://codebeat.co/projects/github-com-scriptex-lastfm-ts-api-master)
[![CodeFactor Badge](https://www.codefactor.io/repository/github/scriptex/lastfm-ts-api/badge)](https://www.codefactor.io/repository/github/scriptex/lastfm-ts-api)
[![DeepScan grade](https://deepscan.io/api/teams/3574/projects/5257/branches/40799/badge/grade.svg)](https://deepscan.io/dashboard#view=project&tid=3574&pid=5257&bid=40799)
[![Analytics](https://ga-beacon-361907.ew.r.appspot.com/UA-83446952-1/github.com/scriptex/lastfm-ts-api/README.md?pixel)](https://github.com/scriptex/lastfm-ts-api/)# Last.FM TypeScript API Client
> A API client for the Last.FM API written in TypeScript
See the [Last.FM API](https://www.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](https://img.shields.io/github/stars/scriptex/lastfm-ts-api?style=social)
![GitHub forks](https://img.shields.io/github/forks/scriptex/lastfm-ts-api?style=social)
![GitHub watchers](https://img.shields.io/github/watchers/scriptex/lastfm-ts-api?style=social)
![GitHub followers](https://img.shields.io/github/followers/scriptex?style=social)## Code stats
![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/scriptex/lastfm-ts-api)
![GitHub repo size](https://img.shields.io/github/repo-size/scriptex/lastfm-ts-api?style=plastic)
![GitHub language count](https://img.shields.io/github/languages/count/scriptex/lastfm-ts-api?style=plastic)
![GitHub top language](https://img.shields.io/github/languages/top/scriptex/lastfm-ts-api?style=plastic)
![GitHub last commit](https://img.shields.io/github/last-commit/scriptex/lastfm-ts-api?style=plastic)## Installation
```sh
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.
```js
// 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.
```js
user.getRecentTracks({
user: 'USER'
});
```## LICENSE
MIT
---
Connect with me:
---