The `musicbrainz-api` package provides a TypeScript-first client for interacting with the MusicBrainz web service, enabling both reading detailed metadata and submitting new information to the database. Currently at stable version 1.2.0, the library maintains an active release cadence with updates typically occurring every few weeks or months. Key differentiators include its robust support for retrieving various entity types, comprehensive TypeScript definitions for enhanced developer experience, and intelligent request throttling that automatically adheres to MusicBrainz API rate limits, including retries for rate-limit hits. It simplifies the required application identification (User-Agent) by prompting for `appName`, `appVersion`, and `appContactInfo` during client configuration. This library exclusively uses ECMAScript Modules (ESM) since version 8, requiring Node.js 16 or higher for usage.
npm install musicbrainz-apiVerified import paths — ran on the pinned version, not inferred.
Initializes the MusicBrainz API client and performs a search for an artist, logging basic details.
Migrate your project to ESM by adding `"type": "module"` to your `package.json` and updating `require()` calls to `import` statements. Ensure your Node.js version is 16 or newer.
Always initialize the client with `new MusicBrainzApi({ appName: 'YourAppName', appVersion: 'X.Y.Z', appContactInfo: 'you@example.com' })`.Review error handling logic, especially for 400 Bad Request responses, and adapt to potentially more detailed or structured error objects. Implement robust error parsing to avoid future breaking changes.
Ensure your application adheres to reasonable request patterns. For heavy usage, consider distributing requests over time or reaching out to MusicBrainz for specific permissions if necessary. Provide accurate `appContactInfo`.
If migrating from older versions, update calls to `browse` to utilize the new overloads, which may require adjusting how entity IDs and include parameters are passed. For new development, prefer the most flexible `browse` signatures.
Change your import statement to `import { MusicBrainzApi } from 'musicbrainz-api';` and ensure your project is configured for ESM (e.g., `"type": "module"` in `package.json`).When initializing `MusicBrainzApi`, ensure all three fields (`appName`, `appVersion`, `appContactInfo`) are provided and valid, e.g., `new MusicBrainzApi({ appName: 'MyApp', appVersion: '1.0.0', appContactInfo: 'me@example.com' })`.Review your application's request frequency. While the library implements retries, sustained high volume can still trigger this. Ensure `appContactInfo` is valid. Consider spacing out requests or implementing custom back-off strategies if necessary.
For type-only imports, use `import type { Artist } from 'musicbrainz-api';`. If `Artist` is used as a value, ensure it's exported as such (though typically it's only a type).No dependency data recorded yet.