Announcements

Help Wizard

Step 1

NEXT STEP

FAQs

Please see below the most popular frequently asked questions.

Loading article...

Loading faqs...

VIEW ALL

Ongoing Issues

Please see below the current ongoing issues which are under investigation.

Loading issue...

Loading ongoing issues...

VIEW ALL

`Get Artist` API endpoint responds with result in inconsistent format

`Get Artist` API endpoint responds with result in inconsistent format

Hi all, I've found the following inconsistency in API endpoint response format:

 

when I request the endpoint Get Track, I get the response formatted pretty and all integer values are presented like the should be (without any floating points):

$ curl -s --request GET \
--url "https://api.spotify.com/v1/tracks/11dFghVXANMlKmJXsNCbNl" \
--header "Authorization: Bearer $TOKEN"

{
"album" : {
"album_type" : "single",
"artists" : [ {
"external_urls" : {
"spotify" : "https://open.spotify.com/artist/6sFIWsNpZYqfjUpaCgueju"
},
"href" : "https://api.spotify.com/v1/artists/6sFIWsNpZYqfjUpaCgueju",
"id" : "6sFIWsNpZYqfjUpaCgueju",
"name" : "Carly Rae Jepsen",
"type" : "artist",
"uri" : "spotify:artist:6sFIWsNpZYqfjUpaCgueju"
} ],
"available_markets" : [ ],
"external_urls" : {
"spotify" : "https://open.spotify.com/album/0tGPJ0bkWOUmH7MEOR77qc"
},
"href" : "https://api.spotify.com/v1/albums/0tGPJ0bkWOUmH7MEOR77qc",
"id" : "0tGPJ0bkWOUmH7MEOR77qc",
"images" : [ {
"height" : 640,
"url" : "https://i.scdn.co/image/ab67616d0000b2737359994525d219f64872d3b1",
"width" : 640
}, {
"height" : 300,
"url" : "https://i.scdn.co/image/ab67616d00001e027359994525d219f64872d3b1",
"width" : 300
}, {
"height" : 64,
"url" : "https://i.scdn.co/image/ab67616d000048517359994525d219f64872d3b1",
"width" : 64
} ],
"name" : "Cut To The Feeling",
"release_date" : "2017-05-26",
"release_date_precision" : "day",
"total_tracks" : 1,
"type" : "album",
"uri" : "spotify:album:0tGPJ0bkWOUmH7MEOR77qc"
},
"artists" : [ {
"external_urls" : {
"spotify" : "https://open.spotify.com/artist/6sFIWsNpZYqfjUpaCgueju"
},
"href" : "https://api.spotify.com/v1/artists/6sFIWsNpZYqfjUpaCgueju",
"id" : "6sFIWsNpZYqfjUpaCgueju",
"name" : "Carly Rae Jepsen",
"type" : "artist",
"uri" : "spotify:artist:6sFIWsNpZYqfjUpaCgueju"
} ],
"available_markets" : [ ],
"disc_number" : 1,
"duration_ms" : 207959,
"explicit" : false,
"external_ids" : {
"isrc" : "USUM71703861"
},
"external_urls" : {
"spotify" : "https://open.spotify.com/track/11dFghVXANMlKmJXsNCbNl"
},
"href" : "https://api.spotify.com/v1/tracks/11dFghVXANMlKmJXsNCbNl",
"id" : "11dFghVXANMlKmJXsNCbNl",
"is_local" : false,
"name" : "Cut To The Feeling",
"popularity" : 0,
"preview_url" : null,
"track_number" : 1,
"type" : "track",
"uri" : "spotify:track:11dFghVXANMlKmJXsNCbNl"
}%

Same with the other API endpoints and this is OK.

 

But when I request Get Artist endpoint, then I get the response in a kind of raw form (not formatted with new line characters and extra spaces) where integer values are presented like float point numbers:

 

$ curl -s --request GET \
--url "https://api.spotify.com/v1/artists?ids=5K4W6rqBFWDnAN6FQUkS6x" \
--header "Authorization: Bearer $TOKEN"

{"artists":[{"external_urls":{"spotify":"https://open.spotify.com/artist/5K4W6rqBFWDnAN6FQUkS6x"},"followers":{"href":null,"total":2.3015237E7},"genres":["chicago rap","hip hop","rap"],"href":"https://api.spotify.com/v1/artists/5K4W6rqBFWDnAN6FQUkS6x","id":"5K4W6rqBFWDnAN6FQUkS6x","images":[{"url":"https://i.scdn.co/image/ab6761610000e5eb867008a971fae0f4d913f63a","height":640.0,"width":640.0},{"url":"https://i.scdn.co/image/ab67616100005174867008a971fae0f4d913f63a","height":320.0,"width":320.0},{"url":"https://i.scdn.co/image/ab6761610000f178867008a971fae0f4d913f63a","height":160.0,"width":160.0}],"name":"Kanye West","popularity":91.0,"type":"artist","uri":"spotify:artist:5K4W6rqBFWDnAN6FQUkS6x"}]}% 

 

This is probably an inconsistency in the API endpoints behaviour - please pay some attention.

 

Plan

Premium

Country

Poland

 

Reply
8 Replies

The correct curl to get an art is:

 

$ curl -s --request GET \
--url "https://api.spotify.com/v1/artists/5K4W6rqBFWDnAN6FQUkS6x" \
--header "Authorization: Bearer $TOKEN"

 

you don't need to have an `ids` param

You can use the both paths (api.spotify.com/v1/artists/<artist_id> or api.spotify.com/v1/artists?ids=<artist_ids>) - it doesn't matter in this case as the format inconsistency in the responses is still there.

There seems to be a problem with the Get Artist(s) endpoint. Different users are reporting problems about it returning floats instead of integers.

XimzendSpotify Star
Help others find this answer and click "Accept as Solution".
If you appreciate my answer, maybe give me a Like.
Note: I'm not a Spotify employee.

Yeah im having the same problem and spotify doesnt address it or comment on it! 

Well, they did have 3 massive layoffs this year.

Add a `ME TOO` to the issue

I am getting this issue too on the https://api.spotify.com/v1/artists endpoint. 

Me too

I am also having this issue where the integer values become floating point.

 

I am using the Get Track endpoint.

The fields include: image width and height, album disc number, duration ms, track number and popularity

Im getting a :
'name': artist_response['name'],
~~~~~~~~~~~~~~~^^^^^^^^
KeyError: 'name'

error. i dont really understand why since it was working for a while before, but since this morning I tried to figure out the issuse and nothing I could do so far. If anyone knows a way to fix this let me know I would appreciate it. I am using django and react.

 

class CurrentArtist(APIView😞
def get(self, request, format=None😞
room_code = self.request.session.get('room_code')
room = Room.objects.filter(code=room_code).first()
 
if not room:
return Response({'error': 'Room not found'}, status=status.HTTP_404_NOT_FOUND)
 
host = room.host
endpoint = "me/player/currently-playing"
response = execute_spotify_api_request(host, endpoint)
 
if 'error' in response or 'item' not in response:
return Response({}, status=status.HTTP_204_NO_CONTENT)
 
artist_info = []
for artist in response['item']['artists']:
artist_id = artist['id']
artist_endpoint = f"artists/{artist_id}"
artist_response = execute_spotify_api_request(host, artist_endpoint)
if 'error' not in artist_response:
artist_data = {
'name': artist_response['name'],
'followers': artist_response['followers']['total'],
'popularity': artist_response['popularity'],
'type': artist_response['type'],
'uri': artist_response['uri'],
}
 
if artist_response['images']:
 
image_url = artist_response['images'][0]['url']
artist_data['image_url'] = image_url
else:
artist_data['image_url'] = None
artist_info.append(artist_data)
 
return Response(artist_info, status=status.HTTP_200_OK)
 

 

Suggested posts

Type a product name