Asian handicap odds API in Python: quarter lines, totals and no-vig prices from Pinnacle data
An Asian handicap odds API gives you one market per line, so a single soccer match can come back as five handicap markets and six totals. To make sense of it in Python you group those markets by period, sort them by line, split the quarter lines into their two halves and look for the line where the no-vig probability sits closest to 50%. The script below does exactly that against live Pinnacle prices.
I work on PinnFeed, the API in the examples. The parsing applies to any feed that uses Pinnacle-style market keys.
How the markets arrive
Each market has a key in the form s;{period};{type};{line}. The type is m for moneyline, s for spread (the handicap) and ou for totals. Period 0 is the full game and 1 the first half. So s;0;s;-0.25 is the full-game home handicap of -0.25 and s;0;ou;2.75 is the full-game total of 2.75.
Inside a market you get the outcomes with the raw price and the no-vig price side by side:
{ "key": "s;0;s;-0.25", "type": "spread", "period": 0, "line": -0.25, "main": false, "maxStake": 2250, "margin": 0.0471, "outcomes": [ { "name": "home", "decimal": 2.79, "points": -0.25, "fair": 2.9215, "fairProb": 0.34229 }, { "name": "away", "decimal": 1.452, "points": 0.25, "fair": 1.5204, "fairProb": 0.65771 } ] } A few fields do most of the work:
-
lineis the home handicap for spreads and the goal total for totals. -
mainflags the line the book treats as the headline one. -
fairandfairProbremove the margin with the multiplicative method, and the rawdecimalis always there if you prefer another method. -
maxStakeis how much risk the source accepts on that market. A bigger limit usually means a price the book trusts more.
Quarter lines in one paragraph
A quarter line such as -0.25 or 2.75 is two bets in one. Half the stake goes on the line below and half on the line above, so home -0.25 is half on 0 and half on -0.5, and over 2.75 is half on 2.5 and half on 3. In code, a line is a quarter line when line * 4 is odd. That check is enough to label them and to show the split.
The script
# ladder.py: print the Asian handicap and totals ladder of each soccer match, # with no-vig prices, quarter-line splits and the line closest to 50/50. # pip install requests ; export PINNFEED_KEY=... import os from collections import defaultdict import requests KEY = os.environ["PINNFEED_KEY"] BASE = "https://pinnfeed.io/v1" def parse_key(key): # market key format: s;{period};{m|s|ou|tt};{line};{side} parts = key.split(";") period, kind = int(parts[1]), parts[2] line = float(parts[3]) if len(parts) > 3 and parts[3] else None return period, kind, line def is_quarter(line): # -0.25, 0.75, 2.25 ... : the stake is split across two half-lines return line is not None and (line * 4) % 2 == 1 def outcome(market, name): return next(o for o in market["outcomes"] if o["name"] == name) r = requests.get( f"{BASE}/odds", params={"sport": "soccer", "market": "spread,total", "limit": 20}, headers={"x-api-key": KEY}, timeout=20, ) r.raise_for_status() board = r.json() print("asOf", board["asOf"]) for ev in board["events"]: ladders = defaultdict(list) for m in ev["markets"]: period, kind, line = parse_key(m["key"]) if kind in ("s", "ou") and line is not None: ladders[(kind, period)].append(m) if not ladders: continue print(f"\n{ev['home']} v {ev['away']} ({ev['league']['name']})") for (kind, period), markets in sorted(ladders.items()): side = "home" if kind == "s" else "over" markets.sort(key=lambda m: m["line"]) balanced = min(markets, key=lambda m: abs(outcome(m, side)["fairProb"] - 0.5)) label = "handicap" if kind == "s" else "total" print(f" {label}, period {period}: {len(markets)} lines, closest to 50/50 at {balanced['line']:g}") for m in markets: o = outcome(m, side) note = " main" if m.get("main") else "" if is_quarter(m["line"]): note += f" (half on {m['line'] - 0.25:g}, half on {m['line'] + 0.25:g})" margin = m.get("margin") margin_txt = f"{margin:.2%}" if margin is not None else "n/a" print( f" {m['line']:>6g} {side:<5} {o['decimal']:>6} fair {o['fair']:>7}" f" margin {margin_txt:>6} max {m.get('maxStake')}{note}" ) What it printed
This is a trimmed run from 5 December 2026 at 09:03 UTC, on a K League 2 match that was in play:
Seoul E-Land v Daegu FC (Korea Republic - K League 2) total, period 0: 3 lines, closest to 50/50 at 2.5 2.5 over 1.729 fair 1.8194 margin 5.23% max 2250 main 2.75 over 2.11 fair 2.2239 margin 5.40% max 2250 (half on 2.5, half on 3) 3 over 3.21 fair 3.3955 margin 5.78% max 2250 handicap, period 0: 5 lines, closest to 50/50 at 0 -0.5 home 3.69 fair 3.8964 margin 5.59% max 2250 -0.25 home 2.85 fair 2.9847 margin 4.73% max 2250 (half on -0.5, half on 0) 0 home 1.892 fair 1.9783 margin 4.56% max 2250 main 0.25 home 1.421 fair 1.4883 margin 4.74% max 2250 (half on 0, half on 0.5) 0.5 home 1.265 fair 1.3355 margin 5.58% max 2250 In every ladder of this run the margin was lowest on the main line and grew as the line moved away from it. The line closest to 50/50 matched main on all four matches the script printed. It prints both anyway, so you notice the day they drift apart.
Things that trip people up
- Free plans return main lines only. On PinnFeed, Free and Realtime REST carry the main markets, so you will see one handicap and one total per period. The full ladder of alternative lines starts at the Builder plan.
- The line is always from the home side. A spread
lineof 0.25 means home +0.25 and away -0.25. Readpointson each outcome if you want the number for that side. - Do not key your book on the line alone. Use the market
id(event id plus key). Two periods can share the same line. - Prematch markets close at kick-off. Past
cutoffAtthey drop out of the default board. Addinclude_started=trueif you still want to see them.
Plans and limits
As of 5 December 2026, PinnFeed's Free plan is $0 with 1,000 REST requests a day, a 30-second delay, two sports and main markets, no card. Realtime REST is $49/month with no delay and main markets plus no-vig prices. Builder is $139/month with every market on offer, alternative lines, the WebSocket and closing lines, and it has a 3-day trial (card required). Pro is $179/month. Prices change, so check the pricing page before you build around them.
The field-by-field reference for markets and outcomes, including how fair is computed, is in the PinnFeed schema docs: https://pinnfeed.io/docs/schema?utm_source=devto&utm_medium=parasite&utm_campaign=20261205-asian-handicap-odds-api
Who publishes this
Written by the PinnFeed team. PinnFeed is a Pinnacle odds API for developers (REST, WebSocket and a hosted MCP server). PinnFeed is not affiliated with Pinnacle. Odds are for information and software development; if you bet, do it only where it is legal for you, 18+.