nba-feeds

1.0.28 • Public • Published

NBA Feeds

Asynchronously fetch data from mobile stat feed, content API, and stats.nba.com.

Install

npm install nba-feeds

Usage

<!-- Browser -->
<script src="path/to/nba-feeds.js"></script>
<script>
      var nba = nbaFeeds(contentApiTokenGoesHere);
</script>
// CommonJS
const nbafeeds = require(`nba-feeds`);
const nba = nbaFeeds(contentApiTokenGoesHere);

// ES6 Imports 
import nbaFeeds from `nba-feeds`;
const nba = nbaFeeds(contentApiTokenGoesHere);
Examples
// Return current league standings
const standings = await nba.stats.standings();
console.log(standings)

// Return league standings from 2015
const standings = nba.stats.standings({seasonYear: 2015});

// Return player highs
const playerHighs = await nba.stats.playerHighs(201142);
console.log(playerHighs)

Mobile Stats

Default values:

league: 'nba'
leagueId: Drupal.settings.today.league_id
teamName: Drupal.settings.team.CODE
seasonYear: Drupal.settings.today.season_year
seasonTypeId: Drupal.settings.today.season_stage
monthNumber: Drupal.settings.today.sys_month

The final parameter of each feed call is an object that can be used to override the default values above. For example: nba.stats.standings({seasonYear: 2015});

The following parameters must be specified:

statType
gameId
playerId

Today's Scores
Description...
This is a real time update for every game that plays on the current day for the designated league. Initially generated on game day, it will contain all the games for the day and will be updated with scores in real time. Last meeting is included in this feed. This will refresh at noon with the games for the upcoming day/night. For days with no games (Thanksgiving, Christmas Eve), the contents will be just the gs element. If a game occurs before noon, the file will be created when that game’s events are logged.

todaysScores({league, seasonYear, leagueId})
Full Game Play by Play
Description...
This feed contains play by play data by period (including overtimes) for each game, and updates in real time during live games.

fullGamePlayByPlay(gameId, quarter, {league, seasonYear})
Abbreviated Play by Play
Description...
This feed contains abbreviated play by play list: The last 20 events before current point in the game are provided. These events can go across quarters. This updates real time during live games.

abbreviatedPlayByPlay(gameId, {league, seasonYear})
Game Detail
Description...
This feed contains the full boxscore for a game. Updates occur in real time during live games. NOTE: Removed from this feed are the team season averages. This can now be found in a separate feed. The Last Meeting information has also been moved out of this feed and into the Team Schedule feed.

gameDetail(gameId, {league, seasonYear})
Standings
Description...
This feed is produced when standings are available for the given season for the designated league. Updated every time a game ends, or standings are changed. This feed is only generated for preseason and regular season.

standings({league, seasonYear, leagueId})
Playoff Bracket
Description...
This feed contains a representation of the tournament for the playoffs. It is updated after each game. No playoff bracket exists for either summer league due to all games being considered part of the regular season (the playoff games just continue counting up for game id after the play-in games are complete). The D League also does not currently have a playoff bracket. The game elements in the playoff bracket differ from other schedule feeds in that the home/visitor nodes do not contain a record attribute. Instead this information can be gleaned from the series (‘ser’) element. Additionally, the series information (‘seri’) on the game is also removed as there is a series info (‘seri’) attribute on the series (‘ser’) element.

playoffBracket({league, seasonYear, leagueId})
Team Info
Description...
This has information on all regular season teams, even during the playoffs. During the preseason, any international teams will show up.

teamInfo({league, seasonYear, leagueId})
Player Info
Description...
This feed contains information on all players and the teams that they have been on during the current season. It is updated daily.

playerInfo({league, seasonYear, leagueId})
All Time Leaders
Description...
The all-time leaders files are generate for various statistical categories and contain the career totals and per game leaders for the entire league history. A separate player card file is generated for each season type.

allTimeLeaders(statType, seasonTypeId, {league, seasonYear, leagueId})
All Time Players
Description...
This feed contains an entry for every player that has played in the given league. It contains the start and end years, as well as whether the player is currently active.

allTimePlayers({league, seasonYear, leagueId})
League Leaders
Description...
The league leaders files are generate for various statistical categories and contain the league totals and per game leaders for the season. A separate league leader file is generated for each season type.

leagueLeaders(statType, {league, seasonYear, leagueId, seasonTypeId})
Team Schedule
Description...
This feed contains the full schedule for each team, and is provided when the schedule is released and updated when any scheduling changes occur. This file is updated after a game finishes with the Final score of the game. A separate schedule file is generated for each season type with suffixes as follows. Additionally, one file without a suffix is created for each non-allstar teams that has games from each season type. For an eventual playoff team, it will have preseason, regular season, and playoff games. A team that missed the playoffs would have preseason and regular season.

teamSchedule({league, seasonYear, teamName, seasonTypeId})
League Schedule
Description...
These feeds contain the full schedule for the entire league for all season types. The schedule is broken into twelve month files per season year. If there are no games for a given month, the file will still exist, but be an empty root element. When multiple season types (pre and regular season, regular season and all-star, regular season and post season) have games in the same month, they will both appear in the one file, sorted by date. The month number will always be two digits representing the calendar month, so January maps to 01 and December maps to 12. For leagues where the season goes over two calendar years (NBA and D League), the January file under 2014 season will actually be games played in January, 2015 (and so forth for the other applicable months). Games that are no longer necessary in the playoffs are removed from the feed.

leagueSchedule({league, seasonYear, leagueId, monthNumber})
Rolling Daily Schedule
Description...
This feed contains all played and un-played games for the current date and a given number of days past and future. It spans across all season types and across months. Games that are no longer necessary in the playoffs are removed from the feed. Days out currently set to five days in either direction.

rollingDailySchedule({league, seasonYear, leagueId})
Team Roster
Description...
This feed updates when roster changes are produced, and overnight. Years of experience typically updates on the night of the NBA draft when rosters are posted. All-star rosters are produced for east/west and rookie/sophomore teams.

teamRoster(teamName, {league, seasonYear})
Team Coach
Description...
This feed updates when roster changes are produced, and overnight. It includes only active coaches. Coach feeds are available for regular all-star and rookie-sophomore teams based on team name.

rollingDailySchedule(teamName, {league, seasonYear})
Team Player Averages
Description...
This feed contains the players on a team in a given season type and has each player’s per game averages and totals for various stats. It is updated after every game night. A separate team season averages file is generated for each season type.

teamPlayerAverages(teamName, {league, seasonYear, seasonTypeId})
Team Statistics
Description...
This feed is updated after every game night. All stats are per game for the team overall. A separate statistics file is generated for each season type.

teamStatistics(teamName, {league, seasonYear, seasonTypeId})
Team Leaders Overall File
Description...
This feed shows team leaders in points, assists, rebounds, field goals, free throws, three pointers, blocks, steals and turnovers. It is updated after every game night. A separate team leaders overall file is generated for each season type.

teamLeadersOverallFile(teamName, {league, seasonYear, seasonTypeId})
Team Leaders Detail Stats
Description...
This feed is updated after every game night. A separate file is generated for each stat and each season type.

teamLeadersDetailStats(teamName, statType, {league, seasonYear, seasonTypeId})
Team Season Averages
Description...
This feed contains information that was formerly in the game detail feed. It is updated after every game night. A separate team season averages file is generated for each stat and each season type.

teamSeasonAverages(teamName, {league, seasonYear, seasonTypeId})
Advanced Team And Player Stats
Description...
This feed contains advanced team and player statistics in per 36 minute increments. There are no qualifiers for players on the values. Players can appear in more than one team’s file as the stats displayed are only those gained while on said team. There is a roster status attribute to ignore said players if desired.

advancedTeamAndPlayerStats(teamName, {league, seasonYear, seasonTypeId})
Player Cards
Description...
The Player cards are available for preseason, regular season, and playoffs. Season Year has been added to the URL format, so that you can get player cards for previous seasons. Game logs are also included. A separate player card file is generated for each season type.

playerCards(playerId, {league, seasonYear, seasonTypeId})
Player Ranks
Description...
The Player ranks files are available for preseason, regular season, and playoffs. It includes a player’s ranks and values for various statistical categories. It has ranks for totals, per game averages and per minute. The per minute stat values are per forty minutes for WNBA and per forty eight minutes for all others. A separate player card file is generated for each season type.

playerRanks(playerId, {league, seasonYear, seasonTypeId})
Player Splits
Description...
The Player splits are available for preseason, regular season, and playoffs. It includes breakdown of totals and per game averages for various statistical categories based on various split categories and the corresponding splits within. A separate player split file is generated for each season type.

playerSplits(playerId, {league, seasonYear, seasonTypeId})
Player Highs
Description...
The Player highs files are available for preseason, regular season, and playoffs. It includes a player’s career and season highs in various statistical categories. If the value is non-zero, it contains a list of the games it occurred. A separate player highs file is generated for each season type.

playerHighs(playerId, {league, seasonYear, seasonTypeId})

Content API

Feed documentation

Allowed parameters:

freeform games gameRelated writer players teams topics events streamState channels section body headline shortHeadline subheadline title description url before after lang sort offset count verbose

Example Usage
// Get the last 50 Celtics videos
nba.content(`celtics`, { count: 50 , type: 'video'})

// Get the last 10 Celtics articles tagged with 'Keys To The Game' published after 4/13/2018
nba.content(`celtics`, {
      freeform: ['Keys To The Game'],
      types: ['article'],
      count: 10,
      after:  1523664000
});

Value Key

Season Type ID

  • 01 – Preseason
  • 02 – Regular Season
  • 03 – All-star
  • 04 – Playoffs

League ID

  • 00 – NBA
  • 10 – WNBA
  • 14 – NBA Orlando Summer League
  • 15 – NBA Las Vegas Summer League
  • 16 – NBA Utah Summer League (Rocky Mountain Revue)
  • 20 – NBA Developmental League

League Name

  • NBA (00): nba
  • WNBA (10): wnba
  • NBA Orlando Summer League (14): orlando
  • NBA Las Vegas Summer League (15): vegas
  • NBA Utah Summer League (Rocky Mountain Revue) (16): utah
  • NBA Developmental League (20): dleague

Cache Control Values

  • 5s – five seconds
  • 10s – ten seconds
  • 30s – thirty seconds
  • 1m – one minute (sixty seconds)
  • 1h – one hour (3,600 seconds)

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.0.281latest

Version History

VersionDownloads (Last 7 Days)Published
1.0.281
1.0.270
1.0.261
1.0.250
1.0.240
1.0.230
1.0.220
1.0.210
1.0.200
1.0.190
1.0.170
1.0.160
1.0.140
1.0.130
1.0.120
1.0.110
1.0.100
1.0.90
1.0.80
1.0.50
1.0.40
1.0.30
1.0.20
1.0.10
1.0.00

Package Sidebar

Install

npm i nba-feeds

Weekly Downloads

2

Version

1.0.28

License

MIT

Unpacked Size

55.3 kB

Total Files

7

Last publish

Collaborators

  • kylepg