本指南从滚球比赛的 ID 开始,您的首次请求展示了如何获取这些 ID。扫描器需要对比多家博彩公司同一盘口的数据,而 API 会在同一个 match id 下提供所有博彩公司的赔率:您无需手动匹配不同博彩公司之间的赛事。
单次请求包含所有博彩公司
将比赛传入 match_ids 且不填写 bookmaker_ids:返回数据将包含您密钥拥有的所有博彩公司,确保您对比的赔率是同时读取的。
curl -X POST https://oddfeeds.com/api/v1/feeds \
-H "Authorization: Bearer ofk_your_api_key" \
-H "Content-Type: application/json" \
-d '{"scope":"odds","match_ids":[13675188,13677494],"odd_type_ids":[2,3,4],"odd_period_ids":[1]}'const res = await fetch('https://oddfeeds.com/api/v1/feeds', {
method: 'POST',
headers: {
'Authorization': 'Bearer ofk_your_api_key',
'Content-Type': 'application/json',
},
body: JSON.stringify({"scope":"odds","match_ids":[13675188,13677494],"odd_type_ids":[2,3,4],"odd_period_ids":[1]}),
});
const feed = await res.json();import requests
res = requests.post(
'https://oddfeeds.com/api/v1/feeds',
headers={'Authorization': 'Bearer ofk_your_api_key'},
json={"scope":"odds","match_ids":[13675188,13677494],"odd_type_ids":[2,3,4],"odd_period_ids":[1]},
timeout=20,
)
feed = res.json()返回结果 · API 于 2026年11月26日 返回的结果,仅展示前几行。 实际返回结果会包含其他 ID,请在下一个请求中使用对应的 ID。
JSON 返回结果: 单次请求包含所有博彩公司
{
"status": "ok",
"data": {
"prematch": [],
"inplay": [
{
"id": 401959094,
"active": 1,
"match_id": 13675188,
"event_id": 72567276,
"bookmaker": {
"id": 47,
"name": "BetfairExchange"
},
"datetime": "2026-11-26T15:18:13",
"period_id": 1,
"type_id": 2,
"order": 1,
"back_lay_id": 0,
"liquidity": 12,
"hc": -3,
"hc_as_draw": 0,
"price": 200,
"nav": "{\"v\":1,\"scope\":\"inplay\",\"eventId\":\"36359303\",\"url\":\"https...",
"runtime": {
"play": {
"codec": 13,
"display": "1H 13'"
},
"points": {
"home": 0,
"away": 0
}
}
},
{
"id": 401921412,
"active": 1,
"match_id": 13677494,
"event_id": 72567313,
"bookmaker": {
"id": 47,
"name": "BetfairExchange"
},
"datetime": "2026-11-26T15:15:46",
"period_id": 1,
"type_id": 3,
"order": 2,
"back_lay_id": 1,
"liquidity": 20,
"hc": 3,
"hc_as_draw": 0,
"price": 120,
"nav": "{\"v\":1,\"scope\":\"inplay\",\"eventId\":\"36359307\",\"url\":\"https...",
"runtime": {
"play": {
"codec": 300,
"display": "HT"
},
"points": {
"home": 0,
"away": 0
}
}
}
]
},
"time": "2026-11-26T15:18:21",
"ms": "18.09ms"
}
对齐赔率数据
同一投注项的赔率共享 match_id、period_id、type_id 和 hc。在 1X2 格式的行中,type 即代表投注结果:
| type_id | 名称 | 含义 |
|---|---|---|
2 | 1 | Match winner, home. With a non-zero hc it's European handicap: hc is the home team's handicap, the same on all three rows of the line, so at -1 this row wins when the home team wins by two goals or more. The coverage pages list these rows as European handicap. |
3 | X | Match winner, draw. With a non-zero hc it's European handicap: at -1 this row wins when the home team wins by exactly one goal. |
4 | 2 | Match winner, away. With a non-zero hc it's European handicap: at -1 this row wins on a draw or an away win. |
不需要对比的内容
在交易所中,某行数据可能是 lay 赔率(back_lay_id 1)或低于最优层级的数据(order 2 或 3)。针对 back 赔率的扫描器应仅保留最高层级的 back 赔率。
| 字段 | 含义 |
|---|---|
back_lay_id | 0 = back, 1 = lay (exchanges). |
order | On an exchange, the price level: 1 is the best price, 2 and 3 the next ones on the same side, each with its own liquidity. It isn't a line number: lines differ by hc. |
liquidity | Available volume at this price level in euros, rounded down to whole euros. Exchanges only; -1 at other bookmakers. |
博彩公司暂停或关闭的赔率会从数据流中移除:返回结果中缺失的赔率表示该项不再提供,切勿保留上次读取到的旧赔率。
在下注前进行校验
在根据赔率采取行动之前,将其 ID 传给 odds_seen:seen 表示我们扫描器最后确认该赔率的时间,一旦赔率失效则会填充 closed。
curl -X POST https://oddfeeds.com/api/v1/feeds \
-H "Authorization: Bearer ofk_your_api_key" \
-H "Content-Type: application/json" \
-d '{"scope":"odds_seen","odd_ids":[401959094,401921412,401918414]}'const res = await fetch('https://oddfeeds.com/api/v1/feeds', {
method: 'POST',
headers: {
'Authorization': 'Bearer ofk_your_api_key',
'Content-Type': 'application/json',
},
body: JSON.stringify({"scope":"odds_seen","odd_ids":[401959094,401921412,401918414]}),
});
const feed = await res.json();import requests
res = requests.post(
'https://oddfeeds.com/api/v1/feeds',
headers={'Authorization': 'Bearer ofk_your_api_key'},
json={"scope":"odds_seen","odd_ids":[401959094,401921412,401918414]},
timeout=20,
)
feed = res.json()返回结果 · API 于 2026年11月26日 返回的结果,仅展示前几行。
JSON 返回结果: 在下注前进行校验
{
"status": "ok",
"data": [
{
"id": 401959094,
"open": "2026-11-26T15:05:21",
"seen": "2026-11-26T15:18:21",
"closed": ""
},
{
"id": 401921412,
"open": "2026-11-26T14:27:03",
"seen": "2026-11-26T15:18:21",
"closed": ""
}
],
"time": "2026-11-26T15:18:22",
"ms": "1.54ms"
}
用单个脚本实现赔率对齐
此脚本会请求指定比赛在您密钥所含全部博彩公司的 1X2 赔率,保留最高层级的 back 赔率,并按赔率从高到低打印每个投注项的数据。脚本从 ODDFEEDS_KEY 读取密钥。
// The 1X2 prices of some matches at every bookmaker of your key, lined up per outcome:
// back prices at the best level only, highest first. The scanning itself is yours.
// ODDFEEDS_KEY=<your key> node arbitrage-scanner-feed.mjs <match id> ...
const API = process.env.ODDFEEDS_URL || 'https://oddfeeds.com/api/v1/feeds';
const matchIds = process.argv.slice(2).map(Number);
const SIDE = { 2: '1', 3: 'X', 4: '2' };
const res = await fetch(API, {
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.ODDFEEDS_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
scope: 'odds',
match_ids: matchIds,
odd_type_ids: [2, 3, 4],
odd_period_ids: [1],
}),
});
const feed = await res.json();
if (feed.status !== 'ok') throw new Error(`${res.status}: ${feed.error}`);
const rows = [...feed.data.prematch, ...feed.data.inplay];
console.log(`Matches ${matchIds.join(', ')}: ${rows.length} prices`);
// One market = one match, one period, one line (hc); in it, one list per outcome.
const markets = new Map();
for (const r of rows) {
if (r.back_lay_id !== 0 || (r.order ?? 1) > 1) continue; // lay prices, deeper levels
const key = `${r.match_id} period ${r.period_id} hc ${r.hc}`;
if (!markets.has(key)) markets.set(key, { 2: [], 3: [], 4: [] });
markets.get(key)[r.type_id].push({ book: r.bookmaker.name, price: r.price });
}
for (const [key, outcomes] of markets) {
console.log(`Match ${key}`);
for (const type of [2, 3, 4]) {
const list = outcomes[type].sort((a, b) => b.price - a.price);
const prices = list.map((x) => `${x.book} ${x.price}`).join(', ');
console.log(` ${SIDE[type]}: ${prices}`);
}
}# The 1X2 prices of some matches at every bookmaker of your key, lined up per outcome:
# back prices at the best level only, highest first. The scanning itself is yours.
# ODDFEEDS_KEY=<your key> python arbitrage-scanner-feed.py <match id> ...
import os
import sys
import requests
API = os.environ.get('ODDFEEDS_URL', 'https://oddfeeds.com/api/v1/feeds')
match_ids = [int(x) for x in sys.argv[1:]]
SIDE = {2: '1', 3: 'X', 4: '2'}
res = requests.post(
API,
headers={'Authorization': f"Bearer {os.environ['ODDFEEDS_KEY']}"},
json={'scope': 'odds', 'match_ids': match_ids,
'odd_type_ids': [2, 3, 4], 'odd_period_ids': [1]},
timeout=20,
)
feed = res.json()
if feed['status'] != 'ok':
raise RuntimeError(f"{res.status_code}: {feed['error']}")
rows = feed['data']['prematch'] + feed['data']['inplay']
print(f"Matches {', '.join(map(str, match_ids))}: {len(rows)} prices")
# One market = one match, one period, one line (hc); in it, one list per outcome.
markets = {}
for r in rows:
if r['back_lay_id'] != 0 or (r.get('order') or 1) > 1: # lay, deeper levels
continue
key = f"{r['match_id']} period {r['period_id']} hc {r['hc']}"
outcomes = markets.setdefault(key, {2: [], 3: [], 4: []})
outcomes[r['type_id']].append((r['bookmaker']['name'], r['price']))
for key, outcomes in markets.items():
print(f"Match {key}")
for t in (2, 3, 4):
best_first = sorted(outcomes[t], key=lambda x: -x[1])
print(f" {SIDE[t]}: " + ', '.join(f"{b} {p}" for b, p in best_first))数据流的职责边界
获取每个投注项的最优赔率,并计算组合投注后能覆盖所有结果且产生套利空间的赔率,这是扫描器自身的工作。套利计算由您自行完成,数据流负责提供原始赔率数据。
下一步
套利扫描器使用场景展示了扫描器还可以从 API 读取哪些其他数据。