This is not possible via the API. You can use two other "tricks", though (both must be done server-side because the sites return CORS headers):
Scrape the /leagues
page. Call the endpoint:
GET /leagues/1/<type>/<site>/<YYYY-MM-DD>/<userId>
(e.g. /leagues/1/quarter/stackoverflow/2021-01-01/10607772
), look for the .highlight .number
selector and get the inner text. If you want just the number, remember to remove #
in the front of the result.
However, the probem is that all league URLs exist in robots.txt
, so if you make too many requests, you might be rate-limited.
Fetch the information from Data Explorer. Call:
POST /query/run/<siteId>/<queryId>/97298
(for the query you've linked, the site id is 1
and the query id 6772
).
If running
exists in the returned JSON and is true
, then using job_id
call:
POST /query/job/<job_id>
every 1500 milliseconds (that's what Stack Exchange uses) until resultSets
is present in the response.
If not, then look directly for resultSets
.
Here's a sample value of that property:
[
{
"columns": [
{
"name": "Id",
"type": "Number"
},
{
"name": "Ranking",
"type": "Number"
},
{
"name": "Percentile",
"type": "Number"
}
],
"rows": [
[
10607772,
65137,
0.0586909706892046
]
],
"messagePosition": 0,
"truncated": false
}
]
Note that the results are only updated every Sunday. You might get rate-limited as well if you make too many requests in a short time period.