7

Note: I initially posted this on SO Meta some time ago but got no answer, so as suggested over there I'm cross-posting it here, hoping it catches a dev's attention.

I get a random bug when retrieving questions from the Stack Overflow API. It happens under conditions like this:

  • I request the page 7 from the API (with 100 records per page).
  • The API responds with the 100 records and a total property of 2723 records. Which means there are a total of 27 pages, i.e. there are still 20 pages after the current record set.
  • However the has_more property of the response is set to false.

So this is not consistent - on one hand the API reports that there are more records (indirectly, via the total property), and on the other hand it reports that there are not, via the has_more property.

For information, this was for this particular query:

https://api.stackexchange.com/2.2/questions?filter=%21-%2Af%286rkvD-tO&tagged=php&fromdate=1257095423&todate=1259687423&page=7&pagesize=100&key=BmopG%29d9Thccirg4e%29CjOw%28%28&site=stackoverflow

I got this in my log:

2017-04-16 17:18:10: https://api.stackexchange.com/2.2/questions?filter=%21-%2Af%286rkvD-tO&tagged=php&fromdate=1257095423&todate=1259687423&page=7&pagesize=100&key=BmopG%29d9Thccirg4e%29CjOw%28%28&site=stackoverflow

2017-04-16 17:18:10: Got 2009-11-01 to 2009-12-01, page 7. Total items: 2723

And this is the response from the API:

{
     "items":[...],
     "has_more":false,
     "quota_max":10000,
     "quota_remaining":9805,
     "total":2723
}

It seems to be a bug, but maybe I'm missing something. Any idea?

Also I've just tested, if I request page 8 it returns, as expected, more records with an "has_more" property set to true, so this one is fine. Basically: page 6 is fine, page 7 is buggy, page 8 is fine.

Here is the request:

https://api.stackexchange.com/2.2/questions?filter=%21-%2Af%286rkvD-tO&tagged=php&fromdate=1257095423&todate=1259687423&page=8&pagesize=100&key=BmopG%29d9Thccirg4e%29CjOw%28%28&site=stackoverflow

And the response:

{
    "items": [...],
    "has_more": true,
    "quota_max": 10000,
    "quota_remaining": 9997,
    "total": 2723
}

You must log in to answer this question.

Browse other questions tagged .