/lastfm-api-node-pr

an unofficial last.fm api wrapper with additional scraping functions

Primary LanguageJavaScriptISC LicenseISC

lastfm-api-node

Installation

npm i lastfm-api-node

Usage Example

const { getUserInfo } = require("lastfm-api-node")

return getUserInfo(username, api_key)
   .then((response) => {
      console.log(response)
   })
   .catch((error) => {
      console.log(error)
   })

Documentation

Table of Contents

getArtistCount

Retrieves the count of artists in the user's library.

Usage:

getArtistCount("username", true)
getArtistCount("username", false)

Parameters

  • username string The username of the user whose artist count is being retrieved.
  • cors boolean Whether to use a CORS proxy to bypass CORS restrictions.

Returns Promise A promise that resolves with the number of artists in the user's library.

getUserInfo

Fetches information about a user, such as their username and email.

Usage:

getUserInfo("username", "api_key")

Parameters

  • username string The username of the user whose information is being fetched
  • api_key string The API key for the service.

Returns Promise A promise that resolves with an object containing the user's information.

getCookies

Retrieves all cookies related to the current session.

Usage:

getCookies("nextjs")

Parameters

  • type string The type of cookie you want to use for the service.

Returns Promise A promise that resolves with an object containing all cookies.

setCookies

Sets cookies for the user session. Currently supports only Next.js applications.

Usage:

setCookies("nextjs", "session_key", "username");

Parameters

  • type string The type of application, e.g., "nextjs".
  • session_key string The session key to be stored in the cookie.
  • username string The username to be stored in the cookie.

Returns string A confirmation message or an error message if the type is not supported.

getSession

Fetches the session for a user based on the provided token, signature, and API key.

Usage:

getSession("token", "signature", "api_key")

Parameters

  • token string The token for the session.
  • signature string The signature for the session.
  • api_key string The API key for the service.

Returns Promise A promise that resolves with the session data or rejects with an error.

getRecentTracks

Retrieves the user's recent tracks from the service.

Usage:

getRecentTracks("username", "api_key")

Parameters

  • username string The username whose recent tracks are to be fetched.
  • api_key string The API key for the service.

Returns Promise A promise that resolves with the recent tracks data or rejects with an error.