A bit ago, at about 2019-11-13 15:09 UTC, the SE API started randomly responding with site is required
errors.
I've see it in the following situations:
There are lots of these reported by SmokeDetector, which reports such errors into Charcoal HQ.
Note: I've added code to SmokeDetector such that SD won't report these errors into the chat rooms (having so many error reports was disruptive). Not reporting into the chat rooms doesn't mean the errors aren't still happening. The plan is to revert that change once the error in the SE API is resolved. If helpful for testing the API, we can revert the change and start posting the reports again.
I've seen this as a response when making a request on the SE API page, which showed a response of:
{ "error_id": 400, "error_message": "site is required", "error_name": "bad_parameter" }
The URL which produced that should respond with:
{ "items":[], "has_more":false, "quota_max":300, "quota_remaining":296 }
It does respond with that, most of the time, but will infrequently respond with the "site is required" error.
When attempting to make the above call from the SE API Documentation page, the response I received was:
I've also seen this at least once in a userscript within the last 30 minutes.
This error is quite intermittent. Most requests complete correctly. We're seeing it a lot on SmokeDetector, because SmokeDetector makes a lot of requests. If you're going to test this, you'll probably need to make the request a few/several/many times prior to seeing this, but if things were working properly, you wouldn't see it at all.
Now getting CORS errors, which are more widespread
The SE API is now giving CORS errors in many circumstances.
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://api.stackexchange.com/2.2/posts/58842606?site=stackoverflow&_=1573665872964. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).
The above URL won't give a CORS error from this page. To duplicate, try the following from the JavaScript console on a page on SO Chat.:
$.get("https://api.stackexchange.com/2.2/posts/58842606?site=stackoverflow")