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 🙏

© 2024 – Pkg Stats / Ryan Hefner

nba-feeds

v1.0.28

Published

NBA feeds

Downloads

41

Readme

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)