Goal
Use the SE API in order to get the lists of the badges for every website in the network. The /badges
endpoint provide this data.
Expected result
According to the paging documentation, we can request up to 100 items:
pagesize
can be any value between 0 and 100 and defaults to 30
Source: https://api.stackexchange.com/docs/paging:
So the API should allow us to request up to 100 badges, in order to reduce the number of requests.
In fact, it worked for 11 years (according to my git
history) with 100 items per page , before it broke in late August 2024.
Actual result
(see the last update below)
No pagesize
Example:
https://api.stackexchange.com/docs/badges#order=desc&sort=rank&filter=default&site=eosio&run=true
Output:
With 43 <= pagesize
<= 100
Example:
For some reason, the API returns an error when pagesize
is equal or greater than 43.
Output:
Output as text:
{
"error_id": 404,
"error_message": "no method found with this name",
"error_name": "no_method"
}
So pagesize
must be removed from the request, and we have to perform more calls to retrieve all the tags.
Update after tests from Makyen
Actually the error doesn't come from pagesize
, since we can request the page
2
with pagesize = 95
:
Cause of the error
The root issue is a problem with the Guide badge, as shown in this answer from Jeremy.
Minor update after more tests in /badges/{ids}
(2024-10-10)
On serverfault
We can see the badge with 542
for serverfault
here (name
has been removed to avoid the error):
And we can see its name Guide
here on /badges/{ids}
:
So this tag has a name indeed, but this tag crashes /badges
.
We can see a link in the response, but it returns a 404 page: https://serverfault.com/help/badges/542/guide
On Stack Overflow
About this badge: https://stackoverflow.com/badges/12166/
We can look at it by its id: https://api.stackexchange.com/docs/badges-by-ids#order=desc&sort=rank&ids=12166&filter=!-*xW3Xj7tCc7&site=stackoverflow&run=true
If we add name
to the filters, it crashes.
It also lack a description.
So it's very likely that the badges about the Staging Ground feature broke several API endpoints related to badges.
pagesize
> 42 (example:page=2
withpagesize=95
).page=1&pagesize=94
andpage=2&pagesize=94
.page=2&pagesize=100
also fails, butpage=1&pagesize=100
doesn't.page=2 with pagesize=95
. The difference is that this link is usingorder=desc
, which matches your examples. I had switched toorder=asc
for additional testing and copied the wrong URL.no method found with this name
error is definitely returned on correctly formatted, valid requests when the server encounters an internal error. I don't know if it's returned all the time in such cases, but it's definitely returned as such on at least some types of internal server errors, which should be 500. We've seen such errors in response to requests from SmokeDetector over multiple years (examples: 1, 2)pagesize
.