npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@sportsdatabase/sdk

v0.0.2

Published

Official TypeScript SDK for SportsDatabase.io

Readme

SportsDatabase TypeScript SDK

Official TypeScript client for SportsDatabase.io, providing typed access to leagues, teams, events, schedules, scores, and more with first-class pagination helpers and error handling.

Installation

npm install @sportsdatabase/sdk
# or
yarn add @sportsdatabase/sdk

Quick Start

import { SportsDatabaseClient } from '@sportsdatabase/sdk';

const client = new SportsDatabaseClient({
  apiKey: process.env.SPORTSDB_API_KEY!,
  baseUrl: 'https://api.sportsdatabase.io/v1'
});

const games = await client.events.getByDate({ sport: 'soccer', date: '2025-05-01' });
console.log(games.data.map((event) => `${event.homeTeamId} vs ${event.awayTeamId}`));

ELI5: Getting Started Fast

  1. Install the package – run npm install @sportsdatabase/sdk.
  2. Grab your API key – copy it from the SportsDatabase portal.
  3. Create the client – drop this snippet into your app:
    import { SportsDatabaseClient } from '@sportsdatabase/sdk';
    
     const client = new SportsDatabaseClient({ apiKey: 'YOUR_KEY' });
  4. Make a call – try client.leagues.list({ sportSlug: 'soccer' }) and log the data.
  5. Handle pagination – if meta.nextCursor exists, pass it back in cursor to fetch the next page (or use client.events.iterate to do it for you).
  6. Watch rate limits – every response includes meta.rateLimit and meta.requestId, so log them when debugging.
  7. Avoid surprises – wrap calls in try/catch and check for ApiError, RateLimitError, or NetworkError to show friendly messages.

If you can run node sample.js and see JSON printed, you’re good to explore deeper endpoints.

Configuration

| Option | Type | Default | Description | |-------------------|----------|-----------------------------------|----------------------------------------------------| | apiKey | string | required | API key from the SportsDatabase portal | | baseUrl | string | https://api.sportsdatabase.io/v1| Override for staging/self-hosted deployments | | timeoutMs | number | 10_000 | Request timeout in milliseconds | | maxRetries | number | 2 | Automatic retries for 429/5xx responses | | userAgentSuffix | string | '' | Extra identifier appended to SDK user-agent |

Endpoints Overview

  • client.sports (coming soon) — list available sports.
  • client.leagues.list({ sportSlug, status })
  • client.teams.list({ leagueId, season })
  • client.events.list({ sport, league, date, status })
  • client.events.iterate(...) — async iterator over paginated events.
  • client.schedules.teamNext({ teamId }), client.schedules.iterateLeagueSeason(...)
  • client.scores.getByEvent(eventId) — latest score snapshot.

Each method returns a typed response with data and meta (including rate-limit headers and request ID).

Pagination Helpers

Use client.events.iterate() or the exported helpers:

import { iterateItems } from '@sportsdatabase/sdk';

const iterator = iterateItems(client.events.list.bind(client.events), {
  initialParams: { sport: 'basketball', limit: 50 }
});

for await (const event of iterator) {
  // consume pages transparently
}

Error Handling

Errors extend SportsDatabaseError and include:

  • ApiError — non-2xx responses with status, code, details.
  • RateLimitError — 429 responses with resetAt.
  • NetworkError — network failures after retry attempts.
try {
  await client.events.getById('evt_123');
} catch (error) {
  if (error instanceof RateLimitError) {
    console.log(`Retry after ${error.resetAt}`);
  }
}

Examples

| Script | Description | |--------------------------|-------------------------------------| | examples/get_today_events.ts | Fetches today's soccer events | | examples/list_leagues.ts | Lists active leagues for a sport | | examples/smoke_test.ts | Integration smoke script |

Run via tsx/ts-node or compile with tsc.

Development

npm install
npm run lint
npm run test

CI runs linting, type-checking, and tests via GitHub Actions (.github/workflows/ci.yml).

Versioning

This SDK follows semantic versioning and mirrors major/minor releases of the public API:

  • MAJOR version only changes when the API introduces breaking changes that require SDK adjustments.
  • MINOR bumps ship new endpoints or fields that are backward-compatible.
  • PATCH releases contain bug fixes or documentation updates.

Publish from a clean tree after running npm run lint, npm run test, and npm run build, then npm publish --access public.

License

MIT © SportsDatabase.io