Unable to iterate over (actual) results in Spotify API search

The number of returned results in Spotify API varies with different values of offset and limit. For instance:

https://api.spotify.com/v1/search?query=madonna&offset=0&limit=50&type=playlist

playlists.total= 164

https://api.spotify.com/v1/search?query=madonna&offset=0&limit=20&type=playlist

playlists.total= 177

https://api.spotify.com/v1/search?query=madonna&offset=10&limit=50&type=playlist

playlists.total= 156

https://api.spotify.com/v1/search query=madonna&offset=100&limit=50&type=playlist

playlists.total= 163

The real problem is that some items are missing when iterating over the results. This can be easily reproduced as follows:

  • Make the following request:

    https://api.spotify.com/v1/search?query=redhouse&offset=0&limit=20&type=album

    The response returns albums.total=27 and 20 items.

  • Make another request to get the next page:

    https://api.spotify.com/v1/search?query=redhouse&offset=20&limit=20&type=album

    The response returns albums.total=21 and 1 item. (6 missing items!)

  • Make the same request with offset=0 and limit=30

    https://api.spotify.com/v1/search?query=redhouse&offset=0&limit=30&type=album

    The response returns albums.total=27 and 27 items, which is correct.

  • This happens in all searches for albums, artist, tracks and playlists. A few people (including myself) reported it as a (critical) bug in the Spotify issue tracking system.

    I just wonder if there is any reliable way of iterating over the results of a search.

    链接地址: http://www.djcxy.com/p/55576.html

    上一篇: Spotify API:使用jQuery / ajax检索歌曲/艺术​​家/专辑信息

    下一篇: 无法遍历Spotify API搜索中的(实际)结果