1.0.28 • Published 4 years ago

nba-feeds v1.0.28

Weekly downloads
2
License
MIT
Repository
-
Last release
4 years ago

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
todaysScores({league, seasonYear, leagueId})
Full Game Play by Play
fullGamePlayByPlay(gameId, quarter, {league, seasonYear})
Abbreviated Play by Play
abbreviatedPlayByPlay(gameId, {league, seasonYear})
Game Detail
gameDetail(gameId, {league, seasonYear})
Standings
standings({league, seasonYear, leagueId})
Playoff Bracket
playoffBracket({league, seasonYear, leagueId})
Team Info
teamInfo({league, seasonYear, leagueId})
Player Info
playerInfo({league, seasonYear, leagueId})
All Time Leaders
allTimeLeaders(statType, seasonTypeId, {league, seasonYear, leagueId})
All Time Players
allTimePlayers({league, seasonYear, leagueId})
League Leaders
leagueLeaders(statType, {league, seasonYear, leagueId, seasonTypeId})
Team Schedule
teamSchedule({league, seasonYear, teamName, seasonTypeId})
League Schedule
leagueSchedule({league, seasonYear, leagueId, monthNumber})
Rolling Daily Schedule
rollingDailySchedule({league, seasonYear, leagueId})
Team Roster
teamRoster(teamName, {league, seasonYear})
Team Coach
rollingDailySchedule(teamName, {league, seasonYear})
Team Player Averages
teamPlayerAverages(teamName, {league, seasonYear, seasonTypeId})
Team Statistics
teamStatistics(teamName, {league, seasonYear, seasonTypeId})
Team Leaders Overall File
teamLeadersOverallFile(teamName, {league, seasonYear, seasonTypeId})
Team Leaders Detail Stats
teamLeadersDetailStats(teamName, statType, {league, seasonYear, seasonTypeId})
Team Season Averages
teamSeasonAverages(teamName, {league, seasonYear, seasonTypeId})
Advanced Team And Player Stats
advancedTeamAndPlayerStats(teamName, {league, seasonYear, seasonTypeId})
Player Cards
playerCards(playerId, {league, seasonYear, seasonTypeId})
Player Ranks
playerRanks(playerId, {league, seasonYear, seasonTypeId})
Player Splits
playerSplits(playerId, {league, seasonYear, seasonTypeId})
Player Highs
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)
1.0.28

4 years ago

1.0.27

4 years ago

1.0.26

4 years ago

1.0.25

4 years ago

1.0.24

5 years ago

1.0.23

6 years ago

1.0.22

6 years ago

1.0.21

6 years ago

1.0.20

6 years ago

1.0.19

6 years ago

1.0.17

6 years ago

1.0.16

6 years ago

1.0.14

6 years ago

1.0.13

6 years ago

1.0.12

6 years ago

1.0.11

6 years ago

1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago