Apple Music API

RSS for tag

Apple Music API integrates streaming music with Apple Music content.

Apple Music API Documentation

Posts under Apple Music API tag

98 Posts
Sort by:
Post not yet marked as solved
0 Replies
38 Views
I'm developing an app which utilises playback from the Apple Music catalogue using MusicKit. Playback works fine however, whenever the playback state changes the ApplicationMusicPlayer.shared.state.objectWillChange publisher is fired twice. Moreover, with each emit the ApplicationMusicPlayer.shared.state is different. An example: Music is playing in my app. Music is paused. (Through any method of pausing) The objectWillChange publisher is called twice. In first call state is .playing In the second call state is .paused The same happens if playback is then resumed except the states switch. First, .paused and then .playing. I'm using Combine's .sink() method. I've checked for accidental duplicate subscriptions but there is only one. Is this the intended behaviour or is this an issue?
Posted
by
Post not yet marked as solved
0 Replies
39 Views
In this thread it has been stated that getting artist artwork through the MusicKit api isn't allowed because of copyright issues. My question is: Is using the Apple Music REST api to get album artwork via the OpenGraph API also disallowed such that my app would be rejected? Wonder if I should pursue this option that I found or if I need to find another way? Seems like the answer would be no, but wanted to double check. Thanks for your response, this is my first app that I'm trying to publish to the store and I'd like to avoid getting an instant rejection for something like this. Code snippet: import MusicKit import Foundation import OpenGraph extension Artist {     func artwork(width: Int = 1024, height: Int = 1024) async -> URL? {         let id = self.id.rawValue         let countryCode = try? await MusicDataRequest.currentCountryCode         let url = URL(string: "https://music.apple.com/\(countryCode ?? "us")/artist/\(id)")!         return await withCheckedContinuation { continuation in             OpenGraph.fetch(url: url) { result in                 switch result {                     case .success(let og):                         let image = og[.image]?.resizeArtwork(width: width, height: height)                         if let image = image, let url = URL(string: image) {                             continuation.resume(returning: url)                         } else {                             continuation.resume(returning: nil)                         }                     case .failure(_):                         continuation.resume(returning: nil)                 }             }         }     } } extension String {     func resizeArtwork(width: Int, height: Int) -> String? {         do {             let regex = try NSRegularExpression(pattern: "/\\d+x\\d+cw", options: .caseInsensitive)             let newImage = regex.stringByReplacingMatches(in: self, options: [], range: NSRange(0..<self.utf16.count), withTemplate: "/\(width)x\(height)cc")             return newImage         } catch {             return nil         }     } }
Posted
by
Post not yet marked as solved
0 Replies
47 Views
When working with embedded web content inside a native app, any calls to MusicKit.authorize will not be properly authenticate. Calling authenticate will open Safari, allow the user to login, then ask for user confirmation, but the window will not navigate back to the native app. Is it expected that developers would have to enable associated domains for the native app?
Posted
by
Post not yet marked as solved
0 Replies
109 Views
Hello! I am currently working on a react.js application that is integrating with the MusicKit v3 library. I have followed the documentation to generate a JWT for MusicKit and add the library to my application. Using my token I am able to successfully retrieve song information from the Apple Music API, but I am having trouble with authentication. When I call music.authorize() and successfully go through the Apple sign in popup, I am receiving the following 403 error: https://play.itunes.apple.com/WebObjects/MZPlay.woa/wa/webPlayerLogout 403 musickit.js:44 Uncaught (in promise) AUTHORIZATION_ERROR: Unauthorized After stepping through the music kit API and login popup with breakpoints, I am seeing that the music user token is null, despite the login popup succeeding and returning a proper token/response: {"isAppleMusicSubscriber":"true","musicUserToken":"Ak4ItOgRRRG2y6xgA/OeWQPK0RqPQ/esAJkRN0B/Ua/AWLT52tLhd2TfzMK6uhH+Nczvd7wjYDM1UewG/NledKtimwlrR+s5tdQPk/FG28zqhBqXZ12q6LC516w8ELZDwv5T61kV8xiJ1KSO1q4pGi01JO7SuPMtOqB/QsycYj+xNnrYUEwlP5tm/zxfg7bWmvuWMwfUruYR+A1U9FdXZsdIITVmxCjiHg8ro9xXRzl6Txhsag\u003d\u003d","cid":"REDACTED","itre":"REDACTED","supported":"REDACTED"} I have tested my application with multiple Apple Music users who have paid subscriptions. All accounts are receiving this same error. I have tried regenerating my JWT token multiple times following various guides. My latest attempt used the following node library and parameters: var jwt = require('jsonwebtoken'); var fs = require('fs'); var privateKey = fs.readFileSync('./AuthKey_MYKEY.p8'); let now = new Date(); let nextMonth = new Date(now.getFullYear(), now.getMonth() + 1, now.getDate()); let nowEpoch = Math.round(now.getTime() / 1000); // number of seconds since Epoch, in UTC let nextMonthEpoch = Math.round(nextMonth.getTime() / 1000); // number of seconds since Epoch, in UTC var payload = {     iss: 'REDACTED', // TEAM ID     iat: nowEpoch,     exp: nextMonthEpoch }; var options = {     algorithm: 'ES256',     header: {         alg: 'ES256',         kid: 'REDACTED' // KEY ID     } }; jwt.sign(payload, privateKey, options, function(error, token) {     console.log(error);     console.log(token); }); I have a valid App Identifier created with the MusicKit App Service enabled. I am stuck! I have no other ideas on the possible root cause here. Is there something I am missing? I have a mobile app currently in Test Flight - does this app need to be released to the app store? I am out of guesses! Any support here would be greatly appreciated! Thank you for your time. Patrick
Posted
by
Post not yet marked as solved
0 Replies
59 Views
The supported Relationship Views for Albums in the API include appears-on, other-versions, related-albums, related-videos, but it doesn't support more-by-artist, this data is available when viewing the album in the Apple Music app and would be very useful if it was available in the Apple Music API and possibly MusicKit as well with new iOS update.
Posted
by
Post not yet marked as solved
0 Replies
69 Views
Is it possible to play songs/playlists on another device on the same account of the user. Effectively, remote control. ex: I own a Mac Book and an iPad, my iPad is connected to speakers, I want to stop and start playing music on the iPad using my Mac Book, through APIs.
Posted
by
Post not yet marked as solved
1 Replies
115 Views
Hi there! I have been trying to play the music videos we get from Apple Music API and have been unsuccessful. Here's my code: var video: MusicVideo var body: some View { VideoPlayer(player: AVPlayer(url: video.url!)) } I know the URL from the MusicVideo is not in a music format but just the URL to the video in the Apple Music catalog. How do I go about playing it without using something like MPMusicPlayerController.systemMusicPlayer.openToPlay(queueDescriptor) and provide an in-app experience (and not take the user to the Apple Music app)?
Posted
by
Post marked as solved
3 Replies
153 Views
When attempting to authenticate with the musickit-js v3, the page that gets loaded from authorize.music.apple.com results in an error "Cannot parse response" On the desktop, this does not happen. The authentication code in question is async login() { const mkInst = MusicKit.getInstance(); await mkInst.authorize(); } Not sure if this is limited to V3, as it's technically not officially released, but figured it was worth bringing to attention.
Posted
by
Post not yet marked as solved
0 Replies
65 Views
given a song storeId from a storefront other than my own. Is there a apple music API call to determine if the song is playable. For example song A is from the gb storefront and my apple music account uses storefront au. Can I play this track without getting a playback error
Posted
by
Post marked as solved
2 Replies
213 Views
I am making a media player for Apple iOS and wanted it to be able to pull my music library using an API. The closest thing I found to this is this: https://developer.apple.com/musickit/ However, I don't know if it will allow users to play their music purchased by apple. Does anyone know how to do this so the user logs into their apple account through my app and then has complete access to their movies, tv shows, and music? Any answers are really appreciated I did my best to find the answer to this and know its annoying to ask these questions when google or apple has it documented somewhere.
Posted
by
Post not yet marked as solved
0 Replies
117 Views
Hi there, I can see dateAdded when looking at the response of a get library playlist request via the Apple Music API, but this does not appear to exist on any tracks within a given library playlist. I'm assuming that this just isn't there, but I'm asking here, in case I've missed it. Thanks.
Posted
by
Post not yet marked as solved
3 Replies
225 Views
Hello! When creating a playlist we are getting an id which is the one in the user's library, it's not enough to create a link and share it with friends for example. To do so, we need a global id. The only way I found to generate this global id is by clicking on the share button of the playlist on Apple Music. After doing this manual action, the global id is properly returned by the Playlist endpoint on the Apple Music API. I wanted to know if there was a endpoint that could be called in order to generate this global id without having to go on the Apple Music app? Thanks for your help
Posted
by
Post not yet marked as solved
5 Replies
313 Views
Hello, I have a question regarding the update of playlists through the API. I haven't found this documented, but I prefer asking just in case I missed something. Is there an endpoint/parameter to add tracks to a playlist by overriding the tracks that are in it? I only found an endpoint to append tracks to a playlist, which is not enough for how my app works Thanks!
Posted
by
Post not yet marked as solved
4 Replies
273 Views
Hello, I'm using the Apple Music API to store tracks & albums links in my database and I need a way to determine if a track/album is available for purchase on iTunes or if it's a streaming one. I'm currently using the "playParams" attribute to determine it. If it is present I consider the track to be streaming, if it's not, I consider it to be a purchasable track. I'm not sure if this is the best way to do so, I'd gladly take your recommendations, maybe there's an attribute I missed on the API.
Posted
by
Post not yet marked as solved
5 Replies
296 Views
Hello, with the recent update of the Apple Music API allowing to retrieve artwork for artists, I wanted to know if it was possible to post an artwork when creating a playlist through the API? If so, what is the format and parameters to use and is it documented somewhere? Thanks for your help
Posted
by