Mỗi phản hồi từ API sẽ cung cấp cho bạn các id cho yêu cầu tiếp theo: quốc gia dẫn đến giải đấu, giải đấu dẫn đến trận đấu, và trận đấu dẫn đến tỷ lệ cược. Hướng dẫn này thực hiện bốn yêu cầu đó theo thứ tự và hiển thị dữ liệu trong từng phản hồi.
API key của bạn
Mỗi yêu cầu là một lệnh POST đến một địa chỉ, với key nằm trong header: Authorization: Bearer theo sau là key đó. Key nằm trên trang tài khoản của bạn sau khi đăng ký, và trang dịch vụ hướng dẫn cách lấy key.
1. Các quốc gia
Một yêu cầu không có scope sẽ liệt kê các quốc gia hiện có tỷ lệ cược, trước trận đấu và trực tiếp.
curl -X POST https://oddfeeds.com/api/v1/feeds \
-H "Authorization: Bearer ofk_your_api_key" \
-H "Content-Type: application/json" \
-d '{"prematch":true,"inplay":true}'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({"prematch":true,"inplay":true}),
});
const feed = await res.json();import requests
res = requests.post(
'https://oddfeeds.com/api/v1/feeds',
headers={'Authorization': 'Bearer ofk_your_api_key'},
json={"prematch":True,"inplay":True},
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: 1. Các quốc gia
{
"status": "ok",
"data": [
{
"id": 136,
"name": "Slovakia",
"prematch_leagues_cnt": 1,
"inplay_leagues_cnt": 0
},
{
"id": 42,
"name": "Costa Rica",
"prematch_leagues_cnt": 2,
"inplay_leagues_cnt": 0
}
],
"time": "2026-11-26T15:14:19",
"ms": "479us"
}
prematch_leagues_cnt và inplay_leagues_cnt đếm số giải đấu của một quốc gia có tỷ lệ cược trước trận đấu và trực tiếp. Chọn một quốc gia có số lượng lớn hơn 0.
2. Các giải đấu của một quốc gia
Đưa id của quốc gia vào tournament_ids. Phản hồi sẽ liệt kê các giải đấu và số lượng trận đấu có tỷ lệ cược.
curl -X POST https://oddfeeds.com/api/v1/feeds \
-H "Authorization: Bearer ofk_your_api_key" \
-H "Content-Type: application/json" \
-d '{"scope":"leagues","tournament_ids":[136]}'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":"leagues","tournament_ids":[136]}),
});
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":"leagues","tournament_ids":[136]},
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. 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: 2. Các giải đấu của một quốc gia
{
"status": "ok",
"data": [
{
"id": 10618,
"tournament_id": 136,
"name": "Super Liga",
"prematch_matches_cnt": 6,
"inplay_matches_cnt": 0
}
],
"time": "2026-11-26T15:14:19",
"ms": "400us"
}
3. Các trận đấu của một giải đấu
Đưa id của giải đấu vào league_ids.
curl -X POST https://oddfeeds.com/api/v1/feeds \
-H "Authorization: Bearer ofk_your_api_key" \
-H "Content-Type: application/json" \
-d '{"scope":"matches","league_ids":[10618]}'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":"matches","league_ids":[10618]}),
});
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":"matches","league_ids":[10618]},
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: 3. Các trận đấu của một giải đấu
{
"status": "ok",
"data": [
{
"id": 13682297,
"league_id": 10618,
"teams": {
"home": "Dukla Banska Bystrica",
"away": "MFK Ruzomberok"
},
"start": "2026-11-28T14:30:00",
"active": {
"prematch": 1,
"inplay": 0
},
"stats": {
"start": "2026-11-28T14:30:00"
}
},
{
"id": 13683299,
"league_id": 10618,
"teams": {
"home": "Slovan Bratislava",
"away": "FC Kosice"
},
"start": "2026-11-28T17:00:00",
"active": {
"prematch": 1,
"inplay": 0
},
"stats": {
"start": "2026-11-28T17:00:00"
}
}
],
"time": "2026-11-26T15:14:20",
"ms": "700us"
}
start là thời gian bắt đầu trận đấu theo UTC. active cho biết trận đấu hiện có tỷ lệ cược ở chế độ nào, và trận đấu trực tiếp cũng kèm theo stats.runtime với số phút và tỷ số.
4. Tỷ lệ cược của một trận đấu
Đưa id của trận đấu vào match_ids. Nếu không có bookmaker_ids, phản hồi sẽ chứa mọi nhà cái mà key của bạn cho phép truy cập.
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":[13682297]}'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":[13682297]}),
});
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":[13682297]},
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: 4. Tỷ lệ cược của một trận đấu
{
"status": "ok",
"data": {
"prematch": [
{
"id": 390798263,
"active": 1,
"match_id": 13682297,
"event_id": 72533074,
"bookmaker": {
"id": 59,
"name": "Bet8"
},
"datetime": "2026-11-26T01:35:42",
"period_id": 0,
"type_id": 11,
"order": 1,
"back_lay_id": 0,
"liquidity": -1,
"hc": 0,
"hc_as_draw": 0,
"price": 1.231,
"nav": "{\"v\":1,\"scope\":\"prematch\",\"eventId\":\"18450709\",\"oddId\":\"4..."
},
{
"id": 390634623,
"active": 1,
"match_id": 13682297,
"event_id": 72531615,
"bookmaker": {
"id": 34,
"name": "Trbet"
},
"datetime": "2026-11-26T01:36:24",
"period_id": 0,
"type_id": 9,
"order": 1,
"back_lay_id": 0,
"liquidity": -1,
"hc": 2,
"hc_as_draw": 0,
"price": 1.14,
"nav": "{\"v\":1,\"scope\":\"prematch\",\"eventId\":\"42575268\",\"oddId\":\"7..."
}
],
"inplay": []
},
"time": "2026-11-26T15:15:19",
"ms": "15.97ms"
}
Các dòng dữ liệu nằm trong hai danh sách, prematch và inplay, tương ứng với từng chế độ, và mỗi dòng là một mức giá của một nhà cái. Đây là các trường bạn đọc đầu tiên:
| Trường dữ liệu | Ý nghĩa |
|---|---|
bookmaker | id + name of the source bookmaker. |
type_id | Market type, see the type_id table. |
period_id | 0 = first half, 1 = full time, 6 = second half. |
hc | The handicap / total line, e.g. -0.5 or 2.5. On 1X2 rows (type_id 2, 3, 4) a non-zero hc is a European handicap line, and for correct score (type_id 66) it carries the score; see the type_id table. |
price | The odd, decimal format. On an exchange it's the price as the exchange shows it, with no commission taken off. |
datetime | When this price last changed (UTC). |
Ý nghĩa của từng con số trong một dòng được giải thích tại các bảng tham chiếu trong tài liệu hướng dẫn.
Khi API từ chối
Đây là hai phản hồi mà một yêu cầu đầu tiên thường gặp nhất, theo đúng nguyên văn từ API:
| Mã trạng thái HTTP | Ý nghĩa |
|---|---|
400 | A body that is not valid JSON, a malformed parameter, a scope without its id list, or id lists that count as more requests than one request may (see 429); the error field says what was wrong. |
401 | Missing or unknown API key. |
Toàn bộ quy trình trong một kịch bản
Kịch bản này thực hiện bốn yêu cầu theo thứ tự và chuyển tiếp từng id. Nó đọc key từ biến môi trường ODDFEEDS_KEY, giúp giữ key tách biệt khỏi mã nguồn của bạn.
// The whole walk: the countries, a country's leagues, a league's
// matches and the odds of one match. Run it with your key:
// ODDFEEDS_KEY=<your key> node first-request.mjs
const API = process.env.ODDFEEDS_URL || 'https://oddfeeds.com/api/v1/feeds';
async function ask(body) {
const res = await fetch(API, {
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.ODDFEEDS_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify(body),
});
const feed = await res.json();
if (feed.status !== 'ok') throw new Error(`${res.status}: ${feed.error}`);
return feed.data;
}
const countries = await ask({ prematch: true, inplay: true });
const country = countries.find(
(c) => c.prematch_leagues_cnt > 0 || c.inplay_leagues_cnt > 0);
if (!country) throw new Error('No country has odds right now.');
const leagues = await ask({ scope: 'leagues', tournament_ids: [country.id] });
const league = leagues.find(
(l) => l.prematch_matches_cnt > 0 || l.inplay_matches_cnt > 0);
const matches = await ask({ scope: 'matches', league_ids: [league.id] });
const match = matches[0];
const odds = await ask({ scope: 'odds', match_ids: [match.id] });
const rows = [...odds.prematch, ...odds.inplay];
const { home, away } = match.teams;
console.log(`${country.name} / ${league.name} / ${home} - ${away}: ${rows.length} prices`);
for (const r of rows.slice(0, 5)) {
console.log(r.bookmaker.name, r.type_id, r.hc, r.price);
}# The whole walk: the countries, a country's leagues, a league's
# matches and the odds of one match. Run it with your key:
# ODDFEEDS_KEY=<your key> python first-request.py
import os
import requests
API = os.environ.get('ODDFEEDS_URL', 'https://oddfeeds.com/api/v1/feeds')
def ask(body):
res = requests.post(
API,
headers={'Authorization': f"Bearer {os.environ['ODDFEEDS_KEY']}"},
json=body,
timeout=20,
)
feed = res.json()
if feed['status'] != 'ok':
raise RuntimeError(f"{res.status_code}: {feed['error']}")
return feed['data']
countries = ask({'prematch': True, 'inplay': True})
country = next((c for c in countries
if c['prematch_leagues_cnt'] > 0 or c['inplay_leagues_cnt'] > 0), None)
if country is None:
raise RuntimeError('No country has odds right now.')
leagues = ask({'scope': 'leagues', 'tournament_ids': [country['id']]})
league = next(l for l in leagues
if l['prematch_matches_cnt'] > 0 or l['inplay_matches_cnt'] > 0)
matches = ask({'scope': 'matches', 'league_ids': [league['id']]})
match = matches[0]
odds = ask({'scope': 'odds', 'match_ids': [match['id']]})
rows = odds['prematch'] + odds['inplay']
home, away = match['teams']['home'], match['teams']['away']
print(f"{country['name']} / {league['name']} / {home} - {away}: {len(rows)} prices")
for r in rows[:5]:
print(r['bookmaker']['name'], r['type_id'], r['hc'], r['price'])Bước tiếp theo
Tài liệu hướng dẫn chứa đầy đủ các bảng về scope, trường dữ liệu và thị trường, còn trang trường hợp sử dụng minh họa những gì các nhà phát triển xây dựng từ các yêu cầu này.