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

The response type of artist endpoint is marked as Integer in document, but actually return float

The response type of artist endpoint is marked as Integer in document, but actually return float

Plan

Free/Premium

Country

 

Device

(iPhone 8, Samsung Galaxy 9, Macbook Pro late 2016)

Operating System

(iOS 10, Android Oreo, Windows 10,etc.)

 

My Question or Issue

I am the author of RSpotify: https://github.com/ramsayleung/rspotify, a popular community-driven SDK for Spotify built on top of Rust.

 

Recently, the user of RSpotify reported a bug to me: https://github.com/ramsayleung/rspotify/issues/452

 

the RSpotify failed to parse the response body of artist endpoint to JSON because it's unable to convert Float data to Integer. 

 

followers.totalpopularity are both marked as integer in the document:https://developer.spotify.com/documentation/web-api/reference/get-an-artist, but data in response are both float.

 

I manage to reproduce this problem with the tool provided by Spotify.

 

When I called the endpoint with tool on the right side of the document, thefollowers.totalpopularity are integer:

 

{
  "external_urls": {
    "spotify": "https://open.spotify.com/artist/1dfeR4HaWDbWqFHLkxsg1d"
  },
  "followers": {
    "href": null,
    "total": 49022656
  },
  "genres": ["classic rock", "glam rock", "rock"],
  "href": "https://api.spotify.com/v1/artists/1dfeR4HaWDbWqFHLkxsg1d?locale=en-US%2Cen%3Bq%3D0.9%2Czh-CN%3Bq%3D...",
  "id": "1dfeR4HaWDbWqFHLkxsg1d",
  "images": [
    {
      "url": "https://i.scdn.co/image/b040846ceba13c3e9c125d68389491094e7f2982",
      "height": 806,
      "width": 999
    },
    {
      "url": "https://i.scdn.co/image/af2b8e57f6d7b5d43a616bd1e27ba552cd8bfd42",
      "height": 516,
      "width": 640
    },
    {
      "url": "https://i.scdn.co/image/c06971e9ff81696699b829484e3be165f4e64368",
      "height": 161,
      "width": 200
    },
    {
      "url": "https://i.scdn.co/image/6dd0ffd270903d1884edf9058c49f58b03db893d",
      "height": 52,
      "width": 64
    }
  ],
  "name": "Queen",
  "popularity": 84,
  "type": "artist",
  "uri": "spotify:artist:1dfeR4HaWDbWqFHLkxsg1d"
}

 

When I called the endpoint with curl, the followers.totalpopularity are both float:

 

curl --request GET \
  --url https://api.spotify.com/v1/artists/1dfeR4HaWDbWqFHLkxsg1d \
  --header 'Authorization: Bearer $TOKEN'

 

 

{"external_urls":{"spotify":"https://open.spotify.com/artist/1dfeR4HaWDbWqFHLkxsg1d"},"followers":{"href":null,"total":4.9022656E7},"genres":["classic rock","glam rock","rock"],"href":"https://api.spotify.com/v1/artists/1dfeR4HaWDbWqFHLkxsg1d","id":"1dfeR4HaWDbWqFHLkxsg1d","images":[{"url":"https://i.scdn.co/image/b040846ceba13c3e9c125d68389491094e7f2982","height":806.0,"width":999.0},{"url":"https://i.scdn.co/image/af2b8e57f6d7b5d43a616bd1e27ba552cd8bfd42","height":516.0,"width":640.0},{"url":"https://i.scdn.co/image/c06971e9ff81696699b829484e3be165f4e64368","height":161.0,"width":200.0},{"url":"https://i.scdn.co/image/6dd0ffd270903d1884edf9058c49f58b03db893d","height":52.0,"width":64.0}],"name":"Queen","popularity":84.0,"type":"artist","uri":"spotify:artist:1dfeR4HaWDbWqFHLkxsg1d"}

 

Is there any modification on the Spotify server side?

Reply
10 Replies

When I run a CURL request, I get ints back, no floats.

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.

Same here but with GETARTISTS endpoint

Same problem as mine. 

@Ximzend
CURL request still gives floats instead of ints

Example response:
{"external_urls":{"spotify":"https://open.spotify.com/artist/0C8ZW7ezQVs4URX5aX7Kqx"},"followers":{"href":null,"total":4.74174E7},"genres":["pop","post-teen pop"],"href":"https://api.spotify.com/v1/artists/0C8ZW7ezQVs4URX5aX7Kqx","id":"0C8ZW7ezQVs4URX5aX7Kqx","images":[{"url":"https://i.scdn.co/image/ab6761610000e5eb0c8eb928813cd06614c0710d","height":640.0,"width":640.0},{"url":"https://i.scdn.co/image/ab676161000051740c8eb928813cd06614c0710d","height":320.0,"width":320.0},{"url":"https://i.scdn.co/image/ab6761610000f1780c8eb928813cd06614c0710d","height":160.0,"width":160.0}],"name":"Selena Gomez","popularity":82.0,"type":"artist","uri":"spotify:artist:0C8ZW7ezQVs4URX5aX7Kqx"}

Link to my question about this issue: https://community.spotify.com/t5/Spotify-for-Developers/Get-Artist-reference-bug-receiving-Float-ins...

I'm also facing this issue. My app hasn't been updated in more than 2 months and suddenly stopped working last week because of the code expecting an integer and receiving a float number instead when calling the 

Get Several Artists API call.

Documentation still says integer and other calls still return integers so it seems like there is a bug on the API. 

Also getting this issue. Has anyone figured out a workaround? It's breaking my Json reader.

changing the int type to float for the time being

It makes no sense to convert `follower.total` and `popularity` from int to float, in which case means there is a fraction of follower, like 0.22 follower.

 

Furthermore, it also no reasonable to silently swallow this kind of server exception.

It also appears that this might not be a float per say but scientific notation.  It's likely that there's a digit limit and once it passes that it's returning scientific notation.  Regardless this should be addressed since the documentation indicates that this should be an int.

FYI, I've sent a message to escalate this issue to the Spotify team via this link: https://support.spotify.com/ca-en/contact-spotify-support/, here is the response from their associate:

I already forward this issue to the team backst age. Also, the tech folks backstage confirm that they're already ahead of this and currently working for a fix. No need to worry now 🙂

Also, our Tech folks are known for their hard work so this will be fixed in no time! Consider this issue resolved.

It's not resolved: https://community.spotify.com/t5/Spotify-for-Developers/duration-ms-suddenly-returning-float-instead...

 

Please try again. And how on earth do you break your API and not realise, in 2024?!?

Suggested posts