0

I used the Stack Exchange API and received this error:

[1] "{\"error_id\":502,\"error_message\":\"too many requests from this app/user pair, more requests available in 20189 seconds\",\"error_name\":\"throttle_violation\"}"

I follow the instruction here (https://api.stackexchange.com/docs/throttle), where they "consider > 30 request/sec per IP address to be very abusive and thus cut the requests off very harshly". Therefore, I only send one request every 1 second, and still receive the 502 error, not always but sometimes. What should be the optimal request frequency?

15
  • 1
    Perhaps you are making the same request and that is the reason for the 502?
    – user707129
    Jun 10, 2020 at 19:55
  • Google search for HTML 502 says "A 502 Bad Gateway indicates that the edge server (server acting as a proxy) was not able to get a valid or any response from the origin server (also called upstream server). ... If one of KeyCDN's edge servers receive a 502 Bad Gateway response from your origin server, KeyCDN will return a 500 Origin Not Reachable page." Jun 10, 2020 at 19:56
  • @Daniil It's the same type of request but with different id's. I've used the max results per request. Is there a better alternative?
    – BellmanEqn
    Jun 10, 2020 at 19:59
  • 1
    Perhaps you've reached your 300 requests per day quota? Go to the request URL in your browser and check quota_remaining at the bottom
    – user707129
    Jun 10, 2020 at 19:59
  • @mindstormsboi that I was not able to get a valid response is the problem, but how do I avoid it?
    – BellmanEqn
    Jun 10, 2020 at 20:00
  • @Daniil No, I was under the quota limit.
    – BellmanEqn
    Jun 10, 2020 at 20:00
  • 1
    You have to have hit your daily quota. That error message is indicating that you wait for 5+ hours, which is about when the daily reset occurs.
    – Spevacus
    Jun 10, 2020 at 20:02
  • 2
    @BellmanEqn I've had this issue before, this can be worked around by registering your app on Stack Apps and using a key
    – user707129
    Jun 10, 2020 at 20:02
  • @Daniil that's what I did. I ran into that 502 with my key...
    – BellmanEqn
    Jun 10, 2020 at 20:03
  • Try without your key? What requests are you making and what is your quota?
    – user707129
    Jun 10, 2020 at 20:04
  • @Spevacus I did not hit my daily quota, and that error goes away after about 1 minute in one occasion that I looked into
    – BellmanEqn
    Jun 10, 2020 at 20:04
  • @Daniil I was requesting data from /users/{ids}, I have 10,000 daily. Without my key I only have 300, which is not enough...
    – BellmanEqn
    Jun 10, 2020 at 20:06
  • 1
    You do check if a backoff is set in the response, right? And then wait for at least that amount of seconds? backoffs can be send to request you to not post any calls for up to 10 seconds.
    – rene
    Jun 10, 2020 at 20:09
  • @rene Sorry, I'm not familiar with backoff, is that supposed to be in the response. I did not receive anything that says backoff...
    – BellmanEqn
    Jun 10, 2020 at 20:11
  • 1
    @rene OK, I'll look into the wrapper later... ran out of my daily limit...
    – BellmanEqn
    Jun 10, 2020 at 20:14

0

Browse other questions tagged .