Most football app projects die between "I got an API key" and "it's running in production." The gap is four unglamorous problems: pagination, error handling, rate limits, and caching. This walkthrough closes all four in JavaScript — from your first request to a service you can leave running. The patterns are framework-agnostic; drop the client into Next.js, Express, a worker, or a plain script.
1. First request, and the one envelope you need to know
Every v2 endpoint answers with the same shape: a data array plus a meta object. Learn one response, parse them all:
curl -G "https://api.kickoffapi.com/api/v2/fixtures" \
-d "limit=3" \
-H "x-api-key: $KICKOFF_API_KEY"
{
"data": [ /* fixtures */ ],
"meta": { "count": 3, "cursor": 0, "nextCursor": "3", "source": "canonical" }
}
Without a key you get a precise error, which your app should treat as a configuration failure, not a retry case:
{"error":"Missing x-api-key header for path: /api/v2/fixtures","code":"MISSING_API_KEY"}
2. Pagination: follow the cursor, not the page number
The v2 API paginates with cursors, not offsets. Offsets break when rows are inserted; cursors don't. Loop until meta.nextCursor disappears:
async function allFixtures(api, pageSize = 100) {
const out = [];
let cursor;
do {
const page = await api.fixtures({ limit: pageSize, cursor });
out.push(...page.data);
cursor = page.meta.nextCursor;
} while (cursor);
return out;
}
One caveat from production: don't backfill your entire database in a single loop. Batch it — a few hundred records per pass, scheduled — so a full traversal never collides with your per-minute rate budget.
3. Or use the SDK and skip the plumbing
The official JavaScript SDK wraps the envelope, the cursor loop and the headers:
import { KickoffAPI } from "./kickoffapi.js";
const api = new KickoffAPI("YOUR_API_KEY");
const { data, meta } = await api.fixtures({ limit: 10 });
console.log(data.length, meta.nextCursor);
The SDK is served from the docs site (kickoffapi.js) — download it, commit it to your repo, and pin the version. It is plain JavaScript with no build step, so it runs in Node, workers, and the browser.
4. Error handling: the three cases that cover everything
| Case | Response | Correct behaviour |
|---|---|---|
| Config error | MISSING_API_KEY / INVALID_API_KEY | Fail fast. Alert. Never retry. |
| Rate limit | 429 with rate-limit headers | Back off by the returned window; halve your cadence |
| Transient (5xx / network) | non-200, timeout | Retry with jitter, max 3 attempts |
Read the rate-limit headers on every response and log them. Your integration should know its remaining budget instead of discovering it via 429s — the cadence strategy behind this is in our rate-limits guide.
5. Caching: the cheapest scalability feature
Football data has natural TTLs. Standings change weekly, finished matches never change again, and only in-play fixtures need short caches. Match your cache TTL to the data's real change rate and a free tier comfortably serves a production app with on-demand traffic:
const TTL = { live: 15_000, upcoming: 300_000, finished: 86_400_000 };
const cache = new Map();
async function cached(key, ttl, fn) {
const hit = cache.get(key);
if (hit && Date.now() - hit.at < ttl) return hit.value;
const value = await fn();
cache.set(key, { at: Date.now(), value });
return value;
}
Three TTLs, one helper — this is the entire caching layer. The deeper stampede defense (single-flight, SWR) is in the live-score architecture guide.
Summary
Cursor pagination, three-case error handling, TTL caching — that is the whole production checklist, and none of it is football-specific. Grab a free key, run the SDK quickstart, and your first real data is one request away: free Hobby tier, no card. When you outgrow on-demand traffic, the paid plans raise the daily volume; the code above does not change.