How to add fancy markets to a cricket betting site
Fancy markets (session runs, lambi, wicket and player markets) are what cricket players in India look for first. This guide walks through adding them to your own site with the Fancy Odds API: get a key, list matches, show a live Yes/No board and keep it current.
Updated 2026-11-17
What you need
- A sandbox key. Ask on Telegram or through the contact form, and send the IP addresses of your servers: keys only work from addresses on your allowlist.
- A server-side component. The API is built for server-to-server use, so the key never goes into a browser or an app.
- About an hour to get a first board on screen.
Step 1: Check your key
Every request carries the key in the X-API-Key header. GET /v1/me tells you which sports and limits your key has.
export FANCYODDS_KEY="fg_test_…"
export BASE="https://api-sandbox.fancyodds.live"
curl -s -H "X-API-Key: $FANCYODDS_KEY" "$BASE/v1/me"Step 2: Find the matches in play
GET /v1/events?sport=cricket&state=inplay lists live matches without prices. Each has an id such as ev_k9wtucdybikxygkh that never changes, so store it.
const BASE = 'https://api-sandbox.fancyodds.live'
const headers = { 'X-API-Key': process.env.FANCYODDS_KEY }
const get = async (path) => (await fetch(BASE + path, { headers })).json()
const { events } = await get('/v1/events?sport=cricket&state=inplay')
for (const e of events) console.log(e.id, e.name, e.marketCount, 'markets')Step 3: Pick out the fancy markets
GET /v1/events/{id} returns the match with every open market. Fancy markets have "type": "fancy". Their format is line for runs, wickets and totals, and range for Khado. In a line market the back price is the Yes side and the lay price is the No side: price is the line and size is the rate.
const event = await get('/v1/events/' + events[0].id)
const fancy = event.markets.filter((m) => m.type === 'fancy')
for (const m of fancy) {
const r = m.runners[0]
const no = r.lay[0], yes = r.back[0]
console.log(m.name.padEnd(28), m.status.padEnd(12),
'No', no ? `${no.price} · ${no.size}` : '-',
' Yes', yes ? `${yes.price} · ${yes.size}` : '-')
}Step 4: Show only what can be played
Fancy prices move on every ball. Each market carries a status:
| Status | What your board shows |
|---|---|
| OPEN | Prices, ready to take bets |
| BALL_RUNNING | The ball is in play: show the market, take no bets |
| SUSPENDED | A wicket, a review or a feed check: no bets |
| CLOSED | Finished: remove it, the result follows |
A market with "stale": true is treated as suspended until prices flow again. Taking bets only on OPEN is the single most important rule for a fancy book.
Step 5: Keep the board live
Polling every match every second does not scale. Open one live stream (Server-Sent Events) instead: it sends each match in full once, then only the market that changed, usually within a fraction of a second. Replace your copy of a market with each market-update; never merge.
// npm install eventsource
import { EventSource } from 'eventsource'
const url = BASE + '/v1/stream?events=' + events.slice(0, 5).map((e) => e.id).join(',')
const es = new EventSource(url, {
fetch: (u, init) => fetch(u, { ...init, headers: { ...init.headers, ...headers } }),
})
es.addEventListener('market-update', (m) => {
const { event, market } = JSON.parse(m.data)
if (market.type === 'fancy') draw(event, market) // replace, don't merge
})Step 6: Settle from results
When a session ends you receive a result on the same stream, with the number the market settled at. The guide How to settle fancy bets from a result API shows the arithmetic and how to handle corrections.
Sandbox limits
Sandbox keys see real, current markets, with prices 60 seconds old, one stream at a time, up to 5 matches per stream and 2 requests per second. Live keys have none of these limits. Everything else is in the API reference.
Common questions
Do I need a separate API for session fancy?
No. Session runs, lambi, wickets, player runs, Khado, Meter and Odd/Even arrive in the same feed as match odds and bookmaker, marked by type and format.
Can I call the API from my website's JavaScript?
No. Keys work only from your servers' IP addresses. Your server reads the feed and sends your own pages what they need.
What if my server misses part of the stream?
Reconnect with the last message id in the Last-Event-ID header and you receive exactly what you missed. Standard EventSource clients do this for you.