In-play की कीमतें poll करें और जानें कि हर कीमत कितनी ताज़ा है

सिर्फ़ उन मैचों और मार्केट्स को माँगें जिनमें आप ट्रेड करते हैं, हर कीमत के साथ मिनट और स्कोर पढ़ें, देखें कि हर कीमत कब आखिरी बार बदली और कन्फर्म हुई, और API के कहने पर सही तरीके से रुकें।

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

यह गाइड लाइव मैच की id से शुरू होती है, और आपकी पहली रिक्वेस्ट दिखाता है कि इसे कैसे खोजें। पोलिंग का मतलब है एक ही सवाल बार-बार पूछना: हर जवाब उस पल का फीड होता है।

वही माँगें जो आप ट्रेड करते हैं

हर रिक्वेस्ट आपकी की (key) की लिमिट में गिनी जाती है, इसलिए match_ids में उन मैचों को और odd_type_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],"odd_type_ids":[2,3,4],"odd_period_ids":[1]}'

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

JSON में जवाब: वही माँगें जो आप ट्रेड करते हैं
{
  "status": "ok",
  "data": {
    "prematch": [],
    "inplay": [
      {
        "id": 401958384,
        "active": 1,
        "match_id": 13675188,
        "event_id": 72567276,
        "bookmaker": {
          "id": 47,
          "name": "BetfairExchange"
        },
        "datetime": "2026-11-26T15:21:20",
        "period_id": 1,
        "type_id": 3,
        "order": 2,
        "back_lay_id": 0,
        "liquidity": 45,
        "hc": -1,
        "hc_as_draw": 0,
        "price": 5.8,
        "nav": "{\"v\":1,\"scope\":\"inplay\",\"eventId\":\"36359303\",\"url\":\"https...",
        "runtime": {
          "play": {
            "codec": 16,
            "display": "1H 16'"
          },
          "points": {
            "home": 0,
            "away": 0
          }
        }
      },
      {
        "id": 401958562,
        "active": 1,
        "match_id": 13675188,
        "event_id": 72567276,
        "bookmaker": {
          "id": 47,
          "name": "BetfairExchange"
        },
        "datetime": "2026-11-26T15:21:11",
        "period_id": 1,
        "type_id": 3,
        "order": 1,
        "back_lay_id": 0,
        "liquidity": 94,
        "hc": 1,
        "hc_as_draw": 0,
        "price": 3.6,
        "nav": "{\"v\":1,\"scope\":\"inplay\",\"eventId\":\"36359303\",\"url\":\"https...",
        "runtime": {
          "play": {
            "codec": 16,
            "display": "1H 16'"
          },
          "points": {
            "home": 0,
            "away": 0
          }
        }
      }
    ]
  },
  "time": "2026-11-26T15:21:22",
  "ms": "5.07ms"
}

मिनट और स्कोर

In-play में कीमतें inplay के तहत आती हैं, और हर रो (row) में runtime होता है: उस कीमत पर मिनट और स्कोर।

odds रो के फ़ील्ड्स
फ़ील्डमतलब
runtimeIn-play only: playtime + score snapshot at this price.
datetimeWhen this price last changed (UTC).
active1: the bookmaker offers this price. When the bookmaker suspends or closes a price, a market or a match, it leaves the feed instead of showing 0; odds_seen gives the time a price closed.

हर कीमत कितनी ताज़ा है

जिन कीमतों पर आप काम करते हैं उनकी id को odds_seen में भेजें। इसका जवाब बताता है कि बुकी ने हर कीमत कब पब्लिश की, कब आखिरी बार कन्फर्म की और कब बंद की।

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":[401958384,401958562,401959094]}'

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

JSON में जवाब: हर कीमत कितनी ताज़ा है
{
  "status": "ok",
  "data": [
    {
      "id": 401958562,
      "open": "2026-11-26T15:05:21",
      "seen": "2026-11-26T15:21:22",
      "closed": ""
    },
    {
      "id": 401959094,
      "open": "2026-11-26T15:05:21",
      "seen": "2026-11-26T15:21:22",
      "closed": ""
    }
  ],
  "time": "2026-11-26T15:21:23",
  "ms": "32us"
}
odds रो के फ़ील्ड्स
फ़ील्डमतलब
openWhen the bookmaker published this price.
seenWhen we last scanned and confirmed it.
closedWhen it disappeared, empty while still live.

सस्पेंड या बंद की गई कीमत odds के जवाब में बिल्कुल नहीं होती: यह फीड से हट जाती है, और closed इसके बंद होने का समय देता है।

जब API रुकने को कहे

429 आने पर, दोबारा पूछने से पहले Retry-After हेडर में दिए गए सेकेंड तक रुकें। अगर यह एक घंटे से ज़्यादा रुकने को कहे, तो नीचे दी गई स्क्रिप्ट रुक जाती है और API का ही मैसेज प्रिंट करती है। हर 5xx को अस्थायी मानें: रुकें, हर बार थोड़ा ज़्यादा समय लें, और फिर से पूछें। आपकी की (key) की लिमिट सर्विसेस पेज पर है।

एरर रेस्पॉन्स
HTTP स्टेटसमतलब
429Rate limit exceeded, 8 requests of your key already being answered, a Free key's requests for the month used up (until the 1st of the next month, UTC; the error field names the plans), Free keys busy together, or the service busy for a few seconds; check Retry-After and slow down. Retry-After: the seconds to wait before asking again, at most a day; the message names the day the month renews. Long id lists count as several requests against your per-minute limit: an odds request counts once for every 25 match ids, any other id list once for every 100 ids, and the counts multiply. One request can count as at most 40, and never as more than your key's limit for a minute.
502Feed service temporarily unavailable, retry with backoff.

एक ही स्क्रिप्ट में पोलिंग लूप

यह स्क्रिप्ट एक मैच की 1X2 कीमतें poll करती है, मिनट और स्कोर प्रिंट करती है, और हर कीमत के लिए बताती है कि यह कब आखिरी बार बदली और कब कन्फर्म हुई। यह आपकी की (key) को ODDFEEDS_KEY से पढ़ती है, मैच id को आर्गुमेंट की तरह लेती है, और जब तक ODDFEEDS_EVERY कुछ और न कहे, हर 10 सेकेंड में पूछती है: हर राउंड में दो रिक्वेस्ट।

// Poll the 1X2 prices of one match in play: the minute, the score, and for each
// price when it last changed and when it was last confirmed. Stop it with Ctrl+C.
//   ODDFEEDS_KEY=<your key> node in-play-polling.mjs <match id>
const API = process.env.ODDFEEDS_URL || 'https://oddfeeds.com/api/v1/feeds';
const matchId = Number(process.argv[2]);
const EVERY_S = Number(process.env.ODDFEEDS_EVERY || 10); // how often: yours to choose
const ROUNDS = Number(process.env.ODDFEEDS_ROUNDS || Infinity);
const SIDE = { 2: '1', 3: 'X', 4: '2' };
const sleep = (s) => new Promise((r) => setTimeout(r, s * 1000));
const ago = (utc) => Math.round((Date.now() - Date.parse(`${utc}Z`)) / 1000);

const MAX_WAIT_S = 3600; // a longer Retry-After ends the program

// The seconds a 429 or 5xx asks to wait: Retry-After in seconds or as a date;
// anything else (none, 0, a date gone by, text) gets our own wait, longer each time.
function waitOf(res, wait) {
  const v = (res.headers.get('Retry-After') || '').trim();
  const s = /^\d+$/.test(v) ? Number(v) : Math.ceil((Date.parse(v) - Date.now()) / 1000);
  return s >= 1 ? s : wait;
}

// One request; on 429 it waits the seconds of Retry-After, on a 5xx longer each time.
async function ask(body) {
  for (let wait = 2; ; wait = Math.min(wait * 2, 60)) {
    const res = await fetch(API, {
      method: 'POST',
      headers: {
        'Authorization': `Bearer ${process.env.ODDFEEDS_KEY}`,
        'Content-Type': 'application/json',
      },
      body: JSON.stringify(body),
    });
    if (res.status === 429 || res.status >= 500) {
      const s = waitOf(res, wait);
      if (s > MAX_WAIT_S) {
        const why = await res.json().then((f) => f.error, () => null);
        throw new Error(`${res.status}: ${why || `retry after ${s} s`}`);
      }
      console.log(`${res.status}: waiting ${s} s`);
      await sleep(s);
      continue;
    }
    const feed = await res.json();
    if (feed.status !== 'ok') throw new Error(`${res.status}: ${feed.error}`);
    return feed;
  }
}

for (let round = 1; round <= ROUNDS; round++) {
  const odds = await ask({
    scope: 'odds',
    match_ids: [matchId],
    odd_type_ids: [2, 3, 4],
    odd_period_ids: [1],
  });
  const rows = odds.data.inplay;
  const rt = rows[0]?.runtime;
  const play = rt ? `, ${rt.play.display}, ${rt.points.home}-${rt.points.away}` : '';
  console.log(`Round ${round}: ${rows.length} prices${play}`);
  if (rows.length) {
    const ids = rows.slice(0, 500).map((r) => r.id);
    const seen = await ask({ scope: 'odds_seen', odd_ids: ids });
    const seenAt = new Map(seen.data.map((s) => [s.id, s.seen]));
    for (const r of rows) {
      const changed = `changed ${ago(r.datetime)} s ago`;
      const at = seenAt.get(r.id);
      const confirmed = at ? `, confirmed ${ago(at)} s ago` : '';
      const price = `${r.bookmaker.name} ${SIDE[r.type_id]} ${r.price}`;
      console.log(`  ${price}: ${changed}${confirmed}`);
    }
  }
  if (round < ROUNDS) await sleep(EVERY_S);
}

आगे

In-play ट्रेडिंग यूज़ केस दिखाता है कि in-play ट्रेडर और क्या-क्या पढ़ता है, और डॉक्यूमेंटेशन के एरर्स हर एरर को लिस्ट करता है।

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

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