### Initialize MusicBrainz API Client Source: https://github.com/borewit/musicbrainz-api/blob/master/README.md Configure and instantiate the MusicBrainz API client with your application's details. This is required for all API interactions. ```javascript import { MusicBrainzApi } from 'musicbrainz-api'; const mbApi = new MusicBrainzApi({ appName: 'my-app', appVersion: '0.1.0', appContactInfo: 'user@mail.org', }); ``` -------------------------------- ### Browse Releases with Query and Includes Source: https://github.com/borewit/musicbrainz-api/blob/master/README.md Browse releases using a query. You can include related entities like 'artist' or 'track'. ```javascript const releases = await mbApi.browse('release', query); ``` ```javascript const releases = await mbApi.browse('release', query, ['artist', 'track']); ``` -------------------------------- ### Browse Instruments with Query Source: https://github.com/borewit/musicbrainz-api/blob/master/README.md Browse instruments using a query. An optional 'collection' parameter can be included. ```javascript const instruments = await mbApi.browse('instrument', query); ``` ```javascript const instruments = await mbApi.browse('instrument', query, ['collection']); ``` -------------------------------- ### Browse Release Groups with Query and Includes Source: https://github.com/borewit/musicbrainz-api/blob/master/README.md Browse release-groups using a query. You can include related entities like 'artist' or 'release'. ```javascript const releaseGroups = await mbApi.browse('release-group', query); ``` ```javascript const releaseGroups = await mbApi.browse('release-group', query, ['artist', 'release']); ``` -------------------------------- ### Configure MusicBrainz API Client Source: https://github.com/borewit/musicbrainz-api/blob/master/README.md Set up the MusicBrainz API client with optional bot account credentials, base URL, application details, and proxy settings. Rate limiting can also be configured or disabled. ```javascript const config = { // Optional: MusicBrainz bot account credentials botAccount: { username: 'myUserName_bot', password: 'myPassword', }, // Optional: API base URL (default: 'https://musicbrainz.org') baseUrl: 'https://musicbrainz.org', // Required: Application details appName: 'my-app', appVersion: '0.1.0', appContactInfo: 'user@mail.org', // Optional: Proxy settings (default: no proxy server) proxy: { host: 'localhost', port: 8888, }, // Optional: Disable rate limiting (default: false) disableRateLimiting: false, // Optional: Set max number of request with X seconds // (default: 15 requests every 18 seconds) rateLimit: [15, 18] }; const mbApi = new MusicBrainzApi(config); ``` -------------------------------- ### Fetch All Release Group Covers Source: https://github.com/borewit/musicbrainz-api/blob/master/README.md Fetches all available cover art images for a given release group MBID and logs their details. Ensure the CoverArtArchiveApi is imported. ```javascript import { CoverArtArchiveApi } from 'musicbrainz-api'; const coverArtArchiveApiClient = new CoverArtArchiveApi(); async function fetchCoverArt(releaseMbid, coverType = '') { const coverInfo = await coverArtArchiveApiClient.getReleaseGroupCovers(releaseMbid); for(const image of coverInfo.images) { console.log(`Cover art front=${image.front} back=${image.back} url=${image.image}`); } } fetchCoverArt('976e0677-a480-4a5e-a177-6a86c1900bbf').catch(error => { console.error(`Failed to fetch cover art: ${error.message}`); }) ``` -------------------------------- ### Browse Recordings with Includes Source: https://github.com/borewit/musicbrainz-api/blob/master/README.md Browse recordings using a query and specify related entities to include, such as 'artist'. ```javascript const recordings = await mbApi.browse('recording', query, ['artist']); ``` -------------------------------- ### Fetch front or back cover for a release Source: https://github.com/borewit/musicbrainz-api/blob/master/README.md Retrieves a specific cover art image (front or back) for a given release. ```APIDOC ## Fetch front or back cover for a release ### Description Fetches a specific cover art image (front or back) for a release. ### Method GET ### Endpoint `/release/{releaseMbid}/front` or `/release/{releaseMbid}/back` ### Parameters #### Path Parameters - **releaseMbid** (string) - Required - The MusicBrainz ID of the release. - **coverType** (string) - Required - The type of cover art to fetch ('front' or 'back'). ### Response #### Success Response (200) - **url** (string) - The URL of the requested cover art image. ### Response Example ```json { "url": "https://coverart.musicbrainz.org/...?" } ``` ### Request Example ```js import { CoverArtArchiveApi } from 'musicbrainz-api'; const coverArtArchiveApiClient = new CoverArtArchiveApi(); async function fetchCoverArt(releaseMbid, coverType = '') { const coverInfo = await coverArtArchiveApiClient.getReleaseCover(releaseMbid, 'front'); console.log(`Cover art url=${coverInfo.url}`); } fetchCoverArt('976e0677-a480-4a5e-a177-6a86c1900bbf').catch(error => { console.error(`Failed to fetch cover art: ${error.message}`); }) ``` ``` -------------------------------- ### Browse Instruments Source: https://github.com/borewit/musicbrainz-api/blob/master/README.md Browse instruments using the mbApi.browse method. An optional collection parameter can be provided. ```APIDOC ## Browse Instruments ### Description Browse instruments using the `mbApi.browse` method. An optional collection parameter can be provided. ### Method ```js mbApi.browse('instrument', query) mbApi.browse('instrument', query, ['collection']) ``` ### Parameters #### Query Parameters - `query.collection` (string) - Optional - Collection MBID ``` -------------------------------- ### Fetch Release Cover Art Information Source: https://github.com/borewit/musicbrainz-api/blob/master/README.md Fetches all available cover art information for a given release MBID. Iterates through the images to log details like front/back status and URL. ```javascript import { CoverArtArchiveApi } from 'musicbrainz-api'; const coverArtArchiveApiClient = new CoverArtArchiveApi(); async function fetchCoverArt(releaseMbid, coverType = '') { const coverInfo = await coverArtArchiveApiClient.getReleaseCovers(releaseMbid); for(const image of coverInfo.images) { console.log(`Cover art front=${image.front} back=${image.back} url=${image.image}`); } } fetchCoverArt('976e0677-a480-4a5e-a177-6a86c1900bbf').catch(error => { console.error(`Failed to fetch cover art: ${error.message}`); }) ``` -------------------------------- ### Fetch Front or Back Cover for a Release Source: https://github.com/borewit/musicbrainz-api/blob/master/README.md Fetches a specific cover art (front or back) for a release using its MBID. Logs the URL of the found cover art. ```javascript import { CoverArtArchiveApi } from 'musicbrainz-api'; const coverArtArchiveApiClient = new CoverArtArchiveApi(); async function fetchCoverArt(releaseMbid, coverType = '') { const coverInfo = await coverArtArchiveApiClient.getReleaseCover(releaseMbid, 'front'); console.log(`Cover art url=${coverInfo.url}`); } fetchCoverArt('976e0677-a480-4a5e-a177-6a86c1900bbf').catch(error => { console.error(`Failed to fetch cover art: ${error.message}`); }) ``` -------------------------------- ### Browse Labels with Query Source: https://github.com/borewit/musicbrainz-api/blob/master/README.md Browse labels using a query. Additional parameters like 'area', 'collection', or 'release' can be specified. ```javascript const labels = await mbApi.browse('label', query); ``` -------------------------------- ### Browse URLs Source: https://github.com/borewit/musicbrainz-api/blob/master/README.md Browse URLs using the mbApi.browse method. Optional artist and collection parameters can be provided. ```APIDOC ## Browse URLs ### Description Browse URLs using the `mbApi.browse` method. Optional artist and collection parameters can be provided. ### Method ```js mbApi.browse('url') mbApi.browse('series', ['artist', 'collection', 'artist-rels']) ``` ### Parameters #### Query Parameters - `query.artist` (string) - Optional - Artist MBID - `query.xollection` (string) - Optional - Collection MBID ``` -------------------------------- ### Search Release by Barcode (String Query) Source: https://github.com/borewit/musicbrainz-api/blob/master/README.md Searches for a release using its barcode provided as a string. This method automatically serializes the search parameters into a query string. ```javascript mbApi.search('release', 'barcode: 602537479870'); ``` -------------------------------- ### Browse Places with Query and Includes Source: https://github.com/borewit/musicbrainz-api/blob/master/README.md Browse places using a query. You can include related entities like 'area' or 'collection'. ```javascript const places = await mbApi.browse('place', query); ``` ```javascript const places = await mbApi.browse('place', query, ['area', 'collection']); ``` -------------------------------- ### Browse Releases Source: https://github.com/borewit/musicbrainz-api/blob/master/README.md Browse releases using the mbApi.browse method. A variety of optional parameters can be provided, including area, artist, editor, event, label, place, recording, release, release-group, and work. ```APIDOC ## Browse Releases ### Description Browse releases using the `mbApi.browse` method. A variety of optional parameters can be provided, including area, artist, editor, event, label, place, recording, release, release-group, and work. ### Method ```js mbApi.browse('release', query) mbApi.browse('release', query, ['artist', 'track']) ``` ### Parameters #### Query Parameters - `query.area` (string) - Optional - Area MBID - `query.artist` (string) - Optional - Artist MBID - `query.editor` (string) - Optional - Editor MBID - `query.event` (string) - Optional - Event MBID - `query.label` (string) - Optional - Label MBID - `query.place` (string) - Optional - Place MBID - `query.recording` (string) - Optional - Recording MBID - `query.release` (string) - Optional - Release MBID - `query.release-group` (string) - Optional - Release-group MBID - `query.work` (string) - Optional - Work MBID ``` -------------------------------- ### Search Release by Barcode (Object Query) Source: https://github.com/borewit/musicbrainz-api/blob/master/README.md Searches for a release using its barcode. The query is provided as an object, allowing for structured parameter passing. ```javascript mbApi.search('release', {query: {barcode: 602537479870}}); ``` -------------------------------- ### Fetch available cover art information Source: https://github.com/borewit/musicbrainz-api/blob/master/README.md Retrieves all available cover art information for a given release. ```APIDOC ## Fetch available cover art information ### Description Fetches all available cover art images for a specific release. ### Method GET ### Endpoint `/release/{releaseMbid}/cover-art` ### Parameters #### Path Parameters - **releaseMbid** (string) - Required - The MusicBrainz ID of the release. ### Response #### Success Response (200) - **images** (array) - A list of cover art images. - **front** (boolean) - Indicates if the image is a front cover. - **back** (boolean) - Indicates if the image is a back cover. - **image** (string) - The URL of the cover art image. ### Response Example ```json { "images": [ { "front": true, "back": false, "image": "https://coverart.musicbrainz.org/...?" } ] } ``` ### Request Example ```js import { CoverArtArchiveApi } from 'musicbrainz-api'; const coverArtArchiveApiClient = new CoverArtArchiveApi(); async function fetchCoverArt(releaseMbid, coverType = '') { const coverInfo = await coverArtArchiveApiClient.getReleaseCovers(releaseMbid); for(const image of coverInfo.images) { console.log(`Cover art front=${image.front} back=${image.back} url=${image.image}`); } } fetchCoverArt('976e0677-a480-4a5e-a177-6a86c1900bbf').catch(error => { console.error(`Failed to fetch cover art: ${error.message}`); }) ``` ``` -------------------------------- ### Browse Recordings Source: https://github.com/borewit/musicbrainz-api/blob/master/README.md Browse recordings using the mbApi.browse method. Optional artist, collection, release, and work parameters can be provided. ```APIDOC ## Browse Recordings ### Description Browse recordings using the `mbApi.browse` method. Optional artist, collection, release, and work parameters can be provided. ### Method ```js mbApi.browse('recording', query, ['artist']) ``` ### Parameters #### Query Parameters - `query.artist` (string) - Optional - Area MBID - `query.collection` (string) - Optional - Collection MBID - `query.release` (string) - Optional - Release MBID - `query.work` (string) - Optional - Work MBID ``` -------------------------------- ### Browse Release Groups Source: https://github.com/borewit/musicbrainz-api/blob/master/README.md Browse release-groups using the mbApi.browse method. Optional artist and release parameters can be provided. ```APIDOC ## Browse Release Groups ### Description Browse release-groups using the `mbApi.browse` method. Optional artist and release parameters can be provided. ### Method ```js mbApi.browse('release-group', query) mbApi.browse('release-group', query, ['artist', 'release']) ``` ### Parameters #### Query Parameters - `query.artist` (string) - Optional - Artist MBID - `query.collection` (string) - Optional - Collection MBID - `query.release` (string) - Optional - Release MBID ``` -------------------------------- ### Search Release Group by Artist and Title Source: https://github.com/borewit/musicbrainz-api/blob/master/README.md Searches for a release group by specifying both the artist and the release group title. Ensure the 'releasegroup' parameter is correctly named for release-group searches. ```javascript const result = await mbApi.search('release-group', {artist: 'Racine carrée', releasegroup: 'Stromae'}); ``` -------------------------------- ### Browse Releases for an Artist Source: https://github.com/borewit/musicbrainz-api/blob/master/README.md Fetch releases associated with an artist by providing the artist's MBID. You can specify include arguments and pagination parameters like limit and offset. ```javascript const artist_mbid = 'ab2528d9-719f-4261-8098-21849222a0f2'; const releases = await mbApi.browse('release', { track_artist: artist_mbid, limit: 0, offset: 0, }, ['url-rels', 'isrcs', 'recordings']); ``` -------------------------------- ### Browse URLs with Includes Source: https://github.com/borewit/musicbrainz-api/blob/master/README.md Browse URLs. You can specify related entities to include, such as 'artist', 'collection', or 'artist-rels'. ```javascript const urls = await mbApi.browse('url'); ``` ```javascript const series = await mbApi.browse('series', ['artist', 'collection', 'artist-rels']); ``` -------------------------------- ### Dynamic Import ESM in CommonJS Source: https://github.com/borewit/musicbrainz-api/blob/master/README.md Shows how to dynamically import the 'musicbrainz-api' ESM module within a CommonJS project using the import() operator. ```javascript async function run() { // Dynamically loads the ESM module in a CommonJS project const { MusicBrainzApi } = await import('musicbrainz-api'); }; run(); ``` -------------------------------- ### Submit ISRC code using XML POST Source: https://github.com/borewit/musicbrainz-api/blob/master/README.md Use this method to submit an ISRC code for a recording via XML POST. Requires MusicBrainz credentials and an XmlMetadata object. ```javascript const mbid_Formidable = '16afa384-174e-435e-bfa3-5591accda31c'; const isrc_Formidable = 'BET671300161'; const xmlMetadata = new XmlMetadata(); const xmlRecording = xmlMetadata.pushRecording(mbid_Formidable); xmlRecording.isrcList.pushIsrc(isrc_Formidable); await mbApi.post('recording', xmlMetadata); ``` -------------------------------- ### Fetch Specific Release Group Cover Source: https://github.com/borewit/musicbrainz-api/blob/master/README.md Fetches a specific cover art image (e.g., 'front') for a release group MBID and logs its URL. Requires importing CoverArtArchiveApi. ```javascript import { CoverArtArchiveApi } from 'musicbrainz-api'; const coverArtArchiveApiClient = new CoverArtArchiveApi(); async function fetchCoverArt(releaseMbid, coverType = '') { const coverInfo = await coverArtArchiveApiClient.getReleaseGroupCover(releaseMbid, 'front'); console.log(`Cover art url=${coverInfo.url}`); } fetchCoverArt('976e0677-a480-4a5e-a177-6a86c1900bbf').catch(error => { console.error(`Failed to fetch cover art: ${error.message}`); }) ``` -------------------------------- ### Browse Labels Source: https://github.com/borewit/musicbrainz-api/blob/master/README.md Browse labels using the mbApi.browse method. Optional area, collection, and release parameters can be provided. ```APIDOC ## Browse Labels ### Description Browse labels using the `mbApi.browse` method. Optional area, collection, and release parameters can be provided. ### Method ```js mbApi.browse('label', query) mbApi.browse('place', query, ['area', 'collection']) ``` ### Parameters #### Query Parameters - `query.area` (string) - Optional - Area MBID - `query.collection` (string) - Optional - Collection MBID - `query.release` (string) - Optional - Release MBID ``` -------------------------------- ### Browse Series Source: https://github.com/borewit/musicbrainz-api/blob/master/README.md Browse series using the mbApi.browse method. Optional collection parameter can be provided, along with various other query parameters. ```APIDOC ## Browse Series ### Description Browse series using the `mbApi.browse` method. Optional collection parameter can be provided, along with various other query parameters. ### Method ```js mbApi.browse('series') mbApi.browse('series', ['collection']) ``` ### Parameters #### Query Parameters - `query.area` (string) - Optional - Area MBID - `query.artist` (string) - Optional - Artist MBID - `query.editor` (string) - Optional - Editor MBID - `query.event` (string) - Optional - Event MBID - `query.label` (string) - Optional - Label MBID - `query.place` (string) - Optional - Place MBID - `query.recording` (string) - Optional - Recording MBID - `query.release` (string) - Optional - Release MBID - `query.release-group` (string) - Optional - Release-group MBID - `query.work` (string) - Optional - Work MBID ``` -------------------------------- ### Search Release Group by Artist and Title (String Query) Source: https://github.com/borewit/musicbrainz-api/blob/master/README.md Performs a search for a release group using a string query that combines artist and release title. This method is useful for constructing complex queries. ```javascript const query = 'query=artist:"Queen" AND release:"We Will Rock You"'; const result = await mbApi.search('release-group', {query}); ``` -------------------------------- ### Search Release Group by Title Source: https://github.com/borewit/musicbrainz-api/blob/master/README.md Searches for a release group by its title. The query is passed as an object with a 'query' property. ```javascript const result = await mbApi.search('release-group', {query: 'Racine carrée'}); ``` -------------------------------- ### Submit recording URL Source: https://github.com/borewit/musicbrainz-api/blob/master/README.md Adds a URL to a recording, such as a streaming link. ```APIDOC ## Submit recording URL ### Description Adds a URL to a recording, for example, a streaming link. ### Method POST ### Endpoint `/recording` (implied by `addUrlToRecording` method) ### Parameters - `recording` (object) - The recording object obtained via lookup. - `url_data` (object) - An object containing URL details. - `linkTypeId` (enum) - The type of link (e.g., `LinkType.stream_for_free`). - `text` (string) - The URL itself. ### Request Example ```js const recording = await mbApi.lookup('recording', '16afa384-174e-435e-bfa3-5591accda31c'); const succeed = await mbApi.login(); await mbApi.addUrlToRecording(recording, { linkTypeId: LinkType.stream_for_free, text: 'https://open.spotify.com/track/2AMysGXOe0zzZJMtH3Nizb' }); ``` ``` -------------------------------- ### Import ESM in Node.js >= 22 CommonJS Source: https://github.com/borewit/musicbrainz-api/blob/master/README.md Demonstrates how to use the 'musicbrainz-api' ESM module in a CommonJS project using Node.js version 22 or later, which supports require for ESM. ```javascript const { MusicBrainzApi } = require('musicbrainz-api'); ``` -------------------------------- ### Browse Works Source: https://github.com/borewit/musicbrainz-api/blob/master/README.md Browse works using the mbApi.browse method. Optional artist and collection parameters can be provided. ```APIDOC ## Browse Works ### Description Browse works using the `mbApi.browse` method. Optional artist and collection parameters can be provided. ### Method ```js mbApi.browse('work') mbApi.browse('series', ['artist', 'collection']) ``` ### Parameters #### Query Parameters - `query.artist` (string) - Optional - Artist MBID - `query.xollection` (string) - Optional - Collection MBID ``` -------------------------------- ### Browse Events Source: https://github.com/borewit/musicbrainz-api/blob/master/README.md Fetch events using query parameters such as area, artist, collection, or place MBIDs. You can also include related entities like 'area' or 'artist'. ```javascript const events = await mbApi.browse('event', query); ``` ```javascript const events = await mbApi.browse('instrument', query, ['area', 'artist']); ``` -------------------------------- ### Browse Works with Includes Source: https://github.com/borewit/musicbrainz-api/blob/master/README.md Browse works. You can specify related entities to include, such as 'artist' or 'collection'. ```javascript const works = await mbApi.browse('work'); ``` ```javascript const series = await mbApi.browse('series', ['artist', 'collection']); ``` -------------------------------- ### Submit ISRC code using XML POST Source: https://github.com/borewit/musicbrainz-api/blob/master/README.md This snippet demonstrates how to submit an ISRC code for a recording using an XML POST request. ```APIDOC ## Submit ISRC code using XML POST ### Description Submits an ISRC code for a recording via XML POST. ### Method POST ### Endpoint `/recording` ### Request Body ```js const mbid_Formidable = '16afa384-174e-435e-bfa3-5591accda31c'; const isrc_Formidable = 'BET671300161'; const xmlMetadata = new XmlMetadata(); const xmlRecording = xmlMetadata.pushRecording(mbid_Formidable); xmlRecording.isrcList.pushIsrc(isrc_Formidable); await mbApi.post('recording', xmlMetadata); ``` ``` -------------------------------- ### Search Artist by Name Source: https://github.com/borewit/musicbrainz-api/blob/master/README.md Searches for an artist by their name. The query is passed as an object with a 'query' property. ```javascript const result = await mbApi.search('artist', {query: 'Stromae'}); ``` -------------------------------- ### Browse Places Source: https://github.com/borewit/musicbrainz-api/blob/master/README.md Browse places using the mbApi.browse method. Optional area and collection parameters can be provided. ```APIDOC ## Browse Places ### Description Browse places using the `mbApi.browse` method. Optional area and collection parameters can be provided. ### Method ```js mbApi.browse('place', query) mbApi.browse('place', query, ['area', 'collection']) ``` ### Parameters #### Query Parameters - `query.area` (string) - Optional - Area MBID - `query.collection` (string) - Optional - Collection MBID ``` -------------------------------- ### Browse Collections Source: https://github.com/borewit/musicbrainz-api/blob/master/README.md Retrieve collections using query parameters like area, artist, editor, event, label, place, recording, release, release-group, or work MBIDs. Related entities can also be included. ```javascript const collections = await mbApi.browse('collection', query); ``` ```javascript const collections = await mbApi.browse('collection', query, ['area', 'artist']); ``` -------------------------------- ### Dynamic Import ESM in TypeScript CommonJS with load-esm Source: https://github.com/borewit/musicbrainz-api/blob/master/README.md Provides a solution for dynamically importing the 'musicbrainz-api' ESM module in TypeScript CommonJS projects using the 'load-esm' package. ```javascript import {loadEsm} from 'load-esm'; async function run() { // Dynamically loads the ESM module in a TypeScript CommonJS project const { MusicBrainzApi } = await loadEsm('musicbrainz-api'); }; run(); ``` -------------------------------- ### Submit Spotify ID to Recording Source: https://github.com/borewit/musicbrainz-api/blob/master/README.md Easier method to add a Spotify ID to a recording. Requires login and the recording's MBID. ```javascript const recording = await mbApi.lookup('recording', '16afa384-174e-435e-bfa3-5591accda31c'); const succeed = await mbApi.login(); assert.isTrue(succeed, 'Login successful'); await mbApi.addSpotifyIdToRecording(recording, '2AMysGXOe0zzZJMtH3Nizb'); ``` -------------------------------- ### Submit recording URL Source: https://github.com/borewit/musicbrainz-api/blob/master/README.md Adds a URL to a recording, such as a streaming link. Requires login and the recording's MBID. The linkTypeId specifies the nature of the URL. ```javascript const recording = await mbApi.lookup('recording', '16afa384-174e-435e-bfa3-5591accda31c'); const succeed = await mbApi.login(); assert.isTrue(succeed, 'Login successful'); await mbApi.addUrlToRecording(recording, { linkTypeId: LinkType.stream_for_free, text: 'https://open.spotify.com/track/2AMysGXOe0zzZJMtH3Nizb' }); ``` -------------------------------- ### Browse Artists Source: https://github.com/borewit/musicbrainz-api/blob/master/README.md Search for artists based on various query parameters such as area, collection, recording, release, release-group, or work MBIDs. Include related entities if needed. ```javascript const artists = await mbApi.browse('artist', query); ``` ```javascript const artists = await mbApi.browse('artist', query, ['area', 'collection']); ``` -------------------------------- ### Lookup URL Entities Source: https://github.com/borewit/musicbrainz-api/blob/master/README.md Find MusicBrainz URL entities by providing one or more URLs. The return type differs based on whether a single URL or an array of URLs is passed. ```javascript const urls = await mbApi.lookupUrl(['https://open.spotify.com/track/2AMysGXOe0zzZJMtH3Nizb', 'https://open.spotify.com/track/78Teboqh9lPIxWlIW5RMQL']); ``` ```javascript const url = await mbApi.lookupUrl('https://open.spotify.com/track/2AMysGXOe0zzZJMtH3Nizb'); ``` -------------------------------- ### Submitting ISRC via post user form-data Source: https://github.com/borewit/musicbrainz-api/blob/master/README.md This method allows submitting an ISRC code for a recording using user form-data. Use with caution as it may clear existing metadata. ```APIDOC ## Submitting ISRC via post user form-data ### Description Submits an ISRC code for a recording using user form-data. Requires authentication. ### Method POST ### Endpoint `/recording` (implied by `addIsrc` method) ### Parameters - `recording` (object) - The recording object obtained via lookup. - `isrc_code` (string) - The ISRC code to submit. ### Request Example ```js const mbid_Formidable = '16afa384-174e-435e-bfa3-5591accda31c'; const isrc_Formidable = 'BET671300161'; const recording = await mbApi.lookup('recording', mbid_Formidable); // Authentication the http-session against MusicBrainz (as defined in config.baseUrl) const succeed = await mbApi.login(); // To submit the ISRC, the `recording.id` and `recording.title` are required await mbApi.addIsrc(recording, isrc_Formidable); ``` ``` -------------------------------- ### Submit Spotify ID to Recording Source: https://github.com/borewit/musicbrainz-api/blob/master/README.md Easier submission of a Spotify track ID to a recording. ```APIDOC ## Submit Spotify ID to Recording ### Description Adds a Spotify track ID to a recording. ### Method POST ### Endpoint `/recording` (implied by `addSpotifyIdToRecording` method) ### Parameters - `recording` (object) - The recording object obtained via lookup. - `spotifyId` (string) - The Spotify track ID. ### Request Example ```js const recording = await mbApi.lookup('recording', '16afa384-174e-435e-bfa3-5591accda31c'); const succeed = await mbApi.login(); await mbApi.addSpotifyIdToRecording(recording, '2AMysGXOe0zzZJMtH3Nizb'); ``` ``` -------------------------------- ### Browse Events Source: https://github.com/borewit/musicbrainz-api/blob/master/README.md Browse for events with specific query parameters. Related entities such as areas and artists can be included. ```APIDOC ### Browse events ```js const events = await mbApi.browse('event', query); const events = await mbApi.browse('instrument', query, ['area', 'artist']); ``` | Query argument | Query value | |-----------------------|-----------------| | `query.area` | Area MBID | | `query.artist` | Artist MBID | | `query.collection` | Collection MBID | | `query.place` | Place MBID | ``` -------------------------------- ### Lookup Artist by MBID Source: https://github.com/borewit/musicbrainz-api/blob/master/README.md Retrieve artist information using their MusicBrainz ID (MBID) and specify which related entities to include, such as recordings. Ensure the correct entity type and MBID are provided. ```javascript const artist = await mbApi.lookup('artist', 'ab2528d9-719f-4261-8098-21849222a0f2', ['recordings']); ``` -------------------------------- ### Browse Artist Source: https://github.com/borewit/musicbrainz-api/blob/master/README.md Browse for artists based on various query parameters. You can also specify related entities to include in the results. ```APIDOC ### Browse artist ```js const artists = await mbApi.browse('artist', query); const artists = await mbApi.browse('artist', query, ['area', 'collection']); ``` | Query argument | Query value | |-----------------------|--------------------| | `query.area` | Area MBID | | `query.collection` | Collection MBID | | `query.recording` | Recording MBID | | `query.release` | Release MBID | | `query.release-group` | Release-group MBID | | `query.work` | Work MBID | ``` -------------------------------- ### Browse Collection Source: https://github.com/borewit/musicbrainz-api/blob/master/README.md Browse for collections using specified query parameters. You can include related entities like areas and artists. ```APIDOC ### Browse collection ```js const collections = await mbApi.browse('collection', query); const collections = await mbApi.browse('collection', query, ['area', 'artist']); ``` | Query argument | Query value | |-----------------------|--------------------| | `query.area` | Area MBID | | `query.artist` | Artist MBID | | `query.editor` | Editor MBID | | `query.event` | Event MBID | | `query.label` | Label MBID | | `query.place` | Place MBID | | `query.recording` | Recording MBID | | `query.release` | Release MBID | | `query.release-group` | Release-group MBID | | `query.work` | Work MBID | ``` -------------------------------- ### Lookup MusicBrainz Entities Source: https://github.com/borewit/musicbrainz-api/blob/master/README.md Allows you to look up a specific MusicBrainz entity using its MBID. You can also specify which related data to include. ```APIDOC ## Lookup MusicBrainz Entities You can use the lookup function, to look up an entity, when you have the MBID for that entity. MusicBrainz API documentation: [MusicBrainz API - Lookups](https://wiki.musicbrainz.org/MusicBrainz_API#Lookups) ### Lookup Function ```js const artist = await mbApi.lookup('artist', 'ab2528d9-719f-4261-8098-21849222a0f2', ['recordings']); ``` Arguments: - entity (`string`): `'area'` | `'artist'` | `'collection'` | `'instrument'` | `'label'` | `'place'` | `'release'` | `'release-group'` | `'recording'` | `'series'` | `'work'` | `'url'` | `'event'` - MBID (`string`): [(MusicBrainz identifier)](https://wiki.musicbrainz.org/MusicBrainz_Identifier) - include arguments (`string[]`), see [Include arguments](#include-arguments) ``` -------------------------------- ### Search Area by Name Source: https://github.com/borewit/musicbrainz-api/blob/master/README.md A simple search for an area by its name. This is a direct query without additional parameters. ```javascript mbApi.search('area', 'Île-de-France'); ``` -------------------------------- ### Browse Series without Query Source: https://github.com/borewit/musicbrainz-api/blob/master/README.md Browse series without a specific query. You can optionally include related entities like 'collection'. ```javascript const series = await mbApi.browse('series'); ``` ```javascript const series = await mbApi.browse('series', ['collection']); ``` -------------------------------- ### Browse Requests Source: https://github.com/borewit/musicbrainz-api/blob/master/README.md Browse requests allow you to retrieve entities directly linked to another entity. This method does not include entities linked indirectly through relationships. ```APIDOC ## Browse requests Browse requests are a direct lookup of all the entities directly linked to another entity ("directly linked" here meaning it does not include entities linked by a relationship). For example, browse _releases_: ```js const artist_mbid = 'ab2528d9-719f-4261-8098-21849222a0f2'; const releases = await mbApi.browse('release', { track_artist: artist_mbid, limit: 0, offset: 0, }, ['url-rels', 'isrcs', 'recordings']); ``` For the optional include arguments (`string[]`), see [Include arguments](#include-arguments). ``` -------------------------------- ### Lookup URL Entity Source: https://github.com/borewit/musicbrainz-api/blob/master/README.md A specialized lookup function to find URL entities by providing one or more URLs. The return type may vary based on whether a single URL or an array of URLs is provided. ```APIDOC #### Lookup URLs There is special method to lookup URL entity / entities by one, or an array of URLs ([MusicBrainz API documentation: url (by text)](https://musicbrainz.org/doc/MusicBrainz_API#url_(by_text))): ```js const urls = await mbApi.lookupUrl(['https://open.spotify.com/track/2AMysGXOe0zzZJMtH3Nizb', 'https://open.spotify.com/track/78Teboqh9lPIxWlIW5RMQL']); ``` or ```js const url = await mbApi.lookupUrl('https://open.spotify.com/track/2AMysGXOe0zzZJMtH3Nizb'); ``` Arguments: - url (`string` | `string[]`): URL or array of URLs - include arguments (`string[]`), see [Include arguments](#include-arguments) Note that the return type is different, depending on if a single URL or an array of URLs is provided. ``` -------------------------------- ### Submit ISRC via POST user form-data Source: https://github.com/borewit/musicbrainz-api/blob/master/README.md Submits an ISRC code for a recording using user form-data. Requires authentication and specific recording details (ID and title). Use with caution on test servers as it may clear existing metadata. ```javascript const mbid_Formidable = '16afa384-174e-435e-bfa3-5591accda31c'; const isrc_Formidable = 'BET671300161'; const recording = await mbApi.lookup('recording', mbid_Formidable); // Authentication the http-session against MusicBrainz (as defined in config.baseUrl) const succeed = await mbApi.login(); assert.isTrue(succeed, 'Login successful'); // To submit the ISRC, the `recording.id` and `recording.title` are required await mbApi.addIsrc(recording, isrc_Formidable); ``` -------------------------------- ### Generic Search Function Source: https://github.com/borewit/musicbrainz-api/blob/master/README.md The generic search function allows you to query for various entities within the MusicBrainz database. You can specify the entity type, a search query, and optional offset and limit parameters for pagination. ```APIDOC ## `query(entity: mb.EntityType, query: string | IFormData, offset?: number, limit?: number): Promise` ### Description Performs a search for a specified entity type using a given query string or form data. Supports pagination with offset and limit. ### Parameters #### Entity Type Specifies the type of entity to search for. Supported types include: - `annotation` - `area` - `artist` - `cdstub` - `event` - `instrument` - `label` - `place` - `recording` - `release` - `release-group` - `series` - `tag` - `url` - `work` #### Query Can be a string containing Lucene Search syntax or an object with query parameters. - `query.query` (string): The search query string. Supports Lucene syntax for advanced filtering (e.g., `artist:"Queen" AND release:"We Will Rock You"`). - `query.offset` (number): Optional. The starting offset for search results, used for pagination. - `query.limit` (number): Optional. The maximum number of entries to return (1-100). Defaults to 25. ### Examples #### Search release-group by artist and release name ```js const result = await mbApi.search('release-group', {query: 'artist:"Queen" AND release:"We Will Rock You"'}); ``` #### Search area by name ```js mbApi.search('area', 'Île-de-France'); ``` #### Search release by barcode ```js mbApi.search('release', {query: {barcode: 602537479870}}); ``` #### Search by object (e.g., release by barcode) ```js mbApi.search('release', 'barcode: 602537479870'); ``` #### Search artist by artist name ```js const result = await mbApi.search('artist', {query: 'Stromae'}); ``` #### Search release-group by release-group name ```js const result = await mbApi.search('release-group', {query: 'Racine carrée'}); ``` #### Search release-group by release-group name and artist name ```js const result = await mbApi.search('release-group', {artist: 'Racine carrée', releasegroup: 'Stromae'}); ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.