lastfm-rs

A blazing-fast Rust SDK and CLI for last.fm

Access your personal Last.fm data with full authentication support. Built with Rust for optimal performance and deployed on Cloudflare's edge network.

31+ Commands
10 Categories
100% Rust

Key Features

πŸ”

Full Authentication

Access your personal Last.fm data including loved tracks, recent plays, and listening statistics

πŸš€

High Performance

Built with Rust for optimal speed and efficiency, deployed on Cloudflare's global edge network

πŸ’Ύ

Smart Caching

KV-based caching with intelligent TTL management for faster responses and reduced API calls

πŸ›‘οΈ

Rate Limiting

Built-in protection against API abuse with configurable limits per IP address

πŸ“Š

Multiple Formats

Export data as JSON, tables, pretty-print, or compact format for easy integration

🎨

Rich CLI

Beautiful command-line interface with colored output and interactive authentication

πŸ“–

Interactive API Docs

Beautiful Swagger UI with live API testing, OpenAPI 3.0 spec, and comprehensive examples

Quick Start

Install CLI

# Install from source
cargo install --path . --bin lastfm-cli

# Or use the install script
./scripts/install-cli.sh

Authenticate

# Login to Last.fm
lastfm-cli auth login

# Check status
lastfm-cli auth status

Interactive Examples

Explore the CLI capabilities with real command outputs

$ lastfm-cli my recent-tracks --limit 5
🎡 Recent Tracks for guitaripod

1. Paranoid Android β€’ Radiohead
   OK Computer β€’ 2 minutes ago

2. Everlong β€’ Foo Fighters
   The Colour and the Shape β€’ 6 minutes ago

3. Time β€’ Pink Floyd
   The Dark Side of the Moon β€’ 10 minutes ago

4. Under the Bridge β€’ Red Hot Chili Peppers
   Blood Sugar Sex Magik β€’ 14 minutes ago

5. Wonderwall β€’ Oasis
   (What's the Story) Morning Glory? β€’ 18 minutes ago
$ lastfm-cli my top-artists --period 1month --limit 5
🎀 Top Artists - Last Month

1. Radiohead
   Plays: 187 β€’ 12.3% of total

2. Pink Floyd
   Plays: 156 β€’ 10.2% of total

3. Led Zeppelin
   Plays: 143 β€’ 9.4% of total

4. The Beatles
   Plays: 128 β€’ 8.4% of total

5. Foo Fighters
   Plays: 115 β€’ 7.6% of total
$ lastfm-cli my top-tracks --period 7day -o table
Top Tracks - Last 7 Days

β”Œβ”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”
β”‚ #   β”‚ Track                    β”‚ Artist              β”‚ Plays β”‚
β”œβ”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€
β”‚ 1   β”‚ Paranoid Android         β”‚ Radiohead           β”‚ 23    β”‚
β”‚ 2   β”‚ Stairway to Heaven       β”‚ Led Zeppelin        β”‚ 19    β”‚
β”‚ 3   β”‚ Wish You Were Here       β”‚ Pink Floyd          β”‚ 17    β”‚
β”‚ 4   β”‚ Bohemian Rhapsody        β”‚ Queen               β”‚ 15    β”‚
β”‚ 5   β”‚ Hotel California         β”‚ Eagles              β”‚ 14    β”‚
β””β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”˜
$ lastfm-cli my loved-tracks --limit 5
❀️  Loved Tracks

β€’ In the Court of the Crimson King
  King Crimson β€’ Loved 2 days ago

β€’ Echoes
  Pink Floyd β€’ Loved 1 week ago

β€’ A Day in the Life
  The Beatles β€’ Loved 2 weeks ago

β€’ Kashmir
  Led Zeppelin β€’ Loved 3 weeks ago

β€’ 2112
  Rush β€’ Loved 1 month ago
$ lastfm-cli artist similar "Radiohead" --limit 8
πŸ”„ Artists Similar to Radiohead

1. Thom Yorke β€’ 100% match
2. Atoms for Peace β€’ 89.2% match
3. Portishead β€’ 84.7% match
4. Massive Attack β€’ 82.1% match
5. Sigur RΓ³s β€’ 79.5% match
6. Godspeed You! Black Emperor β€’ 77.3% match
7. Interpol β€’ 75.8% match
8. The National β€’ 74.2% match
$ lastfm-cli artist info "Pink Floyd"
🎸 Pink Floyd

Listeners: 4,954,829
Playcount: 526,418,203
On Tour: No

Tags:
progressive rock psychedelic rock classic rock rock psychedelic

Biography:
Pink Floyd were an English rock band formed in London in 1964. 
Gaining an early following as one of the first British psychedelic 
groups, they were distinguished for their extended compositions...

Similar Artists:
David Gilmour, Roger Waters, Led Zeppelin, Yes, Genesis
$ lastfm-cli album info "The Dark Side of the Moon" "Pink Floyd"
πŸ’Ώ The Dark Side of the Moon
Pink Floyd β€’ 1973

Listeners: 2,823,481
Playcount: 102,947,582
Duration: 42:49

Tracklist:
1. Speak to Me / Breathe (3:58)
2. On the Run (3:35)
3. Time (6:53)
4. The Great Gig in the Sky (4:44)
5. Money (6:22)
6. Us and Them (7:50)
7. Any Colour You Like (3:26)
8. Brain Damage (3:47)
9. Eclipse (2:04)

Tags:
progressive rock psychedelic rock concept album
$ lastfm-cli geo top-artists "Japan" --limit 5
🌍 Top Artists in Japan

1. η±³ζ΄₯ηŽ„εΈ« (Kenshi Yonezu)
   284,729 listeners

2. King Gnu
   198,456 listeners

3. YOASOBI
   187,923 listeners

4. Officialι«­η”·dism
   165,234 listeners

5. Ado
   156,789 listeners
$ lastfm-cli tag top-tracks "shoegaze" --limit 5
🏷️  Top Shoegaze Tracks

1. Only Shallow β€’ My Bloody Valentine
   Loveless β€’ 489,234 plays

2. When the Sun Hits β€’ Slowdive
   Souvlaki β€’ 378,456 plays

3. Vapour Trail β€’ Ride
   Nowhere β€’ 312,789 plays

4. Black Metallic β€’ Catherine Wheel
   Ferment β€’ 287,123 plays

5. Dreams Burn Down β€’ Ride
   Nowhere β€’ 245,678 plays
$ lastfm-cli my friends --limit 5
πŸ‘₯ Your Friends

1. musiclover92
   Real name: Sarah Johnson
   Scrobbles: 45,892
   Listening: Time by Pink Floyd

2. indierock4ever
   Real name: Mike Chen
   Scrobbles: 38,456
   Country: πŸ‡ΊπŸ‡Έ United States

3. metalhead87
   Real name: Lars
   Scrobbles: 67,234
   Last seen: 2 hours ago
$ lastfm-cli tasteometer compare "guitaripod" "musiclover92"
🎡 Music Compatibility

guitaripod 🀝 musiclover92

78.4% SUPER

Artists in Common:
β€’ Pink Floyd (both love)
β€’ Radiohead (both love)
β€’ The Beatles
β€’ Led Zeppelin
β€’ David Bowie

Unique to guitaripod:
King Crimson, Yes, Genesis

Unique to musiclover92:
Arcade Fire, The National, Bon Iver
$ lastfm-cli my top-tracks --period overall --limit 1000 -o json | head -20
{
  "toptracks": {
    "track": [
      {
        "name": "Paranoid Android",
        "playcount": "453",
        "artist": {
          "name": "Radiohead",
          "mbid": "a74b1b7f-71a5-4011-9441-d0b5e4122711"
        },
        "@attr": {
          "rank": "1"
        }
      },
      {
        "name": "Stairway to Heaven",
        "playcount": "412",
        "artist": {
          "name": "Led Zeppelin",
          "mbid": "678d88b2-87b0-403b-b63d-5da7465aecc3"
        }
...

πŸš€ Backend API

Powerful REST API with 40+ endpoints for accessing Last.fm data

πŸ“–

Interactive Documentation

Explore and test API endpoints with our beautiful Swagger UI

πŸ”‘

Simple Authentication

Just pass your API key as a query parameter

⚑

Edge Performance

Deployed globally on Cloudflare's network for low latency

Explore API Documentation

Available formats: JSON β€’ YAML

Ready to explore your music data?

Get started with lastfm-rs today and unlock the full potential of your Last.fm listening history.