Cricket Scorecard API JSON: Preserve Innings, Numbers, and Match State

Published October 29, 2026

responselastupdated is an integer on a cricket scorecard. On the live-match list the same idea is spelled responseLastUpdated and arrives as a string. One capital letter and one JSON type separate two payloads that a quick parser will treat as interchangeable, and JavaScript will not object: data.responseLastUpdated on a scorecard just returns undefined.

A recorded probe of match-details-get-scorecard with matchId=40381 returned HTTP 200 and five top-level keys: a scorecard array, a boolean ismatchcomplete, an appindex object, a string status and the integer above. This guide builds one adapter around those, using the Cricket Live Scores, Scorecards & Stats API. Sign in, copy an authorized key from the dashboard and read it from OPENDATA_API_KEY on a server; YOUR_API_KEY is a placeholder. The key travels in the query string, so keep those URLs out of logs and browser code. Opening this page or copying a snippet sends no request.

Walk scorecard as an array before choosing innings labels

Loop over scorecard and keep the order it arrives in. The spec's source example is truncated and unverified: its first entry shows ballnbr and a batsman list whose rows carry name, runs, balls, fours, sixes, strkrate and outdec, among others. Bowling, extras and fall-of-wicket sections were not visible, so the adapter does not reach for them.

It does not invent an innings number either. Array position becomes a local label, and the untouched entry rides along:

const innings = data.scorecard.map((raw, index) => ({ position: index + 1, raw }));

Promote position to "first innings" only after a multi-innings response from your own requests shows which field, if any, carries the number. In a Test the same side can bat twice in a row after a follow-on, so "team A, then team B" is not safe to infer from order. An empty array is a shape to handle; a missing or non-array scorecard is a different failure, and the adapter throws on it.

Keep ismatchcomplete and status outside the scorecard loop

Both fields describe the match, not an innings, so they sit on the parent object that the loop never touches. ismatchcomplete is the finished flag. status is display text whose possible values are not listed, so show it as returned instead of mapping it to a fixed set. A missing flag becomes null, meaning unknown; defaulting it to false would label a sparse body as a match in progress.

Status also exists at two levels, which is where HTTP-versus-business confusion starts. The gateway answers with an envelope of code, message and data, and HTTP 200 with a gateway code other than 200 is a failed call. Only when code is 200 does data.status, the match's own text, mean anything, and it says nothing about whether your request worked.

Read responselastupdated without borrowing the live list’s casing or type

On the scorecard the key is all lowercase and the value is an integer. On matches-live the key is responseLastUpdated and the value is a string. Property lookups are case-sensitive, so a shared helper reading one spelling from both payloads silently gets undefined from the other, and a helper that lowercases every key hides the difference. Comparisons are no kinder: "1700" === 1700 is false, so a cache that stores one type and compares against the other never sees a match.

Keep a separate reader per endpoint and treat the scorecard value as an opaque change marker. Its unit is not documented, so do not wrap it in new Date(), and read an unchanged marker as a cheap reason to skip a re-render, not proof that nothing changed.

Keep JSON numbers numeric in the JavaScript scorecard model

In the source example runs, balls, fours and sixes are integers, while strkrate is a string such as "154.55". Preserve both facts. When a present field has the wrong type, throw instead of coercing, so drift shows up in your logs rather than in a wrong total. Store the strike rate string the API sent and parse a copy only when you calculate. Number.isSafeInteger guards the update marker, where a very large integer could be silently rounded by JSON.parse.

// scorecard-adapter.mjs
function read(source, name, isType) {
  const value = source?.[name];
  if (value === undefined || value === null) return null;
  if (!isType(value)) throw new TypeError(`${name} has an unexpected type`);
  return value;
}

const isText = (v) => typeof v === "string";
const isFlag = (v) => typeof v === "boolean";
const isNumber = (v) => typeof v === "number" && Number.isFinite(v);
const isMarker = (v) => Number.isSafeInteger(v);

function adaptBatter(row) {
  return {
    name: read(row, "name", isText),
    runs: read(row, "runs", isNumber),
    balls: read(row, "balls", isNumber),
    strikeRate: read(row, "strkrate", isText), // keep the string the API sent
    dismissal: read(row, "outdec", isText),
  };
}

export function adaptScorecard(data) {
  if (!Array.isArray(data?.scorecard)) {
    throw new TypeError("scorecard must be an array; an empty array is valid");
  }
  return {
    complete: read(data, "ismatchcomplete", isFlag), // null means unknown
    statusText: read(data, "status", isText),
    updateMarker: read(data, "responselastupdated", isMarker),
    innings: data.scorecard.map((raw, index) => ({
      position: index + 1, // local order, not an API innings number
      batters: Array.isArray(raw?.batsman) ? raw.batsman.map(adaptBatter) : [],
      raw,
    })),
  };
}

The names batsman, strkrate and outdec come from the unverified example, so confirm them against a finished match before building a UI on them.

Carry matchId from match discovery into the scorecard request

The only input is matchId, and it comes from listing responses, not memory. matches-live groups matches under typeMatches; each group holds a seriesMatches array whose entries are either a series wrapper containing matches or a placeholder object to skip. A match's matchInfo.matchId is the value to forward. The same ID appears in schedule, series, team and venue responses, and matches-list takes live, recent or upcoming.

Node 18 or later provides fetch. Every parameter, matchId included, goes in the query string next to the key:

// scorecard-client.mjs
import { adaptScorecard } from "./scorecard-adapter.mjs";

const BASE = "https://api.opendata-api.com/api/project/cricbuzz-cricket";

async function call(operation, params = {}) {
  const url = new URL(`${BASE}/${operation}`);
  for (const [name, value] of Object.entries({ ...params, key: process.env.OPENDATA_API_KEY })) {
    url.searchParams.set(name, String(value));
  }
  const response = await fetch(url, { signal: AbortSignal.timeout(30_000) });
  if (response.status === 204) return null; // no content is an empty state, not an error
  if (!response.ok) throw new Error(`HTTP ${response.status}`);
  const envelope = await response.json();
  if (envelope.code !== 200) throw new Error(`Gateway code ${envelope.code}`);
  return envelope.data;
}

export function liveMatchIds(liveData) {
  const ids = [];
  for (const group of liveData?.typeMatches ?? []) {
    for (const entry of group.seriesMatches ?? []) {
      for (const match of entry.seriesAdWrapper?.matches ?? []) {
        const id = match.matchInfo?.matchId;
        if (id !== undefined) ids.push(id);
      }
    }
  }
  return ids;
}

export async function loadScorecard(matchId) {
  return adaptScorecard(await call("match-details-get-scorecard", { matchId }));
}

The Hundred has its own match-details-get-scorecard-hundred operation taking the same ID. Its example is unverified, so do not assume identical fields.

Test empty and multi-innings arrays with explicitly synthetic fixtures

No recorded empty or multi-innings scorecard is shown here. The fixtures below are hand-written to exercise the parser; every name and number in them is invented.

// scorecard-adapter.test.mjs
import test from "node:test";
import assert from "node:assert/strict";
import { adaptScorecard } from "./scorecard-adapter.mjs";

// SYNTHETIC fixtures: hand-written, not recorded from any match.
const base = { ismatchcomplete: false, status: "Synthetic status", responselastupdated: 1001 };
const empty = { ...base, scorecard: [] };
const twoEntries = {
  ...base,
  ismatchcomplete: true,
  scorecard: [
    { batsman: [{ name: "Synthetic Batter", runs: 12, balls: 9, strkrate: "133.33", outdec: "not out" }] },
    { batsman: [] },
  ],
};

test("an empty scorecard array is valid", () => {
  const card = adaptScorecard(empty);
  assert.equal(card.innings.length, 0);
  assert.equal(card.complete, false);
});

test("entry order and numeric types survive", () => {
  const [first] = adaptScorecard(twoEntries).innings;
  assert.equal(first.position, 1);
  assert.equal(first.batters[0].runs, 12);
  assert.equal(first.batters[0].strikeRate, "133.33");
});

test("a wrong type throws and the live list's casing is not an alias", () => {
  assert.throws(() => adaptScorecard({ ...twoEntries, responselastupdated: "1001" }), TypeError);
  const { responselastupdated, ...rest } = twoEntries;
  assert.equal(adaptScorecard({ ...rest, responseLastUpdated: "1001" }).updateMarker, null);
});

Stop at the scorecard boundary: commentary, coverage and refresh timing

This operation takes only matchId. It has no innings, team or player filter, so commentary for one innings or one player belongs to other routes: match-details-get-commentaries accepts iid and a tms paging cursor, and the player variant requires iid, playerId and a type of batting or bowling. For a compact state rather than batting rows, match-details-get-miniscorecard is a lighter read than the full scorecard.

Coverage depends on the match. An upcoming or abandoned fixture may return a sparse body, and bowling figures, extras and fall of wickets are not confirmed here. No refresh cadence is documented and the marker's unit is unspecified, so choose a polling interval from your own needs, stop once ismatchcomplete is true, and do not read the marker as a clock. Before production, confirm that the competitions you serve are covered and that you may display and store the data, because HTTP 200 answers neither question.