Converting to American odds
Which products return American odds, and a function to convert the rest.
Decimal only on standard and dutching
standard and dutching serve decimal odds only: oddsFormat=american is a 400 there. 2up, each-way, extra-place, bog, raw, the single-event route and the historical board and event calls take oddsFormat=american and convert for you. On standard and dutching, convert yourself.
This matches the API's own conversion: a price at or below 1.0 has no American form (null), and halves round to even.
const roundHalfEven = (x) => { const f = Math.floor(x); return x - f === 0.5 ? (f % 2 === 0 ? f : f + 1) : Math.round(x); };
const american = (d) => (d <= 1 ? null : d >= 2 ? roundHalfEven((d - 1) * 100) : roundHalfEven(-100 / (d - 1)));
const decimal = (a) => (a > 0 ? 1 + a / 100 : 1 + 100 / -a);From the blog
- The anatomy of an odds API responseEvery field in a /v2 odds response, from the meta envelope down to each back and lay offer.
- How to display odds data in your appTurn a nested odds response into table rows, format prices and show each price's age.
- Dutching data explainedThe stake arithmetic behind dutching, and a feed that sends the legs already grouped.
Every parameter: API reference.