statshawk
Cookbook

Hit rate over a line

paid

For any person + stat + line, how often did the in-scope games clear it?

Ten-line hit rate

hit_rate.py
import os, requests
KEY = os.environ["STATSHAWK_KEY"]
BASE = "https://api.statshawk.ai/v1"

person = requests.get(
    f"{BASE}/persons",
    headers={"X-API-Key": KEY},
    params={"q": "Jayson Tatum", "limit": 1},
    timeout=10,
).json()["data"]["items"][0]

card = requests.get(
    f"{BASE}/analysis/player-prop",
    headers={"X-API-Key": KEY},
    params={"person_id": person["id"], "stat": "pts", "line": 27.5, "competition": "nba"},
    timeout=10,
).json()["data"]

hit_rate = card["hit_rate"]
print(f"{card['person']['bio']['full_name']} pts over {hit_rate['line']}")
print(f"{hit_rate['hits']}/{hit_rate['games']}  ({hit_rate['over_rate']:.0%} hit rate)")
print(f"Verdict: {'LEAN OVER' if hit_rate['over_rate'] >= 0.6 else 'PASS'}")
Open /analysis/player-prop in the playground →

On this page