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

v1/search API 'offset' parameter issue

v1/search API 'offset' parameter issue

Hi,

 

When requesting search results with an 'offset' parameter of more than 99 the response json contains an empy item array, even when the total number of results is more than 100. For example, I get the following response with an 'offset' parameter of 100. However, the total number of expected results is 848 so in this case I would expect an full array of 50 items due to the 'limit' parameter being set to 50.


curl --request GET \
--url 'https://api.spotify.com/v1/search?q=label%3AKompakt&type=album&limit=50&offset=100'

 

 

{
   "albums":{
      "href":"https://api.spotify.com/v1/search?query=label%3AKompakt&type=album&locale=en-GB%2Cen%3Bq%3D0.5&offset=100&limit=50",
      "limit":50,
      "next":"https://api.spotify.com/v1/search?query=label%3AKompakt&type=album&locale=en-GB%2Cen%3Bq%3D0.5&offset=150&limit=50",
      "offset":100,
      "previous":"https://api.spotify.com/v1/search?query=label%3AKompakt&type=album&locale=en-GB%2Cen%3Bq%3D0.5&offset=50&limit=50",
      "total":848,
      "items":[
         
      ]
   }
}

 

 

With 'offset' of 99, only 1 item is returned...

 

 

{
   "albums":{
      "href":"https://api.spotify.com/v1/search?query=label%3AKompakt&type=album&locale=en-GB%2Cen%3Bq%3D0.5&offset=99&limit=50",
      "limit":50,
      "next":"https://api.spotify.com/v1/search?query=label%3AKompakt&type=album&locale=en-GB%2Cen%3Bq%3D0.5&offset=149&limit=50",
      "offset":99,
      "previous":"https://api.spotify.com/v1/search?query=label%3AKompakt&type=album&locale=en-GB%2Cen%3Bq%3D0.5&offset=49&limit=50",
      "total":848,
      "items":[
         {
            "album_type":"single",
            "total_tracks":2,
            "available_markets":[
            ],
            "external_urls":{
               "spotify":"https://open.spotify.com/album/00aoFgHb7qw8PMkYxQZw9W"
            },
            "href":"https://api.spotify.com/v1/albums/00aoFgHb7qw8PMkYxQZw9W",
            "id":"00aoFgHb7qw8PMkYxQZw9W",
            "images":[
               {
                  "url":"https://i.scdn.co/image/ab67616d0000b27349f793dd743b337a1e8fa7ac",
                  "height":640,
                  "width":640
               },
               {
                  "url":"https://i.scdn.co/image/ab67616d00001e0249f793dd743b337a1e8fa7ac",
                  "height":300,
                  "width":300
               },
               {
                  "url":"https://i.scdn.co/image/ab67616d0000485149f793dd743b337a1e8fa7ac",
                  "height":64,
                  "width":64
               }
            ],
            "name":"Walls vs. Gerd Janson & Prins Thomas",
            "release_date":"2012-09-03",
            "release_date_precision":"day",
            "type":"album",
            "uri":"spotify:album:00aoFgHb7qw8PMkYxQZw9W",
            "artists":[
               {
                  "external_urls":{
                     "spotify":"https://open.spotify.com/artist/4zLjvhhQ5WLRFCKPPgx8q6"
                  },
                  "href":"https://api.spotify.com/v1/artists/4zLjvhhQ5WLRFCKPPgx8q6",
                  "id":"4zLjvhhQ5WLRFCKPPgx8q6",
                  "name":"Walls",
                  "type":"artist",
                  "uri":"spotify:artist:4zLjvhhQ5WLRFCKPPgx8q6"
               }
            ]
         }
      ]
   }
}

 


Please note I am not attempting to retrive more than 100 results with one request. I am limiting the result items to 50 and adjusting the 'offset' parameter to retrive the full result set of 848 over multiple queries. Using the url specified in the 'next' property in the json response also yeilds no results.

 

As far as I can tell the behaviour has changed over the last week or two. It was previously possible to get the the full result set of 848 items using the 'next' url.

 

Please could you confirm if this is expected behaviour or a newly introduced issue?

 

Thanks in advance for your help.

Reply
2 Replies

On further investigation results are not consistently empty when setting the 'offset' parameter to more than 100. For example the cut off point for this search currently appears to be 133.

Request

 

curl 
--request GET \
--url 'https://api.spotify.com/v1/search?q=Miles+Davis&type=album&offset=133'

 

 

Response

 

{
   "albums":{
      "href":"https://api.spotify.com/v1/search?query=Miles+Davis&type=album&locale=en-GB%2Cen%3Bq%3D0.5&offset=133&limit=20",
      "limit":20,
      "next":"https://api.spotify.com/v1/search?query=Miles+Davis&type=album&locale=en-GB%2Cen%3Bq%3D0.5&offset=153&limit=20",
      "offset":133,
      "previous":"https://api.spotify.com/v1/search?query=Miles+Davis&type=album&locale=en-GB%2Cen%3Bq%3D0.5&offset=113&limit=20",
      "total":1000,
      "items":[
         
      ]
   }
}

 

 

The items array is empty even though the total number of expected results is 1000. Lowering 'offset' returns populated items.

Can anyone replicate this behaviour?

I've seen the same behaviour. For me, the offset number is 99. Anything above that returns and empty items array. 

Would love to know why this is happening all of a sudden.

 

UPDATE:
Weird. Moments after I posted the issue resolved itself. Offset is behaving as expected as of Sep 12 12:15pm AST

Suggested posts