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

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.

Related

CoinGecko get all pages at once with one call

I'm looking that the follow endpoint is paginated
https://api.coingecko.com/api/v3/coins/bitcoin/tickers?page=1
Each page has 100 results but in my app, I need all results at once, since this is a free API , I researched and there are 65 pages available, which will exceed on the quota since I only have 10 - 50 request per minute and here I'm doing 65 requests , is there a way or format that I can access for example to get all pages results as one call ?
I tried with
https://api.coingecko.com/api/v3/coins/bitcoin/tickers?page=1,2,3,4,5
but it is always returning 100 elements despiting that the order is different

Retrieve all of a user's playlist from SoundCloud limited to 50?

I'm trying to retrieve all the playlists from my account via
http://api.soundcloud.com/users/145295911/playlists?client_id=xxxxxx, as the API reference shows.
However, I can only retrieve recent 50 playlists instead of all of my playlists. I've been looking for this but it seems like no one has had this issue before. Is there a way to get all of them?
Check out the section of their API on pagination.
Most results from our API are returned as a collection. The number of items in the collection returned is limited to 50 by default with a maximum value of 200. Most endpoints support a linked_partitioning parameter that will allow you to page through collections. When this parameter is passed, the response will contain a next_href property if there are additional results. To fetch the next page of results, simply follow that URI. If the response does not contain a next_href property, you have reached the end of the results.

Facebook Graph API search limit & offset

I want to do a query like this:
search?q=KEY_NAME&type=page&fields=id,name,location&limit=500&offset=0
when I do this the first time the result is about 470 results, now I put offset to 471 and repeat the query
search?q=KEY_NAME&type=page&fields=id,name,location&limit=500&offset=471
and the result is empty.
Why? The key_name is a famous word like "fan" and I don't think that there are only 471 results on fb pages!
What is the problem?
Never use a limit that high, afaik a limit of 100 should be the maximum. Everything else may be buggy. If you use this API call, you get more than 500 with paging:
/search?pretty=0&fields=idmname,location&q=fan&type=page&limit=100
Don´t use "offset", always use the "next" link in the JSON document to get the next batch of results: https://developers.facebook.com/docs/graph-api/using-graph-api/v2.4#paging
The next 100 entries would be available with the following endpoint for me:
/search?pretty=0&fields=idmname,location&q=fan&type=page&limit=100&after=OTkZD
Please refer to this following blog post in which it says
https://developers.facebook.com/blog/post/478/
gist of it.
As such, when querying the following tables and connections, use time-based paging instead of “offset” to ensure you are getting back as many results as possible with each call. For these Graph API connections, use the “since” and “until” parameters

Facebook Request(s): what counts as 1 request?

I am currently creating an application that polls facebook for data. First request a page in this fashion...
pageID/posts?fields=id,message,created_time,type&limit=250
This returns the top 250 posts from a page. I then check if there page next is set and if it is make another request for the next 250 posts. I continue this recursively until there are no more posts.
With each post that is returned I go out and fetch the post details from the graph api as well.
My question is if I had 500 posts on a page. Would that equate to 502 requests? (500 requests for each post + 2 for parsing through page data to get posts) or am I incorrect in my understanding of a "request". I know when batching calls each query included in the batch actually counts as 1 request. The goal is to avoid the 600 calls / 600 second rate limiting. Thanks!
Every API call is...well, 1 request. So every time you use the /posts endpoint with whatever limit, it will be 1 request. For example, if you do that call you posted, it will be one request that returns 250 elements.
Batch requests are just faster, but each call in the batch counts as a request. So if you combine 10 calls in a batch, it will be 10 requests. The benefit of batch calls is really just that they are a lot faster: as fast as the slowest call in the batch.
If you want to get 500 posts with that example of yours, you would only need 2 calls. First one with 250 returned elements, second one by using the API call defined in the "next" value to get another 250. Just keep in mind that the default is usually 25 elements, and you can´t use any limit you want. There is a max limit for calls and it gets changed from time to time afaik so don´t count on getting the same result every time.
Btw, don't be to fixated on that 600calls/600seconds limit, it's just a general limit. The real limit is dynamic and depends on many factors. It's not public, of course. But if you really hit the limit, you are doing something wrong anyway.

Beats Music, Why does this playlist's tracks fetch returns invalid results?

I'm trying to fetch tracks for a specific playlist (pl128943612061942272) and it gives me strange results.
https://partner.api.beatsmusic.com/v1/api/playlists/pl128943612061942272/tracks?access_token=
The response has a total count of 15 but returns only 13 tracks.
Besides, if i try to get the 2nd track ( offset 1 and limit 1 ) by the following request, the response is empty.
https://partner.api.beatsmusic.com/v1/api/playlists/pl128943612061942272/tracks?access_token=&offset=1&limit=1
This is happening because two of the tracks are no longer available. Songs sometimes become unavailable. This is often temporary.