This release is a pre-release and may not be stable for production use.
xazam
xazam is an async Python client for the Shazam API. It uses shazamio_core for audio fingerprinting, and adds track identification and artist metadata scraping on top.
Features
- Track identification: send audio bytes and get track metadata back.
- Artist metadata scraping: resolve artist pages and query the Apple Music catalog proxy.
- Modular transport:
ShazamTransporthandles headers and sessions.ShazamClientandShazamScraperbuild on top of it.
Install
pip install -e .
# or with dev dependencies
pip install -e ".[dev]"
Quick start
Identify a track (typed API: recommended)
import asyncio
from xazam import ShazamClient, ShazamTransport
async def main():
with open("song.mp3", "rb") as f:
audio = f.read()
async with ShazamTransport() as transport:
client = ShazamClient(transport)
result = await client.identify(audio)
if result.matched:
track = result.track
print(f"{track.title} — {track.subtitle}")
print(f"Cover art: {track.cover_art}")
print(f"Apple Music: {track.apple_music_url}")
print(f"Spotify: {track.spotify_uri}")
print(f"Lyrics: {track.lyrics[:200]}...")
else:
print("No match")
asyncio.run(main())
Fetch extra track metadata
After identification, query the track detail endpoint for lyrics, related videos, and extended metadata:
extra = await client.get_track_info(track.key)
print(extra.metadata_table) # {'Album': '…', 'Released': '…', 'Label': '…'}
print(extra.related_videos) # ['https://youtube.com/watch?v=…', ...]
Identify a track (legacy raw-dict API)
identify_track() still returns the raw Shazam JSON, for backward
compatibility:
result = await client.identify_track(audio)
print(result["track"]["title"], "—", result["track"]["subtitle"])
Scrape artist metadata
import asyncio
from xazam import ShazamScraper, ShazamTransport
async def main():
async with ShazamTransport() as transport:
scraper = ShazamScraper(transport)
data = await scraper.get_artist_metadata("3996865")
artist = data["results"]["artists"]["data"][0]
print(artist["attributes"]["name"])
asyncio.run(main())
CLI
# Identify a file
python -m xazam_cli identify --file song.mp3
# Scrape artist metadata
python -m xazam_cli scrape --artist-id 3996865
See docs/cli.md for the full command reference.
Tests
Live integration tests hit the real Shazam API. Set a custom audio file with an environment variable:
export SHAZAMPY_TEST_AUDIO="/path/to/track.mp3"
pytest tests/test_integration.py -v
Architecture
| Module | Purpose |
|---|---|
client.py |
ShazamClient: high-level track identification |
scraper.py |
ShazamScraper: artist name resolution and catalog search |
transport.py |
ShazamTransport: aiohttp sessions, headers, request helpers |
models.py |
Track, Artist dataclasses |
See docs/architecture.md for the full data flow.
Status
- Artist metadata scraping works (405 errors resolved with a dedicated web-page session).
- Track identification works (matches return correctly through
shazamio_corefingerprinting).
Related projects
- TigreGotico/pyshazam: the package that
xazamwas renamed from on PyPI. - TigreGotico/shazam2mqtt: a Dockerized bridge that uses
xazamto identify music from a microphone and publish results to MQTT.
Documentation
- docs/usage.md: library usage and error handling
- docs/cli.md: command-line reference
- docs/api.md: reverse-engineered Shazam API reference
- docs/architecture.md: internal design and data flow
- docs/dataset.md: data products and their suitability for publication
License
MIT
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file xazam-0.1.3a1.tar.gz.
File metadata
- Download URL: xazam-0.1.3a1.tar.gz
- Upload date:
- Size: 10.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
447b8219100097fc5cac458196711243b481ef4399865d643cf04dbd287f533c
|
|
| MD5 |
f6a5f418f96e673050a96313866e76c6
|
|
| BLAKE2b-256 |
5d9bf584d25c12bf5d019beda721c8a0ce0d42c6030ca641d698798674309ccf
|
File details
Details for the file xazam-0.1.3a1-py3-none-any.whl.
File metadata
- Download URL: xazam-0.1.3a1-py3-none-any.whl
- Upload date:
- Size: 9.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cea4ceda1d25c4334937c51dde02f43661998dab3cc2002bd431668ababc4775
|
|
| MD5 |
cd224b67e7f02c91b078241443801f20
|
|
| BLAKE2b-256 |
e78a7d7373019ecc35678445d88aa4751b02f74579c79c86889fdfad67b52cfa
|