Backoff (i.e. slow down) hitting the Stackexchange API

February 6, 2022 ยท View on GitHub

Here's what the JSON looks like when the stackexchange api tells you to backoff (i.e. to make less requests)...

{
  "items": [
    {
 ...
    }
  ],
  "backoff": 10
}

Here's how I back off...

if (jsonBody.IndexOf("backoff") >= 0)
{
    if (data.backoff != null)
    {
        int delay = (int)data.backoff.Value;
        System.Threading.Thread.Sleep(delay * 1000);
    }
}