Find the counters for a hero
Who beats Miya in Mythic this week, with names and win rate gains.
1 Ask for the counters
days is the window (1, 3, 7, 15 or 30) and rank is the tier.
curl "https://arena.fastapicloud.dev/api/heroes/miya/counters?days=7&rank=mythic"
2 Understand the answer
data.records[0].data describes the hero you asked about. Its sub_hero list holds the heroes that do best against it, and increase_win_rate says by how much, as a fraction: 0.026 is 2.6 percentage points. sub_hero_last holds the heroes that do worst against it.
3 Add the names
The counters list uses hero numbers, so fetch the hero list once and look the names up.
import httpx
base = "https://arena.fastapicloud.dev/api"
heroes = httpx.get(f"{base}/heroes?size=200").json()["data"]["records"]
names = {row["data"]["hero_id"]: row["data"]["hero"]["data"]["name"] for row in heroes}
answer = httpx.get(f"{base}/heroes/miya/counters?days=7&rank=mythic").json()
for counter in answer["data"]["records"][0]["data"]["sub_hero"]:
print(names[counter["heroid"]], f"{counter['increase_win_rate']:+.1%}")
The hero list changes only when a new hero is released, so keep it instead of fetching it every time.