title: How to get artist ID for all artists in Apple Music for a user
body: <p>Using Apple Music API I was able to get all artists in my library:</p>
  
  <pre><code>func getArtists(forToken musicUserToken: String) {
      var urlComponents = URLComponents()
      urlComponents.scheme = "https"
      urlComponents.host = "api.music.apple.com"
      urlComponents.path = "/v1/me/library/artists"
  
      var request = URLRequest(url: urlComponents.url!)
      request.setValue("Bearer (developerToken)", forHTTPHeaderField: "Authorization")
      request.setValue(musicUserToken, forHTTPHeaderField: "Music-User-Token")
  
      let dataTask = URLSession.shared.dataTask(with: request) { (data, urlResponse, error) in
          ...
      }
      dataTask.resume()
  }
  </code></pre>
  
  <p>For example, the code above returns this JSON:</p>
  
  <pre><code>{
      "data":[
          {
              "attributes":{
                  "name":"Anne-Marie"
              },
              "href":"/v1/me/library/artists/r.wb9aRPu",
              "id":"r.wb9aRPu",
              "type":"library-artists"
          },
          {
              "attributes":{
                  "name":"Bruno Mars"
              },
              "href":"/v1/me/library/artists/r.zCrRBIw",
              "id":"r.zCrRBIw",
              "type":"library-artists"
          },
          ...
      ]
  }
  </code></pre>
  
  <p>But, it seems to me that each object refers to an artist <em>in my library</em> and not the artist in the Apple Music Library. Because if I get the artist <code>id</code> and try to get this artist albums, nothing is found. For example, a GET to the URL <code>https://api.music.apple.com/v1/catalog/us/artists/r.wb9aRPu</code> returns an error:</p>
  
  <pre><code>{
      "errors":[
          {
              "id":"GJXVG3NROYGJPDRECZLCPYKLEQ",
              "title":"Internal Service Error",
              "status":"500",
              "code":"50000"
          }
      ]
  }
  </code></pre>
  
  <p>But if I do the same GET for the artist ID 178834 (which I got from an example on Apple's website), it returns the correct response:</p>
  
  <pre><code>{
      "data":[
          {
              "id":"178834",
              "type":"artists",
              "href":"/v1/catalog/us/artists/178834",
              "attributes":{
                  "name":"Bruce Springsteen",
                  "genreNames":[
                      "Rock"
                  ],
                  "url":"https://itunes.apple.com/us/artist/bruce-springsteen/178834"
              },
              "relationships":{
                  "albums":{
                      "data":[
                          {
                              "id":"1136909069",
                              "type":"albums",
                              "href":"/v1/catalog/us/albums/1136909069"
                          },
                          {
                              "id":"1134170183",
                              "type":"albums",
                              "href":"/v1/catalog/us/albums/1134170183"
                          },
                          ...
                      ],
                      "href":"/v1/catalog/us/artists/178834/albums",
                      "next":"/v1/catalog/us/artists/178834/albums?offset=144"
                  }
              }
          }
      ]
  }
  </code></pre>
  
  <p>What I want to do is to get all albums from all artists that a user has in his library. But I cannot do this with the artist ID that <code>/me/library/artists</code> returns. So, <strong>is there another way to get the artist ID for the artists that the user has in the library?</strong></p>