Apple Music API

RSS for tag

Apple Music API integrates streaming music with Apple Music content.

Posts under Apple Music API tag

79 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

"Add to Favorites" on Apple Music API
Is there any way to make an API call that would add an artist to a user's favorites, like this article outlines? https://support.apple.com/guide/music/select-artists-as-favorites-musf33a29ebf/mac I know I am able to add individual resources (song, album, playlists) to user libraries but I specifically want to add a favorite artist. Thank you in advance to anybody with thoughts.
0
0
449
Jul ’23
Apple Music API: only get full Albums from user's library
If a user has only added one song from an album in its library, the library album endpoint (/me/library/albums) will return this album. It does not make sense because the user did not add the full album to its library, only one song. Note that the Apple Music app is doing the same in its Library > Albums section. How to retrieve only those albums which have been added ?
0
0
571
Jul ’23
Language Setting for Music App
Hello. I'm Korean, and the system language of macOS is in English because user directories such as Desktop and Document should be displayed in English. As I use the system language in English, the singers and song names of the Korean songs of Apple Music are also displayed in English. It is so confused to find the song in the App, or to talk about the song with other people. I'm using Apple Music with my Korean account, and I'm also using the region of the system in Korea. There is a function to customize language settings for the specific applications, so I tried to change the language setting of the Music App (specific app) to Korean. In this case, Music Apps are displayed in Korean. But the song information (singer, title) and various playlists are still displayed in English. Many Korean users are suffered with this problem, so I think there should be some ways to see the information of Korean music sources in Korean in the Music App preferences, other than changing the system language of macOS and iOS.
0
0
684
Jul ’23
User login flow with nodeJS
Hi everyone. I am creating a ReactNative application which requires user's data from his/her apple music account. In order to retrieve user's apple music data, I understand that I need both a developer token and a user's access token with the appropriate scope for Apple Music. https://developer.apple.com/documentation/applemusicapi/user_authentication_for_musickit I had created developer token and tested it, suggested by documentation https://developer.apple.com/documentation/applemusicapi/generating_developer_tokens For user's login, I am creating login URL with the npm package apple-auth and configuration object is export const con: any = { client_id: clientId, team_id: teamId, key_id: keyId, redirect_uri: "https://api.borrow4less.ca/api/v1/welcome", scope: "email", }; I registered a service identifier for domain/subdomain and returnURL. when I go the login url it shows login url is :https://appleid.apple.com/auth/authorize?response_type=code%20id_token&client_id=com.QueueMusic&redirect_uri=https://api.borrow4less.ca/api/v1/welcome&state=489612589c&scope=email&response_mode=form_post Invalid client id or web redirect url. I would greatly appreciate any guidance or insights from the community regarding the correct configuration object to use with "apple-auth" or any alternative. Regards
0
0
773
Jul ’23
Determining song availability based on user's region or country in MusicKit
I'm currently working on integrating MusicKit into my app and would like to provide a seamless user experience by displaying only the songs that are available in the user's region or country. However, after going through the MusicKit documentation, I couldn't find a direct method to determine song availability based on the user's location. I wanted to inquire if there is a way to determine if a specific song or a catalog of songs is available in the user's region or country using MusicKit. It would be incredibly helpful if someone could guide me on how to achieve this or provide any insights on alternative approaches. Thank you in advance for your assistance!
0
0
409
Jul ’23
[Apple Music API] How can i control Music User Token expiration time?
Hello there! I have a problem: when i create Music User Token via AppleMusicKit, it returns me token that expires after one or two days. But regarding to this threads - https://developer.apple.com/forums/thread/654814 https://developer.apple.com/forums/thread/685343 it should expire in 6 months! Do I need to consider something when creating a token so that its lifetime will be 6 months and not 2 days? Maybe something with developer token or with MusicKit? Maybe something in apple account? p.s. i tried to find solution of this problem in internet and noticed that many other people have such problem too. And no one got any answers expect that token should live 6 months.
4
3
1.3k
Jul ’23
MusicKit MusicCatalogResourceRequest for artists with top-songs returns 504 in non-json format
I'm making a request to get 10 artists with their top songs at once, but for some artists it will always fail with a 504. The response is also in HTML which leads to a decoding error. This is my code var request = MusicCatalogResourceRequest<Artist>(matching: \.id, memberOf: ids) request.properties = properties let response = try await request.response() where ids is MusicItemId. Below I have an input which will always fail 100% of the time, even when retried. 10 elements  - 0 : "51639"  - 1 : "331584"  - 2 : "120199"  - 3 : "45058"  - 4 : "284786497"  - 5 : "44984"  - 6 : "37299"  - 7 : "518462"  - 8 : "39525"  - 9 : "73568" Example response: [DataRequesting] Failed to parse body of response with status code Unknown (504):  <!DOCTYPE html> <html lang="en"> <head>   <style>     body {       font-family: "Helvetica Neue", "HelveticaNeue", Helvetica, Arial, sans-serif;       font-size: 15px;       font-weight: 200;       line-height: 20px;       color: #4c4c4c;       text-align: center;     }     .section {       margin-top: 50px;     }   </style> </head> <body> <div class="section">   <h1>&#63743;</h1>   <h3>Gateway Timeout</h3>   <p>Correlation Key: WFRI6Q5HXAUJYXGNRKQ6YTBYIM</p> </div> </body> </html> I have also tried batching these into 2 requests of 5 artists instead of 1 request of 10 artists which still fails. However, I do have sets of 10 artists that work fine. Anyone know why?
3
1
2k
May ’24
Apple Music Kit Web API - User's Top Played Songs/Artists
Hello everyone! I am using the web version of the Apple Music Kit API, and similar to how Apple is able to produce a user's year in rewind playlist showing the most played artists/songs from a year, I am trying to replicate it for either a year or all time. I have been searching the internet for days trying to figure it out, but I've been completely stuck. I am able to make the following HTTP request successfully. GET https://api.music.apple.com/v1/me/library/songs/ which returns back the user's library of songs, but I haven't figured out how to get the play count. I have tried adding a query like such ?extend=playCount, but that doesn't work. I can see here that the Swift Music Kit API is able to extend a play count property, but I haven't been able to figure it out for Web. Ideally, I am looking for an endpoint that just shows a user's top artist/tracks similar to Spotify, however, whenever I try to use the heavy in rotation endpoint here, it always returns an empty array. The way that I have described is the long-roundabout way where I'll have to fetch each individual song and sort by playCount. But if anyone happens to know how I can do either of the options I've described, it will be truly appreciated ! I've seen other forums posts from years ago, but hopefully there's been a discovered way. Thank you!
2
1
1.8k
Sep ’23
Can't access chart playlists for a specific genre
I am trying to offer my users a wide variety of playlists, like Apple Music does in the "explore" section. I fetched the charting playlists for the current storefront, but that's as far as I get. For example, I fetch the top charts genres first. If a user selects a genre I want to display the playlists for this genre, so I call the charts endpoint with the genre as the id but I can't get a response. path = "/v1/catalog/\(storefrontID)/charts" components.queryItems = [ URLQueryItem(name: "types", value: "playlists"), URLQueryItem(name: "chart", value: "most-played") ] if let id = id { let genreQuery = URLQueryItem(name: "genre", value: id) components.queryItems?.append(genreQuery) } Even weirder, I get exactly one genre "Musik" (which isn't a genre) with identifier "34" and storefrontId "de" where it works and I get my playlists. All other genre return empty responses. I try to use AppleMusic API with MusicKit as an addition, but there doesn't seem to be a solution for this problem either.
2
1
925
Aug ’23
MusicKit Dev Token Refresh
I am trying to follow along with this in order to auto generate my dev token on requests to MusicKit, but I am getting an error about by identifier, which was configured Link: https://developer.apple.com/documentation/musickit/using-automatic-token-generation-for-apple-music-api Error: 2022-04-26 14:12:06.353589-0400 [6885:431407] [DataRequesting] Failed retrieving developer token: Error Domain=ICErrorDomain Code=-8200 "Media API Token Service responded with status code: Not Found (404). This suggests that "<set_bundle_ID>" was likely not registered as a valid client identifier." UserInfo={NSDebugDescription=Media API Token Service responded with status code: Not Found (404). This suggests that "<set_bundle_ID>" was likely not registered as a valid client identifier., NSUnderlyingError=0x2827669a0 {Error Domain=AMSErrorDomain Code=301 "Invalid Status Code" UserInfo={NSLocalizedDescription=Invalid Status Code, AMSURL=https://sf-api-token-service.itunes.apple.com/apiToken?REDACTED, AMSStatusCode=404, AMSServerPayload={     message = "Client not found";     status = 40402; }, NSLocalizedFailureReason=The response has an invalid status code}}}. Throwing .developerTokenRequestFailed. error getting token
4
0
1.6k
Oct ’23
How can I play Apple Music Live Radio Station?
Hello, I'm using systemMusicPlayer to play Apple Music Live Radio Station got from Apple Music API. But it doesn't work. How can I do that? Error: Test[46751:13235249] [SDKPlayback] Failed to prepareToPlay error: Error Domain=MPMusicPlayerControllerErrorDomain Code=6 "Failed to prepare to play" UserInfo={NSDebugDescription=Failed to prepare to play} My implementation:    let musicPlayerController = MPMusicPlayerController.systemMusicPlayer musicPlayerController.beginGeneratingPlaybackNotifications()      musicPlayerController.setQueue(with: "ra.978194965")     musicPlayerController.play() API response: { “id”: “ra.978194965”, “type”: “stations”, “href”: “/v1/catalog/us/stations/ra.978194965”, “attributes”: { “artwork”: { “width”: 4320, “url”: “https://is2-ssl.mzstatic.com/image/thumb/Features114/v4/e5/10/76/e5107683-9e51-ebc5-3901-d8fbd65f2c2a/source/{w}x{h}sr.jpeg”, “height”: 1080, “textColor3”: “332628”, “textColor2”: “120509”, “textColor4”: “33272a”, “textColor1”: “000000”, “bgColor”: “f4f4f4”, “hasP3”: false }, “url”: “https://music.apple.com/us/station/apple-music-1/ra.978194965”, “mediaKind”: “audio”, “supportedDrms”: [ “fairplay”, “playready”, “widevine” ], “requiresSubscription”: false, “name”: “Apple Music 1”, “kind”: “streaming”, “radioUrl”: “itsradio://music.apple.com/us/station/ra.978194965”, “playParams”: { “id”: “ra.978194965”, “kind”: “radioStation”, “format”: “stream”, “stationHash”: “CgkIBRoFlaS40gMQBA”, “mediaType”: 0 }, “editorialNotes”: { “name”: “Apple Music 1”, “short”: “The new music that matters.”, “tagline”: “The new music that matters.” }, “isLive”: true } },``` Thank you! Best regards, MichaelNg
2
0
1.9k
Aug ’23
ERROR_FAILED_TO_VERIFY_JWT error when trying to link with Apple Music
I want to use Apple Music using MusicKit. I've created MusicKit identifier and private key by following all the steps mentioned here: https://help.apple.com/developer-account/#/devce5522674 I have my Team ID, the Music key ID and the private key (.p8 file) with me. I tried to generate the required JWT token by using many scripts that were mentioned in similar questions asked here, but none of them have worked so far. When I try to authenticate, I'm getting an error ERROR_FAILED_TO_VERIFY_JWT. Ref: Codes I've tried to generate the JWT token from: Thread 130168 - https://developer.apple.com/forums/thread/130168 A nice and simple blog by Lee Martin [Blog - Creating an Apple Music API Token] Thread 79074 - https://developer.apple.com/forums/thread/79074 Many other links But sadly, none of them worked and I had to post this question. I have tried the sample Android app: https://developer.apple.com/download/more/?=Android%20MusicKit After authentication, the page goes on with an infinite loader, which I believe must be because of the same error ERROR_FAILED_TO_VERIFY_JWT Also tried with this HTML page: <html> <head> <meta name="apple-music-developer-token" content="the-JWT-token-generated-using-the-reference-links"> <meta name="apple-music-app-name" content="My App Name"> <meta name="apple-music-app-build" content="1978.4.1"> </head> <body> <button id="apple-music-authorize"></button> <button id="apple-music-unauthorize"></button> </body> <script src="link-to-musickit.js"></script> <script> let music = MusicKit.getInstance(); &#9;&#9;music.player.play(); &#9;&#9;music.authorize().then(function() { &#9;&#9;&#9;&#9;music.player.play(); &#9;&#9;}); &#9;&#9;music.authorize().then(function() { &#9;&#9;&#9;&#9; music.api.library.albums.then(function(cloudAlbums) { &#9;&#9;&#9;&#9;&#9;&#9;&#9;// user's cloudAlbums &#9;&#9;&#9;&#9;}); &#9;&#9;}); </script> </html>
4
0
2.6k
Sep ’23
MPMusicPlayerController prepareToPlay errors
I'm getting a variety of errors when I call prepareToPlay on the MPMusicPlayerController. Sometimes they happen, sometimes they don't. I'm trying to play songs from the Apple Music service. When I don't get the errors, it plays just fine. I have iOS v13.5.1 on my iPhone Xs and I'm using Xcode 11.5. This is my code: let applicationMusicPlayer = MPMusicPlayerController.applicationMusicPlayer applicationMusicPlayer.setQueue(with: [trackID]) applicationMusicPlayer.prepareToPlay(completionHandler:{ error in if let error = error { print(error.localizedDescription) return } DispatchQueue.main.async{ applicationMusicPlayer.play() } } These are the various errors I'm getting: [SDKPlayback] Failed to prepareToPlay error: Error Domain=MPMusicPlayerControllerErrorDomain Code=2 "Queue was interrupted by another queue" UserInfo={NSDebugDescription=Queue was interrupted by another queue} [SDKPlayback] Failed to prepareToPlay error: Error Domain=MPMusicPlayerControllerErrorDomain Code=9 "Preparing queue timed out" UserInfo={NSDebugDescription=Preparing queue timed out} [SDKPlayback] Failed to prepareToPlay error: Error Domain=MPMusicPlayerControllerErrorDomain Code=6 "Failed to prepare to play" UserInfo={NSDebugDescription=Failed to prepare to play} [SDKPlayback] applicationQueuePlayer _establishConnectionIfNeeded timeout [ping did not pong]
7
0
4.2k
Mar ’24
Music API does not return smart playlists from Library
I tried to use smart playlist to get all liked songs. But Smart playlists are not returned from Library Playlists endpoint https://api.music.apple.com/v1/me/library/playlists — only the regular playlists are returned.Is there a way to fetch user's smart playlists?If not is there a way to fetch liked songs? Currently I have to load ALL songs and the ratings for all of them, then manually filter. It takes ridiculous amount of time, especially because page size is limited to 100. Btw, is there a way to increase it?
1
1
875
Aug ’23