Hướng dẫn này bắt đầu từ id của các trận đấu InPlay, và Yêu cầu đầu tiên của bạn giải thích cách tìm chúng. Phần mềm quét so sánh cùng một thị trường giữa nhiều nhà cái, và API cung cấp tỷ lệ cược của mọi nhà cái cho trận đấu dưới duy nhất một match id: bạn không bao giờ phải tự khớp trận đấu giữa các nhà cái.
Tất cả nhà cái trong một yêu cầu
Đưa các trận đấu vào match_ids và bỏ qua bookmaker_ids: phản hồi sẽ chứa mọi nhà cái thuộc API key của bạn, đảm bảo các tỷ lệ cược bạn so sánh được đọc cùng lúc.
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()Kết quả trả về · Kết quả thực tế từ API vào ngày 26 thg 11, 2026, hiển thị các dòng đầu tiên. Kết quả của bạn sẽ chứa các ID khác: hãy đưa những ID đó vào yêu cầu tiếp theo.
Phản hồi dưới dạng JSON: Tất cả nhà cái trong một yêu cầu
{
"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"
}
Sắp xếp các tỷ lệ cược
Tỷ lệ cược của cùng một cửa cược chia sẻ match_id, period_id, type_id và hc. Trên các hàng 1X2, type chính là cửa cược:
| type_id | Tên | Ý nghĩa |
|---|---|---|
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. |
Những dữ liệu không nên so sánh
Trên sàn giao dịch cược (exchange), một hàng có thể là tỷ lệ lay (back_lay_id 1) hoặc cấp độ bên dưới mức tốt nhất (order 2 hoặc 3). Phần mềm quét tỷ lệ back chỉ giữ lại các tỷ lệ back ở mức tốt nhất.
| Trường dữ liệu | Ý nghĩa |
|---|---|
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. |
Tỷ lệ cược bị nhà cái tạm dừng hoặc đóng sẽ rời khỏi feed dữ liệu: tỷ lệ cược thiếu trong phản hồi nghĩa là không còn được mở cược, vì vậy không bao giờ giữ lại tỷ lệ cược cũ đã xem trước đó.
Kiểm tra trước khi đặt cược
Trước khi hành động theo tỷ lệ cược, hãy gửi id của chúng đến odds_seen: seen là thời điểm hệ thống quét của chúng tôi xác nhận lần cuối, và closed được điền khi tỷ lệ đó không còn.
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()Kết quả trả về · Kết quả thực tế từ API vào ngày 26 thg 11, 2026, hiển thị các dòng đầu tiên.
Phản hồi dưới dạng JSON: Kiểm tra trước khi đặt cược
{
"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"
}
Sắp xếp tỷ lệ cược trong một script
Script này yêu cầu tỷ lệ 1X2 của các trận đấu được cung cấp từ tất cả nhà cái thuộc API key của bạn, giữ lại tỷ lệ back ở mức tốt nhất và in tỷ lệ cược của từng cửa từ cao xuống thấp. Script đọc API key từ 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))Ranh giới của feed dữ liệu
Việc lấy tỷ lệ cược tốt nhất của mỗi cửa và tìm các tỷ lệ cược mà khi đặt cùng nhau sẽ bao phủ mọi kết quả với chi phí nhỏ hơn tiền thắng cược là công việc của phần mềm quét. Phép tính đó là của bạn: feed dữ liệu cung cấp tỷ lệ cược thô.
Tiếp theo
Trường hợp sử dụng phần mềm quét arbitrage hiển thị những dữ liệu khác mà phần mềm quét có thể đọc từ API.