home ¦ Archives ¦ Atom ¦ RSS

apple-music-python, MusicKit Authentication, and Music Assistant

It was a bit of a circuitous route, but I seem to have discovered a means to inspect a user’s Apple Music Library with Python.

Previously, when I was exploring Apple Music APIs, I landed on the apple-music-python package and its repository. Recently, I did the legwork to reactivate an old Apple Developer account and get the credentials for searching with the package.

Reading one of the repo’s issues surfaced Apple’s User Authentication for MusicKit documentation and Web flow. I started pondering if an agentic coder could do the heavy lifting involved in porting this to Python. But more research was in order. Surely there must be another Python package that dealt with this?

Then I learned about Music Assistant.

Music Assistant is a music library manager for your offline and online music sources which can easily stream your favourite music to a wide range of supported players and be combined with the power of Home Assistant!

Music Assistant Server

The Music Assistant server is a free, opensource Media library manager that connects to your streaming services and a wide range of connected speakers. The server is the beating heart, the core of Music Assistant and it keeps track of your music sources. It must run on an always-on device like a Raspberry Pi, a NAS or an Intel NUC or alike. The server can access multiple music providers and stream to multiple player types.

One of the output providers is Sonos 😲 💥 🎉! My fave!! And a supported streaming service is, guess what, Apple Music, including a nice auth flow according to this pull request.

So yes indeed, someone else had dealt with this issue. The solution looked a bit hairy though, so I decided to revisit apple-music-python one last time. Jonathan Jacobson had submitted a yet to be accepted PR that extended apple-music-python under the assumption that the Music User Token was already available, something that can be handled via Music Assistant.

Bringing it all together, in the short term, I’m just going to install Music Assistant and experiment with Apple Music support. Can’t imagine it’ll be too hard to pry out a Music User Token, assuming I can actually authenticate. Then I’ll just experiment with Jacobson’s package repo that upgrades apple-music-python.

The ultimate goal is to augment scrobbledb with the ability to enrich the data with information from my favorite DJ mix platform.

© 2008-2025 C. Ross Jam. Licensed under CC BY-NC-SA 4.0 Built using Pelican. Theme based upon Giulio Fidente’s original svbhack, and slightly modified by crossjam.