OddFeeds API पर आपकी पहली request

आपकी API key से लेकर एक मैच के odds तक, चार requests में, जहाँ हर request पिछले जवाब से अपनी id लेती है।

6 मिनट में पढ़ें ·

API का हर जवाब अगली request के लिए ids देता है: देशों से उनकी leagues मिलती हैं, leagues से उनके matches, और matches से उनके odds। यह गाइड क्रम में वे चार requests बनाती है और दिखाती है कि हर जवाब में क्या होता है।

आपकी API key

हर request एक ही पते पर POST होती है, जिसमें आपकी key header में भेजी जाती है: Authorization: Bearer के बाद key। अकाउंट बनने के बाद आपकी key आपके अकाउंट पेज पर होती है, और services पेज बताती है कि इसे कैसे प्राप्त करें।

1. देश

बिना scope वाली request उन देशों की सूची देती है जिनके पास अभी kick-off से पहले और in play में odds उपलब्ध हैं।

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}'

जवाब · 26 नव॰ 2026 को API से मिला एक जवाब, जिसकी शुरुआती रो दिखाई गई हैं। आपके अपने जवाब में अलग ids होंगी: उन्हें अगली रिक्वेस्ट में इस्तेमाल करें।

JSON में जवाब: 1. देश
{
  "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 और inplay_leagues_cnt किसी देश की उन leagues की गिनती बताते हैं जिनके पास kick-off से पहले और in play में odds हैं। ऐसा देश चुनें जिसकी गिनती शून्य से अधिक हो।

2. किसी देश की leagues

देश की id को tournament_ids में डालें। जवाब में उसकी leagues और उनके कितने matches में odds हैं, इसकी सूची मिलती है।

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]}'

जवाब · 26 नव॰ 2026 को API से मिला जवाब। आपके अपने जवाब में अलग ids होंगी: उन्हें अगली रिक्वेस्ट में इस्तेमाल करें।

JSON में जवाब: 2. किसी देश की leagues
{
  "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. किसी league के matches

किसी league की id को 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]}'

जवाब · 26 नव॰ 2026 को API से मिला एक जवाब, जिसकी शुरुआती रो दिखाई गई हैं। आपके अपने जवाब में अलग ids होंगी: उन्हें अगली रिक्वेस्ट में इस्तेमाल करें।

JSON में जवाब: 3. किसी league के matches
{
  "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 UTC समय में kick-off है। active बताता है कि मैच में अभी किस mode में odds हैं, और in play मैच में मिनट और स्कोर के साथ stats.runtime भी होता है।

4. एक मैच के odds

मैच की id को match_ids में डालें। बिना bookmaker_ids के, जवाब में वे सभी bookmakers मिलते हैं जो आपकी key की पहुँच में हैं।

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]}'

जवाब · 26 नव॰ 2026 को API से मिला एक जवाब, जिसकी शुरुआती रो दिखाई गई हैं।

JSON में जवाब: 4. एक मैच के odds
{
  "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"
}

पंक्तियाँ दो सूचियों prematch और inplay में आती हैं, प्रत्येक mode के लिए एक, और हर पंक्ति एक bookmaker का एक price होती है। ये वे fields हैं जिन्हें आप पहले पढ़ते हैं:

odds रो के फ़ील्ड्स
फ़ील्डमतलब
bookmakerid + name of the source bookmaker.
type_idMarket type, see the type_id table.
period_id0 = first half, 1 = full time, 6 = second half.
hcThe 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.
priceThe odd, decimal format. On an exchange it's the price as the exchange shows it, with no commission taken off.
datetimeWhen this price last changed (UTC).

पंक्ति में हर संख्या का क्या अर्थ है, यह documentation की reference tables में दिया गया है।

जब API एरर रिस्पांस दे

ये वे दो जवाब हैं जिनका पहली request में सबसे अक्सर सामना होता है, API के अपने शब्दों में:

एरर रेस्पॉन्स
HTTP स्टेटसमतलब
400A 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.
401Missing or unknown API key.

पूरी प्रक्रिया एक ही script में

यह script क्रम में चारों requests बनाती है और हर id को आगे भेजती है। यह आपकी key को ODDFEEDS_KEY environment variable से पढ़ती है, ताकि key आपके कोड से बाहर रहे।

// 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);
}

आगे

Documentation में हर scope, field और market तालिका है, और use cases का पेज दिखाता है कि डेवलपर्स इन requests के आधार पर क्या बनाते हैं।

इसे लाइव डेटा पर आज़माएं

फ्री अकाउंट में प्लेग्राउंड आपके ब्राउज़र में लाइव डेटा पर इन रिक्वेस्ट को रन करता है।