Skip to content
TORNLIFE More

API Ratelimit

Started by Helcostr [1934501] Wiki Editor on in API Development.

0 replies · 102 views · thread synced · 4 days ago · View on torn.com
About this thread

Posts archived: 1 / 1 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
1
Discussion span
→
People posting
1
Likes on archived posts
1
Authority score
67 / 100
Historical score
27 / 100
Story score
21 / 100
Engagement score
35 / 100
Helcostr [1934501] Wiki Editor
If we ever get torn API ratelimit, this can be translated. Until then, showing off GAS + Discord Webhook.

function myFunction() {
let webhook = "WEBHOOK URL GOES HERE";
let payload = {
'method' : 'post',
'muteHttpExceptions':true
};
let requests = "1,2,3,4,5,6,7,8,9,10".split(",").map(e=>{return {...payload,...{'payload':{'content':e}}}});
requests.forEach(function(payload){
let code;
do {
let response = UrlFetchApp.fetch(webhook,payload);
let headers = response.getAllHeaders();
code = response.getResponseCode();
let time = parseInt(headers['x-ratelimit-reset'])*1000 - Date.now();
let multiply = (parseInt(headers['x-ratelimit-limit']) - parseInt(headers['x-ratelimit-remaining']))/parseInt(headers['x-ratelimit-limit']);
console.log(time * multiply);
Utilities.sleep(time * multiply);
} while (code == 429);
});
}