Skip to content
TORNLIFE More

API call limit

Started by Borderline [2894696] on in API Development.

24 replies · 932 views · thread synced · 4 days ago · View on torn.com
About this thread

Posts archived: 25 / 25 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
25
Discussion span
→
Authority score
74 / 100
Historical score
28 / 100
Story score
38 / 100
Engagement score
67 / 100

People posting, likes and official posts are not counted for this thread yet: on threads longer than one page they come from a periodic pass over the archive, which has not covered it.

Most-liked replies

Borderline [2894696]
Hi,

I'm currently developing a tool within Google Sheets that would help my faction in Ranked wars. However, it does do a lot of API calls. It continuously makes 2 different calls towards the API with 2 different API keys.

The Wiki states:
Each user key can make up to 100 individual requests per minute, this should be more than enough for almost anything to be achievable.

Now I'm wondering... is this 100 a hard cap or a guideline? I'm just asking because I would like to know if I need to build in some kind of timeout into my tool to prevent it from hit that limit. As of right now, if I run my script, it would potentially hit 120 calls per key per minute.
Omanpx [1906686]
First of all, make sure you need that many calls. Keep in mind the 30 sec cache and think of ways to reduce call counts. Like calling the enemy faction to get basic info on roster rather than individual members. Second, the 100/min is a hard cap. There are also Google limits, which you would hit with this kind of usage (20k calls/day per google account).
Borderline [2894696]
Thanks guys. This is what I needed to know!

Is there a way to bypass the amount of calls that I need to make, like combining calls together or something? Like… when I want data of multiple factions, can I do that in one call? Because I’m currently doing 1 call for each faction and I wouldn’t know how to combine it if were possible. I just can’t find any information about stuff like that.
Omanpx [1906686]
One faction per call. But you might be able to reduce the number of calls based on what info you want. If you want something like a hosped / ok tracker, 2 calls is all you need to get the info for both factions. Same goes for activity tracking, you can do it with the same faction calls if you are smart about it ;)
Omanpx [1906686]
Like i said, it heavily depends on what you are trying to do. If you want to get the status of hosped / ok members, all you need is one call to a faction's faction/basic API endpoint and iterate through members to get their status. If you want to make an activity tracker like the one in the picture, it's also 1 api call to faction/basic with some clever logic behind it (not revealing trade secrets any more than i have already :P ). If you use TornStats API instead of Torn API, you can also add spy data to your result - i've set up a hosp tracker with stats for our wars as a discord bot that makes 4 calls / minute and works wonders during wars.

[image: cdn.discordapp.com]
Borderline [2894696]
Yeah, okay. You haven't really revealed any secrets. You more like confirmed my thoughts on your script. Don't get me wrong though. I'm not trying to replicate it...

You also did make me think slightly different on my approach. Enough in such extend that I think I know what I should be doing. Cheers!
Aezur [1950769]
I might have picked this up wrong - still on my first coffee - but I don't understand why you would need to hit the API twice a second if there is a 30s cache. Are you not just getting the same values back, and only getting new values every 30s?

You could just make that call every 2s or do it every 1s for alternating factions and half the amount of calls. If you're already hitting the max, you have zero headroom for additional features or unforeseen challenges.
byrod [1132772]
It's also important to remember that the 100 call limit is per user, and not per key.

If you are creating a script which makes 100 calls per minute with a key of yours, there is no space for you using TornStats, TornTools, torn.report or whatever neat tools are around.

And yes, the limit is hard. If you surpass this, you'll get an error code:
5 => Too many requests : Requests are blocked for a small period of time because of too many requests per user (max 100 per minute).
Borderline [2894696]
There’s a few type of calls that actually don’t get cached.

I would love to elaborate on why I’m doing that many calls, but that’s gonna be a long story, haha.
Stig [2648238]
Source?

I've asked bogie this exact question and im nearly certain he said it wasn't against the rules.

I would understand why it would be against the rules tho
DeKleineKobini [2114440] Committee Committee
I've asked IBF this exact question and he said it was.

DeKleineKobini: Hi, I have a question regarding the API cache. Are we allowed to use 30 keys to get an update every second or not?
IceBlueFire: No
IceBlueFire: That's circumventing the whole purpose of the cache
Stig [2648238]
Would be nice if we could get a definitive answer from a staff member about it to prevent this kind of confusion.
Ata [2507441]
Do not circumvent the cache. Period. How many more written confirmations do you need?

If you can't trust DKK nor IBF, who are practically staff in my eyes, then you'll even doubt Cheds reply.
Stig [2648238]
Lol, okay big man, calm down, you're not even involved in this conversation.

Only reason I ask for a definitive answer is because we've had conflicting answers from Bogie (The Community Manager) and IceBlueFire, an officer.

I'd assume IBF knows more about the matter as hes the scripts guy and is correct so ill just take it as truth.

I dont really know who you are, or what your problem is, but hell you have some attitude lol.

If you have a problem with me, DM me
Omanpx [1906686]
I'd say IBF is the authority on this. Every time i ask bogie anything regarding script rules etc. he directs me to IBF, saying he is the API rule guy.
DeKleineKobini [2114440] Committee Committee
I'm not staff and what I do say is not rule. I do try to keep up with stuff surrounding scripts and the API, but as this situation proves, even staff doesn't know ....
While IBF's word does count, the problem is bogie outranks him so that makes it though to know whether it is allowed or not. Personally I'd always follow IBF, but I obviously can't tell someone else to do so if bogie told them that it is allowed.

I've requested bogie for a definitive answer on here because of the conflicting answers we've gotten before.
_SCOFIELD_ [1441750]
I was under the belief that the 30 second cache was applied on the IP requesting the API call so if one user used separate keys to get a data, the data returned would be the same to both keys (cached for 30 seconds).

Seems this is not case, is it?
Nexus [105937]
All Ill say is, this is why we can't have nice things...

4 calls per second...?

Brother Borderline, you need to optimize your script better.

Even without caches and limits, this is wild, lol.