{"id":48338516,"url":"https://github.com/zas/musicbrainzpy","last_synced_at":"2026-04-05T03:30:46.209Z","repository":{"id":346540456,"uuid":"1189888139","full_name":"zas/musicbrainzpy","owner":"zas","description":"Python bindings to use MusicBrainz Web Service (json/async/modern approach)","archived":false,"fork":false,"pushed_at":"2026-03-24T15:33:13.000Z","size":188,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-03-25T11:56:00.173Z","etag":null,"topics":["musicbrainz","musicbrainz-api","python","python-bindings"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2026-03-23T19:08:23.000Z","updated_at":"2026-03-24T15:34:16.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/zas/musicbrainzpy","commit_stats":null,"previous_names":["zas/musicbrainzpy"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/zas/musicbrainzpy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zas%2Fmusicbrainzpy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zas%2Fmusicbrainzpy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zas%2Fmusicbrainzpy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zas%2Fmusicbrainzpy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zas","download_url":"https://codeload.github.com/zas/musicbrainzpy/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zas%2Fmusicbrainzpy/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31423887,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-05T02:22:46.605Z","status":"ssl_error","status_checked_at":"2026-04-05T02:22:33.263Z","response_time":75,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["musicbrainz","musicbrainz-api","python","python-bindings"],"created_at":"2026-04-05T03:30:44.421Z","updated_at":"2026-04-05T03:30:46.196Z","avatar_url":"https://github.com/zas.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MusicBrainzPy\n\nModern Python bindings for the [MusicBrainz](https://musicbrainz.org/) JSON API.\n\nThin wrapper around the [MusicBrainz Web Service v2](https://musicbrainz.org/doc/MusicBrainz_API) — handles rate limiting, authentication, and (de)serialization via Pydantic models. All responses use the JSON API (`Accept: application/json`).\n\n## Why musicbrainzpy over musicbrainzngs?\n\n| | musicbrainzngs | musicbrainzpy |\n|---|---|---|\n| API format | XML (parsed to dicts) | JSON (native) |\n| Return types | Plain dicts with `-list` suffixes | Pydantic models with IDE autocompletion |\n| Architecture | Global module state | Instance-based clients |\n| Async | No | Yes (+ sync client) |\n| Auth | Digest only | Digest + OAuth2 (PKCE, refresh, revoke) |\n| Error handling | Generic exceptions | Typed exceptions + automatic retry with backoff |\n| Maintenance | Inactive since 2023 | Active |\n| Entity coverage | Missing newer entities/fields | All 13 entity types, forward-compatible with new API fields |\n| Python | 2.7+ | 3.10+ |\n| HTTP | urllib | httpx (connection pooling, HTTP/2, timeouts) |\n| Cover Art Archive | Raw bytes only | Typed client with image listings and metadata |\n\nKey improvements:\n\n- **One method instead of dozens** — `lookup_typed(\"artist\", mbid)` replaces `get_artist_by_id`, `get_release_by_id`, `get_recording_by_id`, etc.\n- **Lucene queries directly** — no leaky abstraction that builds queries from kwargs\n- **Multiple clients** — different configs, auth, rate limits running concurrently without conflicts\n- **Resilient** — automatic retry on transient failures (connection errors, 429/503), respects `Retry-After`\n- **Zero-config** — set `MUSICBRAINZPY_*` env vars once, construct clients with no arguments\n\nComing from musicbrainzngs? See the [migration guide](docs/migrating-from-ngs.md).\n\n## Requirements\n\n- Python 3.10+\n- [httpx](https://www.python-httpx.org/) ≥ 0.28\n- [Pydantic](https://docs.pydantic.dev/) ≥ 2.10\n\n## Installation\n\nAs a dependency in another project:\n\n```bash\nuv add \"musicbrainzpy @ git+https://github.com/zas/musicbrainzpy.git\"\n```\n\nFrom source:\n\n```bash\ngit clone https://github.com/zas/musicbrainzpy.git\ncd musicbrainzpy\nuv sync\n```\n\n## Usage\n\n### Async client\n\n```python\nimport asyncio\nfrom musicbrainzpy import MusicBrainzClient\n\nasync def main():\n    async with MusicBrainzClient(\"myapp\", \"1.0\", \"me@example.com\") as client:\n        # Search for an artist\n        result = await client.search_typed(\"artist\", \"Metallica\")\n        artist = result.items[0]\n        print(f\"{artist.name} ({artist.country})\")\n\n        # Look up by MBID with includes\n        artist = await client.lookup_typed(\"artist\", artist.id, includes=[\"tags\", \"genres\"])\n\n        # Browse releases by artist\n        releases = await client.browse_typed(\n            \"release\", linked_type=\"artist\", linked_id=artist.id, limit=10\n        )\n        for r in releases.items:\n            print(f\"  {r.title}\")\n\nasyncio.run(main())\n```\n\n### Sync client\n\n```python\nfrom musicbrainzpy import SyncMusicBrainzClient\n\nwith SyncMusicBrainzClient(\"myapp\", \"1.0\", \"me@example.com\") as client:\n    result = client.search_typed(\"artist\", \"Metallica\")\n    print(result.items[0].name)\n```\n\n### Raw dict responses\n\n```python\n# All typed methods have raw equivalents returning plain dicts:\ndata = await client.lookup(\"artist\", mbid)\ndata = await client.search(\"artist\", \"Metallica\")\ndata = await client.browse(\"release\", linked_type=\"artist\", linked_id=mbid)\n```\n\n### Non-MBID lookups\n\n```python\nrecordings = await client.lookup_by_isrc(\"USEE10100063\")\nworks = await client.lookup_by_iswc(\"T-070.116.274-5\")\nreleases = await client.lookup_by_discid(discid, toc=\"1+12+267257+150\")\ndata = await client.lookup_by_url(\"https://www.metallica.com/\")\n```\n\n### Submissions (require authentication)\n\n```python\n# Option 1: Digest auth\nclient = MusicBrainzClient(\"myapp\", \"1.0\", \"me@example.com\",\n                           username=\"user\", password=\"pass\")\n\n# Option 2: OAuth2 (recommended)\nfrom musicbrainzpy import OAuthHandler\noauth = OAuthHandler(\"client-id\", \"client-secret\", \"http://localhost:8080/callback\")\nawait oauth.exchange_code(\"authorization-code\")\nclient = MusicBrainzClient(\"myapp\", \"1.0\", \"me@example.com\", oauth=oauth)\n\n# Then submit\nawait client.submit_tags({\"artist\": {mbid: [\"rock\", \"metal\"]}})\nawait client.submit_ratings({\"artist\": {mbid: 80}})\nawait client.submit_barcodes({release_mbid: \"4050538793819\"})\nawait client.submit_isrcs({recording_mbid: [\"USEE10100063\"]})\n\n# Collection management\nawait client.collection_add(collection_mbid, \"releases\", [mbid])\nawait client.collection_remove(collection_mbid, \"releases\", [mbid])\n```\n\n### Cover Art Archive\n\n```python\nfrom musicbrainzpy import SyncCoverArtClient\n\nwith SyncCoverArtClient(\"myapp\", \"1.0\", \"me@example.com\") as caa:\n    # List images for a release\n    image_list = caa.get_image_list(release_mbid)\n    for img in image_list.images:\n        print(f\"  {img.id}: {img.types} ({img.front=})\")\n\n    # Download front cover (full-size or thumbnail)\n    data = caa.get_front(release_mbid)\n    data = caa.get_front(release_mbid, size=500)  # 250, 500, or 1200\n\n    # Get image metadata without downloading\n    info = caa.image_info(release_mbid, \"front\")\n    print(f\"  {info['content_type']}, {info['content_length']} bytes\")\n```\n\nAsync version: `CoverArtClient` with the same methods (all `await`-able).\n\n### Annotation helpers\n\n```python\nfrom musicbrainzpy import annotation_to_text, annotation_to_markdown\n\n# Convert MusicBrainz wiki markup to plain text or Markdown\nplain = annotation_to_text(artist.annotation)\nmd = annotation_to_markdown(artist.annotation)\n```\n\n### Environment variables\n\nClient defaults can be set via environment variables (explicit constructor args always win):\n\n| Variable | Overrides |\n|---|---|\n| `MUSICBRAINZPY_APP` | `app_name` |\n| `MUSICBRAINZPY_VERSION` | `app_version` |\n| `MUSICBRAINZPY_CONTACT` | `app_contact` |\n| `MUSICBRAINZPY_BASE_URL` | `base_url` |\n| `MUSICBRAINZPY_USERNAME` | `username` |\n| `MUSICBRAINZPY_PASSWORD` | `password` |\n| `MUSICBRAINZPY_DEBUG` | Enable debug logging (set to any value) |\n\n```bash\nexport MUSICBRAINZPY_APP=myapp\nexport MUSICBRAINZPY_VERSION=1.0\nexport MUSICBRAINZPY_CONTACT=me@example.com\n```\n\n```python\n# No args needed when env vars are set\nclient = SyncMusicBrainzClient()\n```\n\nSee [docs/oauth2.md](docs/oauth2.md) for the full OAuth2 guide with PKCE, token refresh, and examples.\n\nMore examples in the [examples/](examples/) directory:\n\n```bash\nuv run python examples/search_artists.py\nuv run python examples/cover_art.py\n```\n\n## Development\n\n```bash\nuv sync\nuv run pytest tests/ -v\nuv run ruff check .\nuv run ruff format .\nuv run ty check\n```\n\n## License\n\n[GPL-3.0-or-later](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzas%2Fmusicbrainzpy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzas%2Fmusicbrainzpy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzas%2Fmusicbrainzpy/lists"}