simple-fm
A simple, asynchronous Last.fm wrapper in TypeScript.
Search for what someone has been listening to lately, what tracks are trending in a country, an artist's top tracks, and
a lot more.
Install
Node.js 16+ and TypeScript v5+ is recommended for this package.
- npm:
npm i @solely/simple-fm
- pnpm:
pnpm i @solely/simple-fm
- yarn:
yarn add @solely/simple-fm
Notice
simple-fm
requires you to have a Last.fm API key.
To obtain a Last.fm API key, click here to register an API account.
Example usage
import SimpleFM from '@solely/simple-fm';
const SimpleFM = require('@solely/simple-fm');
const client = new SimpleFM('Last.fm API key');
const json = await client.user.getRecentTracks({ user: 'solelychloe' });
console.log(json);
If you're using Deno, you can import simple-fm
via a CDN:
import simpleFM from 'https://esm.sh/@solely/simple-fm';
Documentation
album
album.getInfo({ artist, album, username? })
Returns metadata information for an album.
-
artist
(string): The name of the artist.
-
album
(string): The name of the album.
-
username?
(string): The username for the context of the request. If supplied, the user's playcount for this artist's album is included in the response.
album.getTopTags({ artist, album })
Returns popular tags for an album.
-
artist
(string): The name of the artist.
-
album
(string): The name of the album.
album.search({ album, limit?, page? })
Search for an album by name.
-
album
(string): The name of the album.
-
limit?
(number): The number of results to fetch per page. Defaults to 30.
-
page?
(number): The page number to fetch. Defaults to the first page.
artist
artist.getInfo({ artist, username? })
Returns metadata information for an artist.
-
artist
(string): The artist's name.
-
username?
(string): The username for the context of the request. If supplied, the user's playcount for this artist is included in the response.
artist.getSimilar({ artist, limit? })
Returns similar artists to this artist.
-
artist
(string): The artist's name.
-
limit?
(number): The number of results to fetch per page. Defaults to 30.
artist.getTopAlbums({ artist, limit?, page? })
Returns popular albums for an artist.
-
artist
(string): The artist's name.
-
limit?
(number): The number of results to fetch per page. Defaults to 50.
-
page?
(number): The page number to fetch. Defaults to the first page.
artist.getTopTags({ artist })
Returns popular tags for an artist.
-
artist
(string): The artist's name.
artist.getTopTracks({ artist, limit?, page? })
Returns popular tracks for an artist.
-
artist
(string): The artist's name.
-
limit?
(number): The number of results to fetch per page. Defaults to 50.
-
page?
(number): The page number to fetch. Defaults to the first page.
artist.search({ artist, limit?, page? })
Search for an artist by name.
-
artist
(string): The artist's name.
-
limit?
(number): The number of results to fetch per page. Defaults to 30.
-
page?
(number): The page number to fetch. Defaults to the first page.
chart
chart.getTopArtists({ limit?, page? })
Returns the most popular artists.
-
limit?
(number): The number of results to fetch per page. Defaults to 30.
-
page?
(number): The page number to fetch. Defaults to the first page.
chart.getTopTags({ limit?, page? })
Returns the most popular tags for tracks.
-
limit?
(number): The number of results to fetch per page. Defaults to 30.
-
page?
(number): The page number to fetch. Defaults to the first page.
chart.getTopTracks({ limit?, page? })
Returns the most popular tracks.
-
limit?
(number): The number of results to fetch per page. Defaults to 30.
-
page?
(number): The page number to fetch. Defaults to the first page.
geo
geo.getTopArtists({ country, limit?, page? })
Returns the most popular artists by country.
-
country
(string): The name of the country.
-
limit?
(number): The number of results to fetch per page. Defaults to 50.
-
page?
(number): The page number to fetch. Defaults to the first page.
geo.getTopTracks({ country, limit?, page? })
Returns the most popular tracks by country.
-
country
(string): The name of the country.
-
limit?
(number): The number of results to fetch per page. Defaults to 50.
-
page?
(number): The page number to fetch. Defaults to the first page.
tag
tag.getInfo({ tag })
Returns metadata information on a tag.
-
tag
(string): The name of the tag.
tag.getTopAlbums({ tag, limit?, page? })
-
tag
(string): The name of the tag.
-
limit?
(number): The number of results to fetch per page. Defaults to 50.
-
page?
(number): The page number to fetch. Defaults to the first page.
tag.getTopArtists({ tag, limit?, page? })
-
tag
(string): The name of the tag.
-
limit?
(number): The number of results to fetch per page. Defaults to 50.
-
page?
(number): The page number to fetch. Defaults to the first page.
tag.getTopTracks({ tag, limit?, page? })
Returns popular tracks for a tag.
-
tag
(string): The name of the tag.
-
limit?
(number): The number of results to fetch per page. Defaults to 50.
-
page?
(number): The page number to fetch. Defaults to the first page.
tag.getWeeklyChartList({ tag })
Returns a list of available charts for a tag.
-
tag
(string): The name of the tag.
track
track.getInfo({ artist, track, username? })
Returns metadata information for a track.
-
artist
(string): The name of the artist.
-
track
(string): The name of the track.
track.getSimilar({ artist, track, limit? })
Returns similar tracks for this track.
-
artist
(string): The name of the artist.
-
track
(string): The name of the track.
-
limit?
(number): The number of results to fetch per page. Defaults to 30.
track.getTopTags({ artist, track })
Returns popular tags for a track.
-
artist
(string): The name of the artist.
-
track
(string): The name of the track.
track.search({ track, limit?, page? })
Search for a track by name.
-
track
(string): The name of the track.
-
limit?
(number): The number of results to fetch per page. Defaults to 30.
-
page?
(number): The page number to fetch. Defaults to the first page.
user
user.getInfo({ username })
Returns information about a user's profile.
-
username
(string): The name of the user.
user.getTopArtists({ username, limit?, page? })
Returns a list of popular artists in a user's library.
-
username
(string): The name of the user.
-
limit?
(number): The number of results to fetch per page. Defaults to 50.
-
page?
(number): The page number to fetch. Defaults to the first page.
user.getFriends({ username, limit?, page? })
Returns a list of the user's friends.
-
username
(string): The name of the user.
-
limit?
(number): The number of results to fetch per page. Defaults to 50.
-
page?
(number): The page number to fetch. Defaults to the first page.
user.getLovedTracks({ username, limit?, page? })
Returns the loved tracks as set by the user.
-
username
(string): The name of the user.
-
limit?
(number): The number of results to fetch per page. Defaults to 50.
-
page?
(number): The page number to fetch. Defaults to the first page.
user.getPersonalTags({ username, tag, tagType })
Returns a list of the user's personal tags.
-
username
(string): The name of the user.
-
tag
(string): The name of the tag.
-
tagType
(album, artist, track): The type of items which have been tagged.
user.getRecentTracks({ username, limit?, page? })
Returns the most recent track listened by the user.
-
username
(string): The name of the user.
-
limit?
(number): The number of results to fetch per page. Defaults to 50. Maximum is 200.
-
page?
(number): The page number to fetch. Defaults to the first page.
user.getTopAlbums({ username, limit?, page? })
Returns a list of popular albums in a user's library.
-
username
(string): The name of the user.
-
limit?
(number): The number of results to fetch per page. Defaults to 50.
-
page?
(number): The page number to fetch. Defaults to the first page.
user.getTopTags({ username, limit? })
-
username
(string): The name of the user.
-
limit?
(number): The number of results to fetch per page. Defaults to 50.
user.getTopTracks({ username, limit?, page? })
Returns a list of popular tracks in a user's library.
-
username
(string): The name of the user.
-
limit?
(number): The number of results to fetch per page. Defaults to 50.
-
page?
(number): The page number to fetch. Defaults to the first page.
License
This package is licensed under the zlib license.
© 2023 Chloe Arciniega.