Loading live scores...
SportsDatabase.io
Sign In
Developer experience

API code examples

Boot your integration with language-specific starter snippets that already include best practices for authentication, pagination, and error handling. Copy, paste, and deploy with production-ready defaults.

Consistent schemas

Every snippet returns the same typed payloads you will encounter in production. Promote prototypes to production without rewriting data access layers.

Pagination & filtering

Examples showcase core query parameters including pagination cursors, text search, and sport/league filters to keep responses lean.

Error-first handling

Each language demonstrates defensive patterns for rate limits, transport failures, and validation errors so you can ship resilient integrations.

Interactive terminal

Assemble a sample request

Choose your endpoint and language to generate a plug-and-play script plus a snapshot of the response payload.

Endpoint

Language

Node.js 18+ or modern browsers

Query tips

  • Supports `limit` (max 50)
  • Filter by `status=ACTIVE` or `status=LEGACY`
  • Combine with `/v1/leagues` for downstream joins
GET /v1/list/sports?limit=5JavaScript (fetch)

Grab the canonical sports catalog in order of popularity.

const API_KEY = process.env.SPORTSDB_API_KEY ?? '';

async function listSports(limit = 5) {
  const url = new URL('https://api.sportsdatabase.io/v1/list/sports');
  url.searchParams.set('limit', String(limit));

  const res = await fetch(url, {
    headers: { 'X-API-Key': API_KEY, Accept: 'application/json' }
  });

  if (!res.ok) {
    throw new Error(`Failed with status ${res.status}`);
  }

  const body = await res.json();
  return body.items;
}

listSports().then(console.log).catch(console.error);

What does limit= do? It caps the number of records returned per request so you can paginate predictably. Increase `limit` (up to 50) or follow `nextPageToken` to continue.

Sample responseStatic JSON
{
  "items": [
    {
      "id": "FOOTBALL",
      "name": "American Football",
      "status": "ACTIVE"
    },
    {
      "id": "BASKETBALL",
      "name": "Basketball",
      "status": "ACTIVE"
    },
    {
      "id": "BASEBALL",
      "name": "Baseball",
      "status": "ACTIVE"
    }
  ],
  "nextPageToken": null
}

Launch faster with production defaults

The examples above already include pagination cursors, timeouts, and friendly error handling. They are the same patterns we use in our internal automations, so you can trust them to scale from prototype to production.

  • Pagination helpers

    Sample utilities demonstrate iterating over `pageToken` responses to hydrate your local cache.

  • Rate limit awareness

    Back-off logic and retry hints keep your integration within the allotted burst windows.

  • Schema forward compatible

    Snippets leverage documented fields only, so upcoming schema additions do not break your builds.

Want these in your IDE?

We publish these examples as VS Code snippets and Postman collections. Download the bundle to explore advanced filters, webhook payloads, and mutation previews.

Download snippet bundle

Need a sandbox key?

Free Community accounts receive an API key instantly. Upgrade to Pro when you are ready for real-time webhooks, higher throughput, and historical depth.

Compare free vs. paid tiers

Explore the full reference

Dive into path-by-path details, schemas, and changelog notes that power these examples. Everything is generated from the same canonical dataset.

View API documentation