I am working on one application that produces timeline of user on every site of Stack Exchange. We have some users on SharePoint.SE.
Since I want list of all the sites, I am trying to get it using API 2.2
GET /2.2/sites/
As shown here. But it is getting only partial sites. The response is missing sites like Beer.SE, SharePoint.SE.
How do I retrieve them too?
You need to pass additional parameters. Beer.SE
appears on page
3 with a pagesize
of 100:
https://api.stackexchange.com/docs/sites#page=3&pagesize=100&filter=default&run=true
With no parameters, the default pagesize
is 30 results. You can tell if there are more items than what is returned in your call by checking the has_more
parameter in the common wrapper.
In this instance, with a pagesize of 3, there are 3 total pages and Beer.SE happens to be on the last page.
After rereading the sites documentation, it says
The pagesize parameter for this method is unbounded, in acknowledgement that for many applications repeatedly fetching from /sites would complicate start-up tasks needlessly.
This means that you can set your page size to something like 1000, and Beer.SE will appear in that results. At this point, there are not 1,000 Stack Exchange sites, so that will work.