Skip to content

sok.apis.music.musicbrainz_api

MusicBrainz API implementation.

API Documentation: https://musicbrainz.org/doc/MusicBrainz_API Note: Free API, no authentication required. Rate limit: 1 request/second.

MusicBrainzApi

class MusicBrainzApi()

Bases: BaseAPI

MusicBrainz API implementation for music metadata.

MusicBrainz is an open music encyclopedia that collects music metadata and makes it available to the public. No API key required.

Initialize MusicBrainz API (no API key required).

Source

Attributes

Name
MIN_INTERVAL
USER_AGENT

supported_content_typesproperty

List[ContentType]

Get supported content types.

supported_media_typesproperty

List[MediaType]

Get supported media types.

get_detailsasync

async def get_details(
item_id: str,
content_type: ContentType,
**kwargs,
) -> Dict[str, Any]:

Get detailed information from MusicBrainz.

Parameters

NameTypeDescription
item_idstrMusicBrainz ID (MBID).
content_typeContentTypeType of content.
**kwargsAdditional parameters.

Returns

  • Dict[str, Any]Detailed information dictionary.
Source
async def get_related_items(
item_id: str,
content_type: ContentType,
**kwargs,
) -> List[Dict[str, Any]]:

Get related items (not supported by MusicBrainz).

Parameters

NameTypeDescription
item_idstrMusicBrainz item ID.
content_typeContentTypeType of content.
**kwargsAdditional parameters.

Returns

  • List[Dict[str, Any]]Empty list as MusicBrainz doesn't have this endpoint.
Source
async def search(
query: str,
content_type: ContentType,
**kwargs,
) -> Dict[str, Any]:

Search for music on MusicBrainz.

Parameters

NameTypeDescription
querystrSearch query.
content_typeContentTypeType of content (ALBUM, TRACK, ARTIST).
**kwargsAdditional parameters (max_results).

Returns

  • Dict[str, Any]Search results with 'results' key.
Source

Attributes

NameValue
BUSY_RETRIES2
BUSY_WAIT2.0
OTHER_RELEASES{'compilation', 'live', 'remix'}
loggerlogging.getLogger(__name__)
Built with Kiln