npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@ansango/lastfm-cli

v0.3.1

Published

CLI for the Last.fm API, built on @ansango/lastfm-api. Read-only by default — no auth required.

Downloads

360

Readme

@ansango/lastfm-cli

CLI for the Last.fm API, built on @ansango/lastfm-api.

Read-only by default. Loads credentials from a standard .env file via dotenv (search order: $LASTFM_CLI_ENV_FILE, ./.env, ~/.lastfm-cli/.env). Emits JSON to stdout, errors to stderr.

Installation

npm install -g @ansango/lastfm-cli
# or, from GitHub (no npm publish needed):
npm install -g github:ansango/lastfm-cli

Credentials

The CLI reads LASTFM_API_KEY from a standard .env file using the dotenv parser (so escapes, multi-line values, $VAR interpolation and export prefix all work).

Search order (first hit wins, unless LASTFM_CLI_ENV_FILE is set):

  1. $LASTFM_CLI_ENV_FILE — absolute path override.
  2. ./.env in the current working directory (the dotenv default).
  3. ~/.lastfm-cli/.env — project-scoped fallback.
LASTFM_API_KEY=your_api_key
LASTFM_BASE_URL=https://ws.audioscrobbler.com/2.0/   # optional

Variables already exported in your shell always win over the file. If none of the above provide LASTFM_API_KEY, the CLI exits with code 2.

Get an API key at https://www.last.fm/api/account/create.

Usage

lastfm <namespace> <method> [key=value ...]
lastfm <namespace> <method> --json '{...}'
lastfm man [namespace | namespace.method] [--markdown] [--all]
lastfm methods [namespace]
lastfm help [namespace.method]
lastfm config

Namespaces

user, album, artist, track, tag, chart, geo, library.

Built-in manual

lastfm man ships a curated reference for every method this CLI exposes — parameters, types, required/optional, and an example invocation.

lastfm man                          # top-level index
lastfm man artist                   # list methods in a namespace
lastfm man artist.getInfo           # full reference for one method
lastfm man --markdown artist        # same listing, emitted as markdown
lastfm man --all --markdown > MAN.md  # dump every method as a single markdown doc

Examples

# Top artists this week for a user
lastfm user getTopArtists user=ansango period=7day limit=20

# Artist info + similar
lastfm artist getInfo artist=Radiohead
lastfm artist getSimilar artist=Radiohead limit=10

# Album lookup
lastfm album getInfo artist=Radiohead album="OK Computer"

# Top tracks by country
lastfm geo getTopTracks country=spain limit=20

# Global chart
lastfm chart getTopArtists limit=50

Periods for user.getTop*: overall | 7day | 1month | 3month | 6month | 12month.

Read-only enforcement

track.scrobble and track.scrobbleMany (the canonical Last.fm names, plus their deprecated aliases track.postTrackScrobble and track.postBatchTrackScrobble) exist on the underlying client but require an authenticated session. This CLI does not support writes — calls to those methods (or any future write method we add to the blocklist) return a clear error:

ERROR: Method "track.scrobble" is an authenticated write operation. This CLI is read-only.

Exit codes

| Code | Meaning | |---|---| | 0 | success | | 1 | generic error (bad args, unknown method, etc.) | | 2 | LASTFM_API_KEY is not set | | 3 | Last.fm API returned an error (rate limit, invalid key, …) |

Development

git clone https://github.com/ansango/lastfm-cli
cd lastfm-cli
npm install
npm run build       # tsc + shebang
npm test            # node:test runner via tsx

Related

  • @ansango/lastfm-api — the underlying Last.fm client (this CLI is a thin wrapper on top of it).

License

MIT