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

@alex-kaffetzakis/espn-api

v0.2.0

Published

TypeScript client for ESPN's public API (site, core, web, cdn, now, fantasy).

Downloads

263

Readme

@alex-kaffetzakis/espn-api

A TypeScript client for ESPN's public API.

Fork notice: This is a fork of mikelaferriere/espn-api, significantly expanded to cover additional ESPN domains (site, core, web, cdn, now, fantasy) with a shared HTTP client, typed errors, and exhaustive types. Published independently on npm as @alex-kaffetzakis/espn-api.

Install

npm install @alex-kaffetzakis/espn-api

Quick start

import { Scoreboard, Summary, League } from '@alex-kaffetzakis/espn-api'

const scoreboard = await Scoreboard.fetch(League.NFL)
const summary = await Summary.fetch(League.NFL, scoreboard.events[0].id)

Configuring the client

All endpoints share a default HTTP client. You can configure timeouts and retries, or swap in your own Axios instance:

import { setDefaultClient, EspnClient } from '@alex-kaffetzakis/espn-api'

setDefaultClient(new EspnClient({ timeout: 15_000, retries: 3 }))

Bring your own HTTP client

Every endpoint ships a pure URL builder alongside its fetch* helper. Use it when you'd rather hand URLs to your own HTTP client (fetch, got, undici, etc.) instead of the bundled axios transport:

import { LeagueData, BASE_URLS, League } from '@alex-kaffetzakis/espn-api'

const { domain, path } = LeagueData.injuriesUrl(League.NBA)
const data = await myClient.get(`${BASE_URLS[domain]}/${path}`)

URL builders are pure — they take the same arguments as the matching fetch* helper (minus the client) and return { domain, path, params? }. BASE_URLS maps each domain to its base URL.

Every fetch* helper also accepts an optional EspnClient as its last argument, so you can route specific calls through a custom-configured client without replacing the default:

import { Scoreboard, EspnClient, League } from '@alex-kaffetzakis/espn-api'

const custom = new EspnClient({ timeout: 5_000 })
const sb = await Scoreboard.fetch(League.NFL, undefined, custom)

Error handling

import {
  Summary,
  League,
  EspnNotFoundError,
  EspnRateLimitError,
  EspnApiError,
} from '@alex-kaffetzakis/espn-api'

try {
  await Summary.fetch(League.NFL, 'bad-event-id')
} catch (err) {
  if (err instanceof EspnNotFoundError) {
    // 404
  } else if (err instanceof EspnRateLimitError) {
    // 429
  } else if (err instanceof EspnApiError) {
    // other HTTP / network errors
  }
}

Covered APIs

  • Site v2 — scoreboard, summary, teams, league, athletes
  • Core v2/v3 — events, athletes, metadata, college, bracketology
  • Web — search
  • CDN — games
  • Now — news
  • Fantasy — league

See lib/index.ts for the full list of exports.

Development

npm install
npm run build
npm test

Live integration tests (off by default) hit the real ESPN API:

ESPN_INTEGRATION=true npm test

Publishing (maintainer)

Releases are cut manually from a clean working tree.

# 1. Bump the version and CHANGELOG.md, commit
npm version <patch|minor|major>   # creates the commit + tag

# 2. Log in to npm (once per machine)
npm login

# 3. Publish. prepublishOnly runs lint + tests + build first.
npm publish --access public

# 4. Push the commit and tag
git push && git push --tags

prepublishOnly in package.json runs npm run lint && npm test && npm run build before the publish goes out, so a broken tree won't ship.

License

MIT — see LICENSE.md. Original copyright held by Michael Laferriere; fork modifications by Alex Kaffetzakis.

Disclaimer

Not affiliated with ESPN. This library wraps ESPN's undocumented public endpoints; please use responsibly and respect ESPN's terms of service.