lastfm-ts-api is a TypeScript-first API client for the Last.FM API, currently stable at version 2.6.2. It provides strongly typed interfaces for interacting with various Last.FM API endpoints, including Album, Artist, Auth, Chart, Geo, Library, Tag, Track, and User APIs. The library maintains an active release cadence, frequently adding new features, improving error handling, and enhancing type definitions. A key differentiator is its comprehensive TypeScript support, ensuring parameter and response types are well-defined. It also supports integration with third-party scrobbling services like Libre.FM since version 2.3.0 and offers user-configurable request timeouts. The library transitioned to a pure ESM module in version 2.0.0, aligning with modern JavaScript practices.
npm install lastfm-ts-apiVerified import paths — ran on the pinned version, not inferred.
Demonstrates initializing the LastFMTrack client and fetching the top tracks for an artist, handling API key retrieval from environment variables.
Migrate all `require()` statements to `import` statements. Ensure your project's `package.json` has `"type": "module"` or uses `.mjs` file extensions for ESM files.
Consult the library's official documentation or your IDE's type hints to update any affected type names in your codebase.
Update your code to correctly parse the `track.scrobble` response, expecting an object for single track scrobbles.
Ensure that `user.getInfo` calls correctly pass the session secret for signing as per the updated API requirements.
Adjust error parsing logic to check for both string and object error formats in API responses, especially when integrating with third-party Last.FM compatible services.
Implement defensive programming by checking for the existence of the `album` property before attempting to access its sub-properties, e.g., `track.album?.title`.
Change your import statements from `const { LastFMAlbum } = require('lastfm-ts-api');` to `import { LastFMAlbum } from 'lastfm-ts-api';`. Also, ensure your `package.json` contains `"type": "module"` or your file has a `.mjs` extension.Update your code to expect an object response from `track.scrobble` when scrobbling a single track, rather than assuming it's always an array or a different structure.
Update your TypeScript code to use the new type names introduced in v2.0.0. Refer to the library's type definitions for the correct names.
No dependency data recorded yet.