simple-fm
simple-fm is 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+ 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 token.
To obtain a Last.fm API token, click here to register an API account.
Usage
import client from '@solely/simple-fm';
const lastFM = new client('last.fm token');
const json = await lastFM.user.fetchRecentTrack('solelychloe');
console.log(json);
If you're using Deno, import simple-fm
from a URL. For example, via a CDN:
import client from 'https://esm.sh/@solely/simple-fm';
Documentation
album
album.fetch(artistName, albumName, userName?)
Fetches and returns metadata information for an album.
-
artistName
: The name of the artist.
-
albumName
: The name of the album.
-
userName?
: 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.fetchTopTags(artistName, albumName)
Fetches and returns popular tags for an album.
-
artistName
: The name of the artist.
-
albumName
: The name of the album.
album.search(albumName, limit?, page?)
Search for an album by name.
-
albumName
: The name of the album.
-
limit?
: The number of results to fetch per page. Defaults to 30.
-
page?
: The page number to fetch. Defaults to the first page.
artist
artist.fetch(artistName, userName?)
Fetches and returns metadata information for an artist.
-
artistName
: The artist's name.
-
userName?
: The username for the context of the request. If supplied, the user's playcount for this artist is included in the response.
artist.fetchSimilar(artistName, limit?)
Fetches and returns similar artists to this artist.
-
artistName
: The artist's name.
-
limit?
: The number of results to fetch per page. Defaults to 30.
artist.fetchTopAlbums(artistName, limit?, page?)
Fetches and returns popular albums for an artist.
-
artistName
: The artist's name.
-
limit?
: The number of results to fetch per page. Defaults to 50.
-
page?
: The page number to fetch. Defaults to the first page.
artist.fetchTopTags(artistName)
Fetches and returns popular tags for an artist.
-
artistName
: The artist's name.
artist.fetchTopTracks(artistName, limit?, page?)
Fetches and returns popular tracks for an artist.
-
artistName
: The artist's name.
-
limit?
: The number of results to fetch per page. Defaults to 50.
-
page?
: The page number to fetch. Defaults to the first page.
artist.search(artistName, limit?, page?)
Search for an artist by name.
-
artistName
: The artist's name.
-
limit?
: The number of results to fetch per page. Defaults to 30.
-
page?
: The page number to fetch. Defaults to the first page.
chart
chart.fetchTopArtists(limit?, page?)
Fetches and returns the most popular artists.
-
limit?
: The number of results to fetch per page. Defaults to 30.
-
page?
: The page number to fetch. Defaults to the first page.
chart.fetchTopTags(limit?, page?)
Fetches and returns the most popular tags for tracks.
-
limit?
: The number of results to fetch per page. Defaults to 30.
-
page?
: The page number to fetch. Defaults to the first page.
chart.fetchTopTracks(limit?, page?)
Fetches and returns the most popular tracks.
-
limit?
: The number of results to fetch per page. Defaults to 30.
-
page?
: The page number to fetch. Defaults to the first page.
geo
geo.fetchTopArtists(country, limit?, page?)
Fetches and returns the most popular artists by country.
Ordered by relevance.
-
country
: The name of the country.
-
limit?
: The number of results to fetch per page. Defaults to 50.
-
page?
: The page number to fetch. Defaults to the first page.
geo.fetchTopTracks(country, limit?, page?)
Fetches and returns the most popular tracks by country.
Ordered by relevance.
-
country
: The name of the country.
-
limit?
: The number of results to fetch per page. Defaults to 50.
-
page?
: The page number to fetch. Defaults to the first page.
tag
tag.fetch(tagName)
Fetches and returns metadata information on a tag.
-
tagName
: The name of the tag.
tag.fetchTopAlbums(tagName, limit?, page?)
-
tagName
: The name of the tag.
-
limit?
: The number of results to fetch per page. Defaults to 50.
-
page?
: The page number to fetch. Defaults to the first page.
tag.fetchTopArtists(tagName, limit?, page?)
-
tagName
: The name of the tag.
-
limit?
: The number of results to fetch per page. Defaults to 50.
-
page?
: The page number to fetch. Defaults to the first page.
tag.fetchTopTags()
Fetches and returns popular albums that are tagged by a tag name.
tag.fetchTopTracks(tagName, limit?, page?)
Fetches and returns popular tracks for a tag.
-
tagName
: The name of the tag.
-
limit?
: The number of results to fetch per page. Defaults to 50.
-
page?
: The page number to fetch. Defaults to the first page.
tag.fetchWeeklyChartList(tagName)
Fetches and returns a list of available charts for a tag.
-
tagName
: The name of the tag.
track
track.fetch(artistName, trackName, userName?)
Fetches and returns metadata information for a track.
-
artistName
: The name of the artist.
-
trackName
: The name of the track.
track.fetchSimilar(artistName, trackName, limit?)
Fetches and returns similar tracks for this track.
-
artistName
: The name of the artist.
-
trackName
: The name of the track.
-
limit?
: The number of results to fetch per page. Defaults to 30.
track.fetchTopTags(artistName, trackName)
Fetches and returns popular tags for a track.
-
artistName
: The name of the artist.
-
trackName
: The name of the track.
track.search(trackName, limit?, page?)
Search for a track by name.
-
trackName
: The name of the track.
-
limit?
: The number of results to fetch per page. Defaults to 30.
-
page?
: The page number to fetch. Defaults to the first page.
user
user.fetch(userName)
Fetches and returns information about a user's profile.
-
userName
: The name of the user.
user.fetchAllArtists(userName, limit?, page?)
Fetches and returns a list of all the artists in a user's library.
-
userName
: The name of the user.
-
limit?
: The number of results to fetch per page. Defaults to 50.
-
page?
: The page number to fetch. Defaults to the first page.
user.fetchFriends(userName, limit?, page?)
Fetches and returns a list of the user's friends.
-
userName
: The name of the user.
-
limit?
: The number of results to fetch per page. Defaults to 50.
-
page?
: The page number to fetch. Defaults to the first page.
user.fetchLovedTracks(userName, limit?, page?)
Fetches and returns the loved tracks as set by the user.
-
userName
: The name of the user.
-
limit?
: The number of results to fetch per page. Defaults to 50.
-
page?
: The page number to fetch. Defaults to the first page.
user.fetchPersonalTags(userName, tagName, tagType)
Fetches and returns a list of the user's personal tags.
-
userName
: The name of the user.
-
tagName
: The name of the tag.
-
tagType
: The type of items which have been tagged. Accepted options: album
, artist
, track
user.fetchRecentTracks(userName, limit?, page?)
Fetches and returns the most recent track listened by the user.
-
userName
: The name of the user.
-
limit?
: The number of results to fetch per page. Defaults to 50. Maximum is 200.
-
page?
: The page number to fetch. Defaults to the first page.
user.fetchTopAlbums
Fetches and returns a list of popular albums in a user's library.
-
userName
: The name of the user.
-
limit?
: The number of results to fetch per page. Defaults to 50.
-
page?
: The page number to fetch. Defaults to the first page.
user.fetchTopTags(userName, limit?)
-
userName
: The name of the user.
-
limit?
: The number of results to fetch per page. Defaults to 50.
user.fetchTopTracks(userName, limit?, page?)
Fetches and returns a list of popular tracks in a user's library.
-
userName
: The name of the user.
-
limit?
: The number of results to fetch per page. Defaults to 50.
-
page?
: The page number to fetch. Defaults to the first page.
License
This package is licensed under the zlib license.
© 2023 Chloe Arciniega.