• Blog
  • Docs
  • Pricing
  • We’re hiring!
Log inSign up
pinjasaur

pinjasaur

lastfm

Public
Like
lastfm
Home
Code
3
README.md
H
lastfm.ts
main.ts
Branches
1
Pull requests
Remixes
History
Environment variables
1
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Sign up now
Code
/
Code
/
Search
README.md

Last.fm Top Track API

A simple HTTP API that returns the top track for the most recent week from Last.fm.

Files

  • lastfm.ts - HTTP endpoint that fetches and returns the top track from the past 7 days
  • main.ts - Empty placeholder file

API Endpoint

GET /

Returns the most played track for user "pinjasaur" from the past 7 days.

Response Format:

{ "track": { "name": "Track Name", "artist": "Artist Name", "playcount": 42, "url": "https://www.last.fm/music/Artist/_/Track", "image": "https://lastfm.freetls.fastly.net/i/u/300x300/image.png" }, "period": { "from": "2026-01-09T16:50:28.000Z", "to": "2026-01-16T16:50:28.000Z" }, "user": "pinjasaur" }

Error Responses:

  • 500 - API key not configured or Last.fm API error
  • 404 - No tracks found for the past week

Configuration

Requires the LAST_FM_API_KEY environment variable to be set with a valid Last.fm API key.

Features

  • Uses Last.fm's predefined "7day" period for better reliability
  • Falls back to custom date range if needed
  • Returns the largest available album artwork
  • Includes caching headers (1 hour cache)
  • Proper error handling and TypeScript types
Code
README.md
H
lastfm.ts
main.ts
FeaturesVersion controlCode intelligenceCLIMCP
Use cases
TeamsAI agentsSlackGTM
DocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
PricingNewsletterBlogAboutCareers
We’re hiring!
Brandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Open Source Pledge
Terms of usePrivacy policyAbuse contact
© 2026 Val Town, Inc.