-
-
Save moowiz/ef6ff870f4d37b221962e51ae0748faf to your computer and use it in GitHub Desktop.
Bug report for League Account rate limiting
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Execute this with `python3 bug_report.py path/to/tokens.json` | |
import json | |
import sys | |
import requests | |
def print_headers(headers, prefix="| "): | |
headers_to_print = {} | |
for header, value in headers.items(): | |
if header.startswith("X-Rate-Limit") or header == "Retry-After": | |
headers_to_print[header] = value | |
print("{0}Headers:".format(prefix)) | |
for header, value in headers_to_print.items(): | |
print("{0} {1}: {2}".format(prefix, header, value)) | |
def main(file_name): | |
with open(file_name) as f: | |
access_tokens = json.load(f) | |
headers = { | |
"User-Agent": "testingatlaspassivesapi", | |
} | |
print( | |
"Fetching characters and atlas passives for {0} accounts.".format( | |
len(access_tokens), | |
), | |
) | |
for i, token in enumerate(access_tokens): | |
headers["Authorization"] = "Bearer {0}".format(token) | |
print("Fetching account {0}...".format(i)) | |
response = requests.get( | |
"https://api.pathofexile.com/character", | |
headers=headers, | |
) | |
print( | |
"| Fetched characters. Account has {0} characters.".format( | |
len(response.json()["characters"]), | |
), | |
) | |
print_headers(response.headers) | |
response = requests.get( | |
"https://api.pathofexile.com/league-account/{0}".format( | |
"Archnemesis", | |
), | |
headers=headers, | |
) | |
resp_json = response.json() | |
if "error" in resp_json: | |
message = resp_json["error"]["message"] | |
else: | |
message = "Account has {0} atlas passives allocated".format( | |
len(response.json()["league_account"]["atlas_passives"]["hashes"]), | |
) | |
print("| Fetched atlas passives. " + message + ".") | |
print_headers(response.headers) | |
if __name__ == "__main__": | |
if len(sys.argv) != 2: | |
print("Usage: bug_report.py FILENAME") | |
sys.exit(1) | |
main(sys.argv[1]) | |
# Output from running this script locally. | |
# $ python3 bug_report.py tokens.json | |
# Fetching characters and atlas passives for 40 accounts. | |
# Fetching account 0... | |
# | Fetched characters. Account has 3 characters. | |
# | Headers: | |
# | X-Rate-Limit-Policy: character-list-request-limit | |
# | X-Rate-Limit-Rules: Account | |
# | X-Rate-Limit-Account: 2:10:60,5:300:300 | |
# | X-Rate-Limit-Account-State: 1:10:0,1:300:0 | |
# | Fetched atlas passives. Account has 121 atlas passives allocated. | |
# | Headers: | |
# | X-Rate-Limit-Policy: league-account-request-limit | |
# | X-Rate-Limit-Rules: Account | |
# | X-Rate-Limit-Account: 5:10:60,10:300:300 | |
# | X-Rate-Limit-Account-State: 1:10:0,1:300:0 | |
# Fetching account 1... | |
# | Fetched characters. Account has 13 characters. | |
# | Headers: | |
# | X-Rate-Limit-Policy: character-list-request-limit | |
# | X-Rate-Limit-Rules: Account | |
# | X-Rate-Limit-Account: 2:10:60,5:300:300 | |
# | X-Rate-Limit-Account-State: 1:10:0,1:300:0 | |
# | Fetched atlas passives. Account has 131 atlas passives allocated. | |
# | Headers: | |
# | X-Rate-Limit-Policy: league-account-request-limit | |
# | X-Rate-Limit-Rules: Account | |
# | X-Rate-Limit-Account: 5:10:60,10:300:300 | |
# | X-Rate-Limit-Account-State: 2:10:0,2:300:0 | |
# Fetching account 2... | |
# | Fetched characters. Account has 41 characters. | |
# | Headers: | |
# | X-Rate-Limit-Policy: character-list-request-limit | |
# | X-Rate-Limit-Rules: Account | |
# | X-Rate-Limit-Account: 2:10:60,5:300:300 | |
# | X-Rate-Limit-Account-State: 1:10:0,1:300:0 | |
# | Fetched atlas passives. Account has 132 atlas passives allocated. | |
# | Headers: | |
# | X-Rate-Limit-Policy: league-account-request-limit | |
# | X-Rate-Limit-Rules: Account | |
# | X-Rate-Limit-Account: 5:10:60,10:300:300 | |
# | X-Rate-Limit-Account-State: 3:10:0,3:300:0 | |
# Fetching account 3... | |
# | Fetched characters. Account has 22 characters. | |
# | Headers: | |
# | X-Rate-Limit-Policy: character-list-request-limit | |
# | X-Rate-Limit-Rules: Account | |
# | X-Rate-Limit-Account: 2:10:60,5:300:300 | |
# | X-Rate-Limit-Account-State: 1:10:0,1:300:0 | |
# | Fetched atlas passives. Account has 0 atlas passives allocated. | |
# | Headers: | |
# | X-Rate-Limit-Policy: league-account-request-limit | |
# | X-Rate-Limit-Rules: Account | |
# | X-Rate-Limit-Account: 5:10:60,10:300:300 | |
# | X-Rate-Limit-Account-State: 4:10:0,4:300:0 | |
# Fetching account 4... | |
# | Fetched characters. Account has 17 characters. | |
# | Headers: | |
# | X-Rate-Limit-Policy: character-list-request-limit | |
# | X-Rate-Limit-Rules: Account | |
# | X-Rate-Limit-Account: 2:10:60,5:300:300 | |
# | X-Rate-Limit-Account-State: 1:10:0,1:300:0 | |
# | Fetched atlas passives. Account has 127 atlas passives allocated. | |
# | Headers: | |
# | X-Rate-Limit-Policy: league-account-request-limit | |
# | X-Rate-Limit-Rules: Account | |
# | X-Rate-Limit-Account: 5:10:60,10:300:300 | |
# | X-Rate-Limit-Account-State: 5:10:0,5:300:0 | |
# Fetching account 5... | |
# | Fetched characters. Account has 9 characters. | |
# | Headers: | |
# | X-Rate-Limit-Policy: character-list-request-limit | |
# | X-Rate-Limit-Rules: Account | |
# | X-Rate-Limit-Account: 2:10:60,5:300:300 | |
# | X-Rate-Limit-Account-State: 1:10:0,1:300:0 | |
# | Fetched atlas passives. Rate limit exceeded. | |
# | Headers: | |
# | X-Rate-Limit-Policy: league-account-request-limit | |
# | X-Rate-Limit-Rules: Account | |
# | X-Rate-Limit-Account: 5:10:60,10:300:300 | |
# | X-Rate-Limit-Account-State: 6:10:60,6:300:0 | |
# | Retry-After: 60 | |
# Fetching account 6... | |
# | Fetched characters. Account has 34 characters. | |
# | Headers: | |
# | X-Rate-Limit-Policy: character-list-request-limit | |
# | X-Rate-Limit-Rules: Account | |
# | X-Rate-Limit-Account: 2:10:60,5:300:300 | |
# | X-Rate-Limit-Account-State: 1:10:0,1:300:0 | |
# | Fetched atlas passives. Rate limit exceeded. | |
# | Headers: | |
# | X-Rate-Limit-Policy: league-account-request-limit | |
# | X-Rate-Limit-Rules: Account | |
# | X-Rate-Limit-Account: 5:10:60,10:300:300 | |
# | X-Rate-Limit-Account-State: 6:10:60,7:300:0 | |
# | Retry-After: 60 | |
# Fetching account 7... | |
# | Fetched characters. Account has 13 characters. | |
# | Headers: | |
# | X-Rate-Limit-Policy: character-list-request-limit | |
# | X-Rate-Limit-Rules: Account | |
# | X-Rate-Limit-Account: 2:10:60,5:300:300 | |
# | X-Rate-Limit-Account-State: 1:10:0,1:300:0 | |
# | Fetched atlas passives. Rate limit exceeded. | |
# | Headers: | |
# | X-Rate-Limit-Policy: league-account-request-limit | |
# | X-Rate-Limit-Rules: Account | |
# | X-Rate-Limit-Account: 5:10:60,10:300:300 | |
# | X-Rate-Limit-Account-State: 6:10:59,8:300:0 | |
# | Retry-After: 59 | |
# Fetching account 8... | |
# | Fetched characters. Account has 8 characters. | |
# | Headers: | |
# | X-Rate-Limit-Policy: character-list-request-limit | |
# | X-Rate-Limit-Rules: Account | |
# | X-Rate-Limit-Account: 2:10:60,5:300:300 | |
# | X-Rate-Limit-Account-State: 1:10:0,1:300:0 | |
# | Fetched atlas passives. Rate limit exceeded. | |
# | Headers: | |
# | X-Rate-Limit-Policy: league-account-request-limit | |
# | X-Rate-Limit-Rules: Account | |
# | X-Rate-Limit-Account: 5:10:60,10:300:300 | |
# | X-Rate-Limit-Account-State: 6:10:59,9:300:0 | |
# | Retry-After: 59 | |
# Fetching account 9... | |
# | Fetched characters. Account has 20 characters. | |
# | Headers: | |
# | X-Rate-Limit-Policy: character-list-request-limit | |
# | X-Rate-Limit-Rules: Account | |
# | X-Rate-Limit-Account: 2:10:60,5:300:300 | |
# | X-Rate-Limit-Account-State: 1:10:0,1:300:0 | |
# | Fetched atlas passives. Rate limit exceeded. | |
# | Headers: | |
# | X-Rate-Limit-Policy: league-account-request-limit | |
# | X-Rate-Limit-Rules: Account | |
# | X-Rate-Limit-Account: 5:10:60,10:300:300 | |
# | X-Rate-Limit-Account-State: 6:10:58,10:300:0 | |
# | Retry-After: 58 | |
# Fetching account 10... | |
# | Fetched characters. Account has 4 characters. | |
# | Headers: | |
# | X-Rate-Limit-Policy: character-list-request-limit | |
# | X-Rate-Limit-Rules: Account | |
# | X-Rate-Limit-Account: 2:10:60,5:300:300 | |
# | X-Rate-Limit-Account-State: 1:10:0,1:300:0 | |
# | Fetched atlas passives. Rate limit exceeded. | |
# | Headers: | |
# | X-Rate-Limit-Policy: league-account-request-limit | |
# | X-Rate-Limit-Rules: Account | |
# | X-Rate-Limit-Account: 5:10:60,10:300:300 | |
# | X-Rate-Limit-Account-State: 4:10:57,11:300:300 | |
# | Retry-After: 300 | |
# Fetching account 11... | |
# | Fetched characters. Account has 19 characters. | |
# | Headers: | |
# | X-Rate-Limit-Policy: character-list-request-limit | |
# | X-Rate-Limit-Rules: Account | |
# | X-Rate-Limit-Account: 2:10:60,5:300:300 | |
# | X-Rate-Limit-Account-State: 1:10:0,1:300:0 | |
# | Fetched atlas passives. Rate limit exceeded. | |
# | Headers: | |
# | X-Rate-Limit-Policy: league-account-request-limit | |
# | X-Rate-Limit-Rules: Account | |
# | X-Rate-Limit-Account: 5:10:60,10:300:300 | |
# | X-Rate-Limit-Account-State: 4:10:57,11:300:300 | |
# | Retry-After: 300 | |
# Fetching account 12... | |
# | Fetched characters. Account has 24 characters. | |
# | Headers: | |
# | X-Rate-Limit-Policy: character-list-request-limit | |
# | X-Rate-Limit-Rules: Account | |
# | X-Rate-Limit-Account: 2:10:60,5:300:300 | |
# | X-Rate-Limit-Account-State: 1:10:0,1:300:0 | |
# | Fetched atlas passives. Rate limit exceeded. | |
# | Headers: | |
# | X-Rate-Limit-Policy: league-account-request-limit | |
# | X-Rate-Limit-Rules: Account | |
# | X-Rate-Limit-Account: 5:10:60,10:300:300 | |
# | X-Rate-Limit-Account-State: 4:10:57,11:300:300 | |
# | Retry-After: 300 | |
# Fetching account 13... | |
# | Fetched characters. Account has 24 characters. | |
# | Headers: | |
# | X-Rate-Limit-Policy: character-list-request-limit | |
# | X-Rate-Limit-Rules: Account | |
# | X-Rate-Limit-Account: 2:10:60,5:300:300 | |
# | X-Rate-Limit-Account-State: 1:10:0,1:300:0 | |
# | Fetched atlas passives. Rate limit exceeded. | |
# | Headers: | |
# | X-Rate-Limit-Policy: league-account-request-limit | |
# | X-Rate-Limit-Rules: Account | |
# | X-Rate-Limit-Account: 5:10:60,10:300:300 | |
# | X-Rate-Limit-Account-State: 4:10:56,11:300:299 | |
# | Retry-After: 299 | |
# Fetching account 14... | |
# | Fetched characters. Account has 24 characters. | |
# | Headers: | |
# | X-Rate-Limit-Policy: character-list-request-limit | |
# | X-Rate-Limit-Rules: Account | |
# | X-Rate-Limit-Account: 2:10:60,5:300:300 | |
# | X-Rate-Limit-Account-State: 1:10:0,1:300:0 | |
# | Fetched atlas passives. Rate limit exceeded. | |
# | Headers: | |
# | X-Rate-Limit-Policy: league-account-request-limit | |
# | X-Rate-Limit-Rules: Account | |
# | X-Rate-Limit-Account: 5:10:60,10:300:300 | |
# | X-Rate-Limit-Account-State: 4:10:55,11:300:298 | |
# | Retry-After: 298 | |
# Fetching account 15... | |
# | Fetched characters. Account has 31 characters. | |
# | Headers: | |
# | X-Rate-Limit-Policy: character-list-request-limit | |
# | X-Rate-Limit-Rules: Account | |
# | X-Rate-Limit-Account: 2:10:60,5:300:300 | |
# | X-Rate-Limit-Account-State: 1:10:0,1:300:0 | |
# | Fetched atlas passives. Rate limit exceeded. | |
# | Headers: | |
# | X-Rate-Limit-Policy: league-account-request-limit | |
# | X-Rate-Limit-Rules: Account | |
# | X-Rate-Limit-Account: 5:10:60,10:300:300 | |
# | X-Rate-Limit-Account-State: 4:10:55,11:300:298 | |
# | Retry-After: 298 | |
# Fetching account 16... | |
# | Fetched characters. Account has 19 characters. | |
# | Headers: | |
# | X-Rate-Limit-Policy: character-list-request-limit | |
# | X-Rate-Limit-Rules: Account | |
# | X-Rate-Limit-Account: 2:10:60,5:300:300 | |
# | X-Rate-Limit-Account-State: 1:10:0,1:300:0 | |
# | Fetched atlas passives. Rate limit exceeded. | |
# | Headers: | |
# | X-Rate-Limit-Policy: league-account-request-limit | |
# | X-Rate-Limit-Rules: Account | |
# | X-Rate-Limit-Account: 5:10:60,10:300:300 | |
# | X-Rate-Limit-Account-State: 4:10:54,11:300:297 | |
# | Retry-After: 297 | |
# Fetching account 17... | |
# | Fetched characters. Account has 25 characters. | |
# | Headers: | |
# | X-Rate-Limit-Policy: character-list-request-limit | |
# | X-Rate-Limit-Rules: Account | |
# | X-Rate-Limit-Account: 2:10:60,5:300:300 | |
# | X-Rate-Limit-Account-State: 1:10:0,1:300:0 | |
# | Fetched atlas passives. Rate limit exceeded. | |
# | Headers: | |
# | X-Rate-Limit-Policy: league-account-request-limit | |
# | X-Rate-Limit-Rules: Account | |
# | X-Rate-Limit-Account: 5:10:60,10:300:300 | |
# | X-Rate-Limit-Account-State: 4:10:54,11:300:297 | |
# | Retry-After: 297 | |
# Fetching account 18... | |
# | Fetched characters. Account has 20 characters. | |
# | Headers: | |
# | X-Rate-Limit-Policy: character-list-request-limit | |
# | X-Rate-Limit-Rules: Account | |
# | X-Rate-Limit-Account: 2:10:60,5:300:300 | |
# | X-Rate-Limit-Account-State: 1:10:0,1:300:0 | |
# | Fetched atlas passives. Rate limit exceeded. | |
# | Headers: | |
# | X-Rate-Limit-Policy: league-account-request-limit | |
# | X-Rate-Limit-Rules: Account | |
# | X-Rate-Limit-Account: 5:10:60,10:300:300 | |
# | X-Rate-Limit-Account-State: 4:10:53,11:300:296 | |
# | Retry-After: 296 | |
# Fetching account 19... | |
# | Fetched characters. Account has 19 characters. | |
# | Headers: | |
# | X-Rate-Limit-Policy: character-list-request-limit | |
# | X-Rate-Limit-Rules: Account | |
# | X-Rate-Limit-Account: 2:10:60,5:300:300 | |
# | X-Rate-Limit-Account-State: 1:10:0,1:300:0 | |
# | Fetched atlas passives. Rate limit exceeded. | |
# | Headers: | |
# | X-Rate-Limit-Policy: league-account-request-limit | |
# | X-Rate-Limit-Rules: Account | |
# | X-Rate-Limit-Account: 5:10:60,10:300:300 | |
# | X-Rate-Limit-Account-State: 4:10:53,11:300:296 | |
# | Retry-After: 296 | |
# Fetching account 20... | |
# | Fetched characters. Account has 24 characters. | |
# | Headers: | |
# | X-Rate-Limit-Policy: character-list-request-limit | |
# | X-Rate-Limit-Rules: Account | |
# | X-Rate-Limit-Account: 2:10:60,5:300:300 | |
# | X-Rate-Limit-Account-State: 1:10:0,1:300:0 | |
# | Fetched atlas passives. Rate limit exceeded. | |
# | Headers: | |
# | X-Rate-Limit-Policy: league-account-request-limit | |
# | X-Rate-Limit-Rules: Account | |
# | X-Rate-Limit-Account: 5:10:60,10:300:300 | |
# | X-Rate-Limit-Account-State: 4:10:53,11:300:296 | |
# | Retry-After: 296 | |
# Fetching account 21... | |
# | Fetched characters. Account has 24 characters. | |
# | Headers: | |
# | X-Rate-Limit-Policy: character-list-request-limit | |
# | X-Rate-Limit-Rules: Account | |
# | X-Rate-Limit-Account: 2:10:60,5:300:300 | |
# | X-Rate-Limit-Account-State: 1:10:0,1:300:0 | |
# | Fetched atlas passives. Rate limit exceeded. | |
# | Headers: | |
# | X-Rate-Limit-Policy: league-account-request-limit | |
# | X-Rate-Limit-Rules: Account | |
# | X-Rate-Limit-Account: 5:10:60,10:300:300 | |
# | X-Rate-Limit-Account-State: 0:10:52,11:300:295 | |
# | Retry-After: 295 | |
# Fetching account 22... | |
# | Fetched characters. Account has 20 characters. | |
# | Headers: | |
# | X-Rate-Limit-Policy: character-list-request-limit | |
# | X-Rate-Limit-Rules: Account | |
# | X-Rate-Limit-Account: 2:10:60,5:300:300 | |
# | X-Rate-Limit-Account-State: 1:10:0,1:300:0 | |
# | Fetched atlas passives. Rate limit exceeded. | |
# | Headers: | |
# | X-Rate-Limit-Policy: league-account-request-limit | |
# | X-Rate-Limit-Rules: Account | |
# | X-Rate-Limit-Account: 5:10:60,10:300:300 | |
# | X-Rate-Limit-Account-State: 0:10:52,11:300:295 | |
# | Retry-After: 295 | |
# Fetching account 23... | |
# | Fetched characters. Account has 12 characters. | |
# | Headers: | |
# | X-Rate-Limit-Policy: character-list-request-limit | |
# | X-Rate-Limit-Rules: Account | |
# | X-Rate-Limit-Account: 2:10:60,5:300:300 | |
# | X-Rate-Limit-Account-State: 1:10:0,1:300:0 | |
# | Fetched atlas passives. Rate limit exceeded. | |
# | Headers: | |
# | X-Rate-Limit-Policy: league-account-request-limit | |
# | X-Rate-Limit-Rules: Account | |
# | X-Rate-Limit-Account: 5:10:60,10:300:300 | |
# | X-Rate-Limit-Account-State: 0:10:51,11:300:294 | |
# | Retry-After: 294 | |
# Fetching account 24... | |
# | Fetched characters. Account has 24 characters. | |
# | Headers: | |
# | X-Rate-Limit-Policy: character-list-request-limit | |
# | X-Rate-Limit-Rules: Account | |
# | X-Rate-Limit-Account: 2:10:60,5:300:300 | |
# | X-Rate-Limit-Account-State: 1:10:0,1:300:0 | |
# | Fetched atlas passives. Rate limit exceeded. | |
# | Headers: | |
# | X-Rate-Limit-Policy: league-account-request-limit | |
# | X-Rate-Limit-Rules: Account | |
# | X-Rate-Limit-Account: 5:10:60,10:300:300 | |
# | X-Rate-Limit-Account-State: 0:10:50,11:300:293 | |
# | Retry-After: 293 | |
# Fetching account 25... | |
# | Fetched characters. Account has 23 characters. | |
# | Headers: | |
# | X-Rate-Limit-Policy: character-list-request-limit | |
# | X-Rate-Limit-Rules: Account |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment