{"_id":"@beatsphere/lastfm-client","name":"@beatsphere/lastfm-client","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@beatsphere/lastfm-client","version":"0.1.0","description":"Last.fm API client with Zod validation — auth, scrobbles, top tracks/artists/albums, weekly reports","main":"build/index.js","types":"build/index.d.ts","scripts":{"build":"tsc","prepublishOnly":"tsc","clean":"rm -rf build"},"keywords":["lastfm","last.fm","scrobble","music","api","now-playing","zod","typescript"],"author":{"name":"BeatSphere","email":"hello@beatsphere.live"},"license":"MIT","homepage":"https://github.com/Beatsphere/lastfm-client#readme","repository":{"type":"git","url":"git+https://github.com/Beatsphere/lastfm-client.git"},"bugs":{"url":"https://github.com/Beatsphere/lastfm-client/issues"},"dependencies":{"axios":"^1.6.0","zod":"^3.22.0"},"devDependencies":{"typescript":"^5.0.0"},"gitHead":"8e58eb2302da37274567c95f0b3b97974ef4b088","_id":"@beatsphere/lastfm-client@0.1.0","_nodeVersion":"24.12.0","_npmVersion":"11.6.2","dist":{"integrity":"sha512-lM8jBaogllcevqxskOfI40h7Rqqn4nCeRJwhqiTjsmeMmWlDlLqYliEqm+YHboIZ/B4QQeVYgJKS6XrsIDl1qw==","shasum":"0254b0c59555de81df56d6da9f06f8fa93304b88","tarball":"https://registry.npmjs.org/@beatsphere/lastfm-client/-/lastfm-client-0.1.0.tgz","fileCount":13,"unpackedSize":134738,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIGzyi1bWTAummBhDVHOcpAmNMy94RM/yLWE/u4bxO1yZAiEAg4KOR25yL6J1dZtJkE4qoxI60e3yexO0+80QrwM+izg="}]},"_npmUser":{"name":"ayushh2k","email":"rustichouse042@gmail.com"},"directories":{},"maintainers":[{"name":"ayushh2k","email":"rustichouse042@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/lastfm-client_0.1.0_1776972060038_0.9891191322007808"},"_hasShrinkwrap":false}},"time":{"created":"2026-04-23T19:20:59.936Z","0.1.0":"2026-04-23T19:21:00.243Z","modified":"2026-04-23T19:21:00.708Z"},"maintainers":[{"name":"ayushh2k","email":"rustichouse042@gmail.com"}],"description":"Last.fm API client with Zod validation — auth, scrobbles, top tracks/artists/albums, weekly reports","homepage":"https://github.com/Beatsphere/lastfm-client#readme","keywords":["lastfm","last.fm","scrobble","music","api","now-playing","zod","typescript"],"repository":{"type":"git","url":"git+https://github.com/Beatsphere/lastfm-client.git"},"author":{"name":"BeatSphere","email":"hello@beatsphere.live"},"bugs":{"url":"https://github.com/Beatsphere/lastfm-client/issues"},"license":"MIT","readme":"# @beatsphere/lastfm-client\n\nLast.fm API client with Zod runtime validation. Covers auth, now-playing, top tracks/artists/albums, recent tracks, and weekly reports. Battle-tested in [BeatSphere](https://beatsphere.live).\n\n## Install\n\n```bash\nnpm install @beatsphere/lastfm-client\n```\n\n## Quick Start\n\n```typescript\nimport {\n  getMobileSession,\n  getUserInfo,\n  getListeningStatus,\n  getTopTracks,\n  getRecentTracks,\n  getWeeklyReport,\n} from '@beatsphere/lastfm-client';\n\n// You must provide an MD5 function for API signature generation.\n// Examples: crypto.createHash('md5') (Node), react-native-quick-md5, js-md5, etc.\nimport { createHash } from 'crypto';\nconst md5 = (input: string) => createHash('md5').update(input).digest('hex');\n\n// Authenticate\nconst { sessionKey, username } = await getMobileSession(\n  'YOUR_API_KEY',\n  'YOUR_SHARED_SECRET',\n  oauthToken,     // from Last.fm callback URL\n  md5,\n);\n\n// Get user info\nconst user = await getUserInfo('YOUR_API_KEY', sessionKey);\n\n// Check what someone is listening to\nconst status = await getListeningStatus('YOUR_API_KEY', username);\nif (status) {\n  console.log(`${status.track.name} — ${status.status}`); // 'live' or 'recent'\n}\n\n// Top tracks\nconst tracks = await getTopTracks('YOUR_API_KEY', username, sessionKey, 10);\n\n// Weekly report\nconst report = await getWeeklyReport('YOUR_API_KEY', username);\n// { totalScrobbles: 142, uniqueArtists: 38, topArtist: { name: 'Radiohead' } }\n```\n\n## API\n\n| Function | Description |\n|----------|-------------|\n| `getMobileSession(apiKey, secret, token, md5)` | OAuth → session key. Prevents double-processing of single-use tokens |\n| `getUserInfo(apiKey, sessionKey)` | User profile (name, playcount, image, etc.) |\n| `getListeningStatus(apiKey, username, threshold?)` | Currently playing or recently scrobbled track |\n| `getTopTracks(apiKey, username, sessionKey?, limit?)` | User's top tracks |\n| `getTopArtists(apiKey, username, sessionKey?, period?, limit?)` | User's top artists |\n| `getTopAlbums(apiKey, username, sessionKey?, period?, limit?)` | User's top albums |\n| `getRecentTracks(apiKey, username, sessionKey?, limit?)` | Recently scrobbled tracks |\n| `getUserRecentTrack(apiKey, username)` | Single most recent track |\n| `getWeeklyReport(apiKey, username)` | Weekly scrobble summary |\n| `createApiSignature(params, secret, md5)` | Generate Last.fm API signature |\n\n### Period values\n\nFor `getTopArtists` and `getTopAlbums`:\n- `'1month'` | `'3month'` | `'6month'` | `'12month'` | `'overall'`\n\n### MD5 function\n\nLast.fm requires MD5-signed requests. Since MD5 implementations vary by platform, you provide your own:\n\n```typescript\n// Node.js\nimport { createHash } from 'crypto';\nconst md5 = (s: string) => createHash('md5').update(s).digest('hex');\n\n// React Native\nimport { stringMd5 } from 'react-native-quick-md5';\nconst md5 = stringMd5;\n\n// Browser\nimport md5 from 'js-md5';\n```\n\n### Zod schemas\n\nAll response schemas are exported for direct use:\n\n```typescript\nimport {\n  LastFmTrackSchema,\n  LastFmUserSchema,\n  LastFmAlbumSchema,\n  // ... all schemas and types\n} from '@beatsphere/lastfm-client';\n```\n\n## License\n\nMIT\n","readmeFilename":"README.md","_rev":"1-a8673b46b5819f5ca20aae2bfb9c3ad7"}