Skip to content
TORNLIFE More

Too many requests.. Question?

Started by LouBaker [1162207] on in API Development.

10 replies · 207 views · thread synced · 7 days ago · View on torn.com
About this thread

Posts archived: 11 / 11 posts (100%) · the total is Torn's reply count + the opening post at the last fetch

Counted by TornLife from the archived posts.

Archived posts
11
Discussion span
→
People posting
6
Likes on archived posts
17
Posts by staff, officers and moderators
3
Authority score
72 / 100
Historical score
24 / 100
Story score
35 / 100
Engagement score
58 / 100

Most-liked replies

LouBaker [1162207]

When my APi hits the big 100

Too many requests
The current private key is banned for a small period of time because of too many requests (max 100 per minute)

Do I have my program stop for 5 minutes (hang in a timed loop, this isn't a good idea)

or

Keep then program running calling the API's until the Too many requests error has gone

I'm not sure what I should do, are we allowed to keep calling the API after the key is banned



Just a Note, I am handling API call rate, this only happens when I run a second API program

we really need an API call counter in the API's so this wouldn't happen

we are all running more API Scripts and Programs there is no way of knowing the call count

Adding a call count in USER BARS might help, if it can be done

{

"server_time": 1521759204,

"callrate": 5,

"happy": { "current": 4396,

"maximum": 4500,

"increment": 5,

"interval": 900,

"ticktime": 396,

"fulltime": 18396

},
Bug [1455582] Committee Committee

You should hold of making calls in the event of temporary ban. My usual strategy is each time it fails, I double the time till I check again. If I check once per minute, then on each failure it would be 2 minutes, 4 minutes, 8 minutes then 16 minutes. Then when it connects successfully reset to every 1 minute. But you could find your own solution if you just want to hold off for 5 minutes when it fails, just don't keep pinging the server if you know its going to block you.
LouBaker [1162207]

ha ha ha ha, I fell over laughing

1 cal a minute, what world do you live in, do you even use APIs DocTorn default is 12 calls a minute

and do you think you can do anything with 1 call

stop patronizing me and Bug OFF
Bug [1455582] Committee Committee

Wow dude.. I was simplifying the numbers down for clarity of the example... I'm sorry i tried to help, solve your own problems next time.
LouBaker [1162207]

I am doing pretty well at controlling my API Calls under 100

[image: i62.servimg.com]

This 5hr Graft highest hit is 28, considering all the stuff I'm doing in this app it is fanatically low



But I'm am still having problems that can be avoided when testing other API's apps while this one is running

If only we knew what our call rate was.



and an apology:

I'm sorry Bug, for being so harsh

but really I do know what I'm doing and call counting is one them


Mauk [1494436]

I've already asked for a rate limit header in the past but was mostly ignored...

This is pretty standard on APIs nowadays:

https://developer.github.com/v3/rate_limit/
https://discordapp.com/developers/docs/topics/rate-limits
https://developer.twitter.com/en/docs/basics/rate-limiting
https://developer.vimeo.com/guidelines/rate-limiting
https://auth0.com/docs/policies/rate-limits


While one can (and should) control their own API usage, you never know what other apps the user has running and if you should stop to prevent going over the limit. Trust no one!
LouBaker [1162207]

I have found a simple solution for API request calls, over many different API applications running at the same time

The idea is that calls are saved to one central place for all API's to read and update

the API request count is saved on the PC with

SetSetting($section,$key,$value) and retrieved with GetSetting($section,$key)

a second Setting for Calls per minute,

SetSetting($section,$time,$value) and GetSetting($section,$time)

if the time has been over 1 minute since it last read (by any application) then set it to zero and save the new Time

.

this makes it possible for any number of API's running to
  • Read the request count
  • Read the Time last reset
  • Reset the Count, if 1 minute has passed
  • Test call_limit(100) has been reached
  • Increase and Save New Call Count
this works for me,

.

maybe all API applications can do this, by having one Set location for Calls and Time

a Global Standard Setting would have to be used by all APP's using the same data

examples:

SetSetting("TornAPI","CallCount","0")

SetSetting("TornAPI,"ResetTime",$Unix($date))

GetSetting("TornAPI","CallCount")

GetSetting("TornAPI,"ResetTime")

someone could probably think of better names, but its out there

.

no one will fail with too many calls again.


Bug [1455582] Committee Committee

The issue being not all apps using the API run on the local machine, neat idea though.
Jox [1714547]

Here some tip.... maybe you find it interesting.... You cant control shared usage of API key with other applications, but for most of them you can know how much call they use, for example if you set DocTorn to refresh every 5s it will spend 12 calls per minute, so you have 88 more for your app.

Thing that you can do is same as what game developers use to limit FPS of game, but you instead of limiting Frame Per Second you will limit API Per Minute. At the end you just need to set up how many API call you wonna you app to use, at this example I would say 80, to leave 8 call for backup, to use them for some manual calls when i wonna check something while flying that's not on app.