JavaScript quickstart — KickoffAPI v2

Fetch-based patterns for Node 18+ and browsers: live scores, fixtures, cursor pagination and error handling against https://api.kickoffapi.com/api/v2.

1. Your first call

const API = "https://api.kickoffapi.com/api/v2";
const KEY = "your_key"; // free at https://kickoffapi.com/pricing.html

const res = await fetch(`${API}/fixtures?limit=3`, {
  headers: { "x-api-key": KEY },
});
if (!res.ok) throw new Error(`KickoffAPI ${res.status}`);
const { data, meta } = await res.json();

for (const fx of data) {
  console.log(fx.homeTeam.name, "vs", fx.awayTeam.name, "-", fx.date);
}
// Every response uses one envelope: {"data": [...], "meta": {...}}

2. Pagination (cursor)

async function allFixtures(status = "FT", maxPages = 5) {
  const out = [];
  let cursor;
  for (let i = 0; i < maxPages; i++) {
    const p = new URLSearchParams({ limit: "100", status });
    if (cursor) p.set("cursor", cursor);
    const res = await fetch(`${API}/fixtures?${p}`, { headers: { "x-api-key": KEY } });
    if (!res.ok) throw new Error(`KickoffAPI ${res.status}`);
    const { data, meta } = await res.json();
    out.push(...data);
    cursor = meta.cursor;
    if (!cursor) break;
  }
  return out;
}

2b. Browser note (keys)

Call KickoffAPI from a server route or serverless function and proxy to the browser: keys in front-end bundles are public by definition. The Node examples above run as-is.

3. Two error responses worth handling

{"error":"Missing x-api-key header for path: /api/v2/fixtures","code":"MISSING_API_KEY"}
{"error":"Invalid API key","code":"INVALID_API_KEY"}

4. Respect the two rate-limit windows

res.headers.get("X-RateLimit-Remaining");       // per-minute window
res.headers.get("X-RateLimit-Daily-Remaining");  // per-day window

Free tier: 30/minute, 100/day. A 5-minute TTL cache keeps one free key comfortable — the full pattern is walked through in the JavaScript integration tutorial.

5. Next steps

Full endpoint list: v2 reference. Prefer an MCP client? See the MCP server page.

Verified: the two error responses below were captured from the live API. Request and response shapes follow the v2 reference; run the examples yourself with a free key — Hobby plan, 100 requests/day, no card.