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 🙏

© 2025 – Pkg Stats / Ryan Hefner

nfl-game-data

v1.0.1

Published

Scrapes NFL game data from ESPN

Readme

NFL Game Data

Scrapes NFL game data from ESPN for the given team (abbreviation), season (year), game (week number), and season type ('pre', 'reg', 'post') and returns a model representing "play-by-play" data and "game details" of the form:

{
  plays: Object[],
  gameDetails: Object,
}

Disclaimer

As with all scrapers, this scraper is subject to break with any change in the response model sent back from ESPN.

There are some occasions where the play-by-play endpoint will return a one-off response that doesn't contain the model that the scraper's regex is expecting. So far I've only seen it with a single preseason game. I don't care enough to parse the raw HTML. Sorry! Fork this repo and enhance it if you'd like.

Usage

const NFLGameData = require("nfl-game-data");

// Set team (Seattle Seahawks) and season year (2018).
const nflGameData = new NFLGameData('sea', 2018);

/**
 * Fetch game data for game 3 of the regular season.
 *
 * HTTP Request count:
 *  1 (season data) + 1 game (for plays)
 */
nflGameData.getGame(3, 'reg').then((data) => {
  const { plays, gameDetails } = data;
  // Do something...
});

// Change team to New England Patriots
nflGameData.team = 'ne';
// Change season to 2017
nflGameData.season = 2017;

/**
 * Fetch game data for every game of the Regular Season
 *
 * HTTP Request count:
 *   1 (season data) + N games (plays for each game)
 */
nflGameData.getEveryGame('reg').then((regSeasonGames) => {
  regSeasonGames.forEach(({ plays, gameDetails }) => {
    // Do something...
  });
});

/**
 * Fetch game data for every game of every season type
 *
 * HTTP Request count:
 *  1 (season data) + N games (plays for each game) for each season
 */
nflGameData.getAllGames().then((allGames) => {
  const { preseason, regularSeason, postSeason } = allGames;
  regularSeason.forEach(({ plays, gameDetails }) => {
    // Do something...
  });
});

plays model

[
  {
    play: {
      period: [Object],
      homeScore: 0,
      awayScore: 0,
      start: [Object],
      text:
        "S.Janikowski kicks 66 yards from SEA 35 to DAL -1. D.Thompson to DAL 34 for 35 yards (A.Calitro, A.King).",
      clock: [Object],
      type: [Object]
    },
    homeWinPercentage: 0.519,
    playId: "40103079945",
    tiePercentage: 0,
    secondsLeft: 0
  }
  ...
];

gameDetails model

{ date:
   { date: '2018-09-23T20:25Z',
     format: 'ddd, MMM D',
     formatMobile: 'ddd, M/D',
     isTimeTBD: false },
  opponent:
   { id: '6',
     abbrev: 'DAL',
     displayName: 'Dallas Cowboys',
     logo: 'https://a.espncdn.com/i/teamlogos/nfl/500/dal.png',
     recordSummary: '',
     standingSummary: '',
     location: 'Dallas',
     links: '/nfl/team/_/name/dal/dallas-cowboys',
     homeAwaySymbol: 'vs',
     rank: '',
     neutralSite: false },
  time:
   { time: '2018-09-23T20:25Z',
     link: 'http://www.espn.com/nfl/game/_/gameId/401030799',
     state: 'post',
     tbd: false,
     format: 'h:mm A' },
  tickets: {},
  network: [ { name: 'FOX' } ],
  result:
   { winner: true,
     isTie: false,
     winLossSymbol: 'W',
     currentTeamScore: '24',
     opponentTeamScore: '13',
     link: 'http://www.espn.com/nfl/game/_/gameId/401030799' },
  timeAndNetwork:
   { time:
      { time: '2018-09-23T20:25Z',
        link: 'http://www.espn.com/nfl/game/_/gameId/401030799',
        state: 'post',
        tbd: false,
        format: 'h:mm A' },
     network: [ [Object] ] },
  record: '1-2',
  seasonType:
   { id: '2', type: 2, name: 'Regular Season', abbreviation: 'reg' },
  status:
   { id: '3',
     name: 'STATUS_FINAL',
     state: 'post',
     completed: true,
     description: 'Final',
     detail: 'Final',
     shortDetail: 'Final' },
  notes: {},
  competitionKey: 'STD',
  competitionName: 'Standard',
  week: { number: 3, text: 'Week 3', display: 3 },
  passingLeader:
   { athlete:
      { name: 'Russell Wilson',
        href: 'http://www.espn.com/nfl/player/_/id/14881/russell-wilson',
        lastName: 'Wilson' },
     value: 192 },
  rushingLeader:
   { athlete:
      { name: 'Chris Carson',
        href: 'http://www.espn.com/nfl/player/_/id/3919596/chris-carson',
        lastName: 'Carson' },
     value: 102 },
  receivingLeader:
   { athlete:
      { name: 'Tyler Lockett',
        href: 'http://www.espn.com/nfl/player/_/id/2577327/tyler-lockett',
        lastName: 'Lockett' },
     value: 77 },
  gameId: '401030799' }