Skip to content

Instantly share code, notes, and snippets.

@ChanceToZoinks
Last active April 19, 2022 00:36
Show Gist options
  • Save ChanceToZoinks/980d44845ec19c770f591e9b99f3c079 to your computer and use it in GitHub Desktop.
Save ChanceToZoinks/980d44845ec19c770f591e9b99f3c079 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import requests
BUILD_SNAPSHOT = 0
ENDPOINT = f"https://poe.ninja/api/data/{BUILD_SNAPSHOT}/getbuildoverview"
PARAMS = {"overview": "archnemesis", "type": "exp", "language": "en"}
def _try_get_builds():
r = requests.get(url=ENDPOINT, params=PARAMS)
try:
return r.json()
except:
return {}
def get_n_characters(n):
"""
Get the first n characters in the list storing their name, level, life, es, and worn unique items
"""
builds = _try_get_builds()
if builds:
characters = []
for i in range(n):
c = {}
c["name"] = builds["names"][i]
c["level"] = builds["levels"][i]
c["life"] = builds["life"][i]
c["es"] = builds["energyShield"][i]
c["uniques"] = []
for idx, unique in enumerate(builds["uniqueItems"]):
if i in builds["uniqueItemUse"][str(idx)]:
c["uniques"].append(unique["name"])
characters.append(c)
return characters
else:
return "No builds found."
if __name__ == "__main__":
print(get_n_characters(1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment