stats

package module
v0.5.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 3, 2024 License: MIT Imports: 9 Imported by: 4

README

stats

golang library for scraping nba stats from data.nba.net api's, normalizing this data, and provides a set of analysis functions. stats also leverages redis to persist data.

dependencies

  • go build

Documentation

Index

Constants

View Source
const (
	APP_NAME    = "stats"
	APP_STORAGE = "nba"
	APP_VERSION = "1.1"
)
View Source
const (
	ESPN_BASE_URL            = `https://www.espn.com`
	ESPN_SCOREBOARD_URL      = `https://espn.com/nba/scoreboard`
	ESPN_SCOREBOARD_DATE_URL = `https://espn.com/nba/scoreboard/_/date/%s`
	ESPN_BOXSCORE_URL        = `https://www.espn.com/nba/boxscore?gameId=`
	ESPN_PLAYER_ICON_URL     = `https://a.espncdn.com/combiner/i?img=/i/headshots/nba/players/full/%s.png&h=80&w=110&scale=crop`
	ESPN_TEAM_ICON_URL       = `https://a.espncdn.com/i/teamlogos/nba/500/%s.png`
)
View Source
const (
	ESPN_SCOREBOARD_EVENTS_ID = "events"
	ESPN_BOXSCORE_ID          = "gamepackage-box-score"
	ESPN_TEAM_NAME_CLASS      = "team-name"
)
View Source
const (
	//NBA_BASE_URL									= "https://data.nba.net/data/10s/prod/v1"
	NBA_BASE_URL     = "https://cdn.nba.com/static/json"
	NBA_STATIC       = "/staticData"
	NBA_SCHEDULE     = "/scheduleLeagueV2_9.json"
	NBA_LIVE         = "/liveData"
	NBA_API_BOXSCORE = "/boxscore/boxscore_%s.json"
	NBA_API_PLAYS    = "/playbyplay/playbyplay_%s.json"
	//NBA_API_BOXSCORE							= "/%s/%s_boxscore.json"
	NBA_API_PLAYERS        = "/%s/players.json"
	NBA_API_PLAYER_PROFILE = "/%s/players/%s_profile.json"
	//NBA_API_PLAYS            			= "/%s/%s_pbp_%d.json"
	NBA_API_ROSTER = "/%s/teams/%s/roster.json"
	//NBA_API_SCOREBOARD            = "/%s/scoreboard.json"
	NBA_API_TODAYS_SCOREBOARD = "/scoreboard/todaysScoreboard_00.json"
	NBA_API_STANDINGS         = "/current/standings_all.json"
	NBA_API_TEAMS             = "/%s/teams.json"
	NBA_API_TEAM_RANKS        = "/%s/team_stats_rankings.json"
)
View Source
const (
	NBA_LEGACY_BASE_URL     = "https://data.nba.com/data/10s/v2015/json/mobile_teams/nba"
	NBA_LEGACY_API_SCHEDULE = "/%s/league/00_full_schedule.json"
)
View Source
const (
	PRESEASON = 0
	REGULAR   = 1
	PLAYOFFS  = 2
)
View Source
const (
	HTML_ANCHOR     = "a"
	HTML_ARTICLE    = "article"
	HTML_ATTR_CLASS = "class"
	HTML_ATTR_HREF  = "href"
	HTML_ATTR_ID    = "id"
	HTML_DIV        = "div"
	HTML_SCRIPT     = "script"
	HTML_SPAN       = "span"
	HTML_TABLE      = "table"
	HTML_TBODY      = "tbody"
	HTML_TD         = "td"
	HTML_TR         = "tr"
)
View Source
const (
	MATCH_BOXSCORE    = `/nba/game?gameId=`
	MATCH_BOXSCORE_RE = "gameId=[0-9]+}"
)
View Source
const (
	STRING_COLON        = ":"
	STRING_EMPTY        = ""
	STRING_EQUAL        = "="
	STRING_MINUS        = "-"
	STRING_NA           = "--"
	STRING_PERIOD       = "."
	STRING_SINGLE_QUOTE = "'"
	STRING_SPACE        = " "
	STRING_TWO_SPACES   = "  "
	STRING_TAB          = "    "
	STRING_ZERO         = "0"
	STRING_ZERO_FLOAT   = "0.0"
)
View Source
const (
	FIELD_FG  = "fg"
	FIELD_FG3 = "fg3"
	FIELD_FT  = "ft"
)
View Source
const (
	INDEX_MADE           = 0
	INDEX_ATTEMPTS       = 1
	INDEX_SPAN_NAME      = 0
	INDEX_SPAN_NAME_ABBR = 1
	INDEX_SPAN_POSITION  = 2
	INDEX_AWAY_STARTERS  = 0
	INDEX_AWAY_BENCH     = 1
	INDEX_HOME_STARTERS  = 2
	INDEX_HOME_BENCH     = 3
)
View Source
const (
	BASE10 = 10
	BITS32 = 32
	BY2    = 2
)
View Source
const (
	DNP       = "dnp"
	HIGHLIGHT = "highlight"
)
View Source
const (
	STARTERS = "starters"
	BENCH    = "bench"
)
View Source
const (
	EST_FORMAT          = "20060102 3:04 PM MST"
	DATE_FORMAT         = "20060102"
	YEAR_FORMAT         = "2006"
	NBA_DATETIME_FORMAT = "01/02/2006 15:04:05"
	EST                 = "America/New_York" // Eastern Standard Time
)
View Source
const (
	MAX_SEASON_END = "0630" // add buffer to be safe
	MAX_PERIODS    = 10     // 6 overtimes
)
View Source
const (
	JSON_INDENT = "  "
	JSON_PREFIX = ""
)
View Source
const (
	GAME_FILE    = "%s%s.json"
	PLAYERS_DIR  = "players"
	PLAYERS_FILE = "players.json"
	PLAYS_FILE   = "%s.%s.plays.json"
	//TEAMS_DIR                   = "teams"
	TEAMS_FILE        = "teams.json"
	TEAM_RANKS_FILE   = "team.ranks.json"
	NBA_SCHEDULE_FILE = "schedule.%s.json"
	UNTAGGED          = "untagged"
)
View Source
const (
	FLOAT_TO_PERCENT = 100.0
)
View Source
const (
	HTTP_TIMEOUT = 45 // seconds
)
View Source
const (
	INDEX_FIELD_NAME = 0
)

Variables

View Source
var (
	LastM   map[int]*L10Data
	StreakM map[int]*StreakData
)
View Source
var (
	GBCE         = float32(0.5)
	WESTERN_CONF = "Western"
	EASTERN_CONF = "Eastern"
)
View Source
var AllTeams = map[int]*TeamMap{
	1610612738: &TeamMap{
		Name:       "Boston Celtics",
		City:       "Boston",
		Code:       "BOS",
		Abv:        "Celtics",
		Division:   "Atlantic",
		Conference: "Eastern",
	},
	1610612751: &TeamMap{
		Name:       "Brooklyn Nets",
		City:       "Brooklyn",
		Code:       "BKN",
		Abv:        "Nets",
		Division:   "Atlantic",
		Conference: "Eastern",
	},
	1610612752: &TeamMap{
		Name:       "New York Knicks",
		City:       "New York",
		Code:       "NYK",
		Abv:        "Knicks",
		Division:   "Atlantic",
		Conference: "Eastern",
	},
	1610612755: &TeamMap{
		Name:       "Philadelphia 76ers",
		City:       "Philadelphia",
		Code:       "PHI",
		Abv:        "76ers",
		Division:   "Atlantic",
		Conference: "Eastern",
	},
	1610612761: &TeamMap{
		Name:       "Toronto Raptors",
		City:       "Toronto",
		Code:       "TOR",
		Abv:        "Raptors",
		Division:   "Atlantic",
		Conference: "Eastern",
	},
	1610612741: &TeamMap{
		Name:       "Chicago Bulls",
		City:       "Chicago",
		Code:       "CHI",
		Abv:        "Bulls",
		Division:   "Central",
		Conference: "Eastern",
	},
	1610612739: &TeamMap{
		Name:       "Cleveland Cavaliers",
		City:       "Cleveland",
		Code:       "CLE",
		Abv:        "Cavaliers",
		Division:   "Central",
		Conference: "Eastern",
	},
	1610612765: &TeamMap{
		Name:       "Detroit Pistons",
		City:       "Detroit",
		Code:       "DET",
		Abv:        "Pistons",
		Division:   "Atlantic",
		Conference: "Eastern",
	},
	1610612754: &TeamMap{
		Name:       "Indiana Pacers",
		City:       "Indiana",
		Code:       "IND",
		Abv:        "Pacers",
		Division:   "Atlantic",
		Conference: "Eastern",
	},
	1610612749: &TeamMap{
		Name:       "Milwaukee Bucks",
		City:       "Milwaukee",
		Code:       "MIL",
		Abv:        "Bucks",
		Division:   "Atlantic",
		Conference: "Eastern",
	},
	1610612737: &TeamMap{
		Name:       "Atlanta Hawks",
		City:       "Atlanta",
		Code:       "ATL",
		Abv:        "Hawks",
		Division:   "Southeast",
		Conference: "Eastern",
	},
	1610612766: &TeamMap{
		Name:       "Charlotte Hornets",
		City:       "Charlotte",
		Code:       "CHA",
		Abv:        "Hornets",
		Division:   "Southeast",
		Conference: "Eastern",
	},
	1610612748: &TeamMap{
		Name:       "Miami Heat",
		City:       "Miami",
		Code:       "MIA",
		Abv:        "Heat",
		Division:   "Southeast",
		Conference: "Eastern",
	},
	1610612753: &TeamMap{
		Name:       "Orlando Magic",
		City:       "Orlando",
		Code:       "ORL",
		Abv:        "Magic",
		Division:   "Southeast",
		Conference: "Eastern",
	},
	1610612764: &TeamMap{
		Name:       "Washington Wizards",
		City:       "Washington",
		Code:       "WAS",
		Abv:        "Wizards",
		Division:   "Southeast",
		Conference: "Eastern",
	},
	1610612743: &TeamMap{
		Name:       "Denver Nuggets",
		City:       "Denver",
		Code:       "DEN",
		Abv:        "Nuggets",
		Division:   "Northwest",
		Conference: "Western",
	},
	1610612750: &TeamMap{
		Name:       "Minnesota Timberwolves",
		City:       "Minnesota",
		Code:       "MIN",
		Abv:        "Timberwolves",
		Division:   "Northwest",
		Conference: "Western",
	},
	1610612760: &TeamMap{
		Name:       "Oklahoma City Thunder",
		City:       "Oklahoma City",
		Code:       "OKC",
		Abv:        "Thunder",
		Division:   "Northwest",
		Conference: "Western",
	},
	1610612757: &TeamMap{
		Name:       "Portland Trailblazers",
		City:       "Portland",
		Code:       "POR",
		Abv:        "Trailblazers",
		Division:   "Northwest",
		Conference: "Western",
	},
	1610612762: &TeamMap{
		Name:       "Utah Jazz",
		City:       "Utah",
		Code:       "UTA",
		Abv:        "Jazz",
		Division:   "Northwest",
		Conference: "Western",
	},
	1610612744: &TeamMap{
		Name:       "Golden State Warriors",
		City:       "Golden State",
		Code:       "GSW",
		Abv:        "Warriors",
		Division:   "Pacific",
		Conference: "Western",
	},
	1610612746: &TeamMap{
		Name:       "LA Clippers",
		City:       "LA",
		Code:       "LAC",
		Abv:        "Clippers",
		Division:   "Pacific",
		Conference: "Western",
	},
	1610612747: &TeamMap{
		Name:       "Los Angeles Lakers",
		City:       "Los Angeles",
		Code:       "LAL",
		Abv:        "Lakers",
		Division:   "Pacific",
		Conference: "Western",
	},
	1610612756: &TeamMap{
		Name:       "Phoenix Suns",
		City:       "Phoenix",
		Code:       "PHX",
		Abv:        "Suns",
		Division:   "Pacific",
		Conference: "Western",
	},
	1610612758: &TeamMap{
		Name:       "Sacremento Kings",
		City:       "Sacremento",
		Code:       "SAC",
		Abv:        "Kings",
		Division:   "Pacific",
		Conference: "Western",
	},
	1610612742: &TeamMap{
		Name:       "Dallas Mavericks",
		City:       "Dallas",
		Code:       "DAL",
		Abv:        "Mavericks",
		Division:   "Southwest",
		Conference: "Western",
	},
	1610612745: &TeamMap{
		Name:       "Houston Rockets",
		City:       "Houston",
		Code:       "HOU",
		Abv:        "Rockets",
		Division:   "Southwest",
		Conference: "Western",
	},
	1610612763: &TeamMap{
		Name:       "Memphis Grizzlies",
		City:       "Memphis",
		Code:       "MEM",
		Abv:        "Grizzlies",
		Division:   "Southwest",
		Conference: "Western",
	},
	1610612740: &TeamMap{
		Name:       "New Orleans Pelicans",
		City:       "New Orleans",
		Code:       "NOP",
		Abv:        "Pelicans",
		Division:   "Southwest",
		Conference: "Western",
	},
	1610612759: &TeamMap{
		Name:       "San Antonio Spurs",
		City:       "San Antonio",
		Code:       "SAS",
		Abv:        "Spurs",
		Division:   "Southwest",
		Conference: "Western",
	},
}

Functions

func BoxscoreApi

func BoxscoreApi(id string) string

func CalcTeamPct added in v0.5.0

func CalcTeamPct(s map[int]*Standing)

func CalcTeamStats added in v0.5.0

func CalcTeamStats(s map[int]*Standing, scores []NbaBoxscore)

func CalculateStandings added in v0.5.0

func CalculateStandings(s map[int]*Standing, scores []NbaBoxscore)

func CheckNbaTeam added in v0.5.1

func CheckNbaTeam(hid int, aid int) bool

func GameDateToString added in v0.2.5

func GameDateToString(d string) string

func GamePlayed added in v0.4.2

func GamePlayed(mins int) int

func GamesBack added in v0.5.0

func GamesBack(s map[int]*Standing)

func GetCurrentSeason

func GetCurrentSeason() string

func IsAfterDate added in v0.2.4

func IsAfterDate(d1 string, d2 string) bool

func IsAfterNow added in v0.5.9

func IsAfterNow(d string) bool

func IsFutureGame

func IsFutureGame(d string) bool

func Last10 added in v0.5.0

func Last10(scores []NbaBoxscore)

assumes boxscores in order by date

func LegacyScheduleApi added in v0.5.6

func LegacyScheduleApi(y string) string

func NbaGetBoxscoreJson added in v0.2.9

func NbaGetBoxscoreJson(id string) []byte

func NbaGetLegacyScheduleJson added in v0.5.6

func NbaGetLegacyScheduleJson(y string) []byte

func NbaGetPlaysJson added in v0.2.9

func NbaGetPlaysJson(id string) []byte

func NbaGetScheduleJson added in v0.2.7

func NbaGetScheduleJson() []byte

func NbaGetScoreboardTodayJson added in v0.2.9

func NbaGetScoreboardTodayJson() []byte

func ParseWl added in v0.4.2

func ParseWl(s map[int]*Standing, game *NbaGame)

func Pct added in v0.4.2

func Pct(dividend int, divisor int) float32

func PctFp added in v0.4.2

func PctFp(dividend float32, divisor int) float32

func PctTotal added in v0.5.0

func PctTotal(a int, b int) float32

a/(a+b)

func PlaysApi

func PlaysApi(d string) string

func PtmToMin added in v0.2.20

func PtmToMin(s string) int

func ScheduleApi

func ScheduleApi() string

func ScoreboardTodayApi

func ScoreboardTodayApi() string

func Streak added in v0.5.0

func Streak(scores []NbaBoxscore)

func TGameType added in v0.3.3

func TGameType(days []NbaGameDates) map[string]int

func TopTeam added in v0.5.0

func TopTeam(s map[int]*Standing) (*Standing, *Standing)

func UpdateLast10 added in v0.5.0

func UpdateLast10(s map[int]*Standing)

func UpdateStreak added in v0.5.0

func UpdateStreak(s map[int]*Standing)

func UtcToString added in v0.2.5

func UtcToString(d string) string

func WinPct added in v0.5.0

func WinPct(s map[int]*Standing)

Types

type Advanced added in v0.3.8

type Advanced struct {
	PointsPg       float32 `json:"points"`
	OrebPg         float32 `json:"oreb"`
	DrebPg         float32 `json:"dreb"`
	TrebPg         float32 `json:"treb"`
	FtaPg          float32 `json:"fta"`
	FtmPg          float32 `json:"ftm"`
	FtpPg          float32 `json:"ftp"`
	Fg2aPg         float32 `json:"fg2a"`
	Fg2mPg         float32 `json:"fg2m"`
	Fg2pPg         float32 `json:"fg2p"`
	Fg3aPg         float32 `json:"fg3a"`
	Fg3mPg         float32 `json:"fg3m"`
	Fg3pPg         float32 `json:"fg3p"`
	FgtaPg         float32 `json:"fgta"`
	FgtmPg         float32 `json:"fgtm"`
	FgtpPg         float32 `json:"fgtp"`
	StealsPg       float32 `json:"steals"`
	AssistsPg      float32 `json:"assists"`
	BlocksPg       float32 `json:"blocks"`
	BlockedPg      float32 `json:"blocked"`
	TurnoversPg    float32 `json:"turnovers"`
	FoulsPg        float32 `json:"fouls"`
	FouledPg       float32 `json:"fouled"`
	FoulsOPg       float32 `json:"foulsOffensive"`
	TechnicalsPg   float32 `json:"technicals"`
	PaintPg        float32 `json:"paint"`
	FastbreakPg    float32 `json:"fastbreak"`
	SecondChancePg float32 `json:"secondChance"`
	MinutesPg      float32 `json:"minutes"`
	PlusMinusPg    float32 `json:"plusMinus"`
}

type Base added in v0.2.16

type Base struct {
	Points       int     `json:"points"`
	Oreb         int     `json:"oreb"`
	Dreb         int     `json:"dreb"`
	Treb         int     `json:"treb"`
	Fta          int     `json:"fta"`
	Ftm          int     `json:"ftm"`
	Ftp          float32 `json:"ftp"`
	Fg2a         int     `json:"fg2a"`
	Fg2m         int     `json:"fg2m"`
	Fg2p         float32 `json:"fg2p"`
	Fg3a         int     `json:"fg3a"`
	Fg3m         int     `json:"fg3m"`
	Fg3p         float32 `json:"fg3p"`
	Fgta         int     `json:"fgta"`
	Fgtm         int     `json:"fgtm"`
	Fgtp         float32 `json:"fgtp"`
	Steals       int     `json:"steals"`
	Assists      int     `json:"assists"`
	Blocks       int     `json:"blocks"`
	Blocked      int     `json:"blocked"`
	Turnovers    int     `json:"turnovers"`
	Fouls        int     `json:"fouls"`
	Fouled       int     `json:"fouled"`
	FoulsO       int     `json:"foulsOffensive"`
	Technicals   int     `json:"technicals"`
	Paint        int     `json:"paint"`
	Fastbreak    int     `json:"fastbreak"`
	SecondChance int     `json:"secondChance"`
	At           float32 `json:"assistToTurnoverRatio"`
}

type Cache added in v0.2.16

type Cache struct {
	Seasons map[string]Season `json:"seasons"`
}

type Conference added in v0.3.18

type Conference struct {
	Name      string     `json:"name"`
	Divisions []Division `json:"divisions"`
}

type Division added in v0.3.18

type Division struct {
	Name  string     `json:"name"`
	Teams []TeamInfo `json:"teams"`
}

type Game

type Game struct {
	GameID  string          `json:"gameId"`
	Date    string          `json:"date"`
	Away    TeamGame        `json:"away"`
	Home    TeamGame        `json:"home"`
	Periods map[int]Period  `json:"periods"`
	Plays   map[string]Play `json:"plays"`
}

type L10Data added in v0.5.0

type L10Data struct {
	L10W int `json:"L10W"`
	L10L int `json:"L10L"`
}

type Leaders added in v0.3.8

type Leaders struct {
	ID        int     `json:"id"`
	First     string  `json:"first"`
	Last      string  `json:"last"`
	Full      string  `json:"full"`
	Abv       string  `json:"abv"`
	Minutes   int     `json:"minutes"`
	Games     int     `json:"games"`
	PlusMinus float32 `json:"plusMinus"`
	Base      `json:"base"`
	Advanced  `json:"advanced"`
}

type League added in v0.3.18

type League struct {
	Conferences []Conference `json:"conferences"`
}

type NbaAction added in v0.2.6

type NbaAction struct {
	ActionNumber          int      `json:"actionNumber"`
	Clock                 string   `json:"clock"`
	TimeActual            string   `json:"timeActual"`
	Description           string   `json:"description"`
	Descriptor            string   `json:"descriptor"`
	PersonID              int      `json:"personId"`
	TeamID                int      `json:"teamId"`
	TeamTriCode           string   `json:"teamTricode"`
	ActionType            string   `json:"actionType"`
	SubActionType         string   `json:"subType"`
	Qualifers             []string `json:"qualifiers"`
	X                     float64  `json:"x"`
	Y                     float64  `json:"y"`
	Side                  string   `json:"side"`
	ShotDistance          float64  `json:"shotDistance"`
	Possession            int      `json:"possession"`
	Period                int      `json:"period"`
	PeriodType            string   `json:"periodType"`
	AwayScore             string   `json:"scoreAway"`
	HomeScore             string   `json:"scoreHome"`
	Edited                string   `json:"edited"`
	OrderNumber           int      `json:"orderNumber"`
	XLegacy               int      `json:"xLegacy"`
	YLegacy               int      `json:"yLegacy"`
	IsFieldGoal           int      `json:"isFieldGoal"`
	ShotResult            string   `json:"shotResult"`
	Name                  string   `json:"playerName"`
	NameI                 string   `json:"playerNameI"`
	PersonIdsFilter       []int    `json:"personIdsFilter"`
	ScoreChange           bool     `json:"isScoreChange"`
	StealName             string   `json:"stealPlayerName"`
	StealPersonID         int      `json:"stealPersonId"`
	AssistName            string   `json:"assistPlayerName"`
	AssistPersonID        int      `json:"assistPersonId"`
	AssistNameI           string   `json:"assistPlayerNameInitial"`
	AssistTotal           int      `json:"assistTotal"`
	BlockName             string   `json:"blockPlayerName"`
	BlockPersonID         int      `json:"blockPersonId"`
	BlockTotal            int      `json:"blockTotal"`
	FoulDrawnPersonID     int      `json:"foulDrawnPersonId"`
	FoulDrawnName         string   `json:"foulDrawnPlayerName"`
	FoulPersonTotal       int      `json:"foulPersonTotal"`
	FoulTechTotal         int      `json:"foulTechnicalTotal"`
	JumpLostName          string   `json:"jumpBallLostPlayerName"`
	JumpLostPersonID      int      `json:"jumpBallLostPersonId"`
	JumpRecoveredName     string   `json:"jumpBallRecoveredPlayerName"`
	JumpRecoveredPersonID int      `json:"jumpBallRecoveredPersonId"`
	JumpWonName           string   `json:"jumpBallWonPlayerName"`
	JumpWonPersonID       int      `json:"jumpBallWonPersonId"`
	OfficialID            int      `json:"officialId"`
	ShotNum               int      `json:"shotActionNumber"`
	TurnoverTotal         int      `json:"turnoverTotal"`
	Value                 string   `json:"value"`
}

type NbaAdvStats

type NbaAdvStats struct {
	SeasonID  int    `json:"seasonYear"`
	TeamID    int    `json:"teamId"`
	Minutes   string `json:"min"`
	Points    string `json:"points"`
	Oreb      string `json:"offReb"`
	Dreb      string `json:"defReb"`
	Treb      string `json:"totReb"`
	Assists   string `json:"assists"`
	Turnovers string `json:"turnovers"`
	Steals    string `json:"steals"`
	Blocks    string `json:"blocks"`
	Fouls     string `json:"pFouls"`
	Fgm       string `json:"fg2m"`
	Fga       string `json:"fg2a"`
	Fg3m      string `json:"fg3m"`
	Fg3a      string `json:"fg3a"`
	Ftm       string `json:"ftm"`
	Fta       string `json:"fta"`
	Played    string `json:"gamesPlayed"`
	Started   string `json:"gamesStarted"`
	PlusMinus string `json:"plusMinus"`
	Ppg       string `json:"ppg"`  // points per game
	Rpg       string `json:"rpg"`  // rebounds per game
	Apg       string `json:"apg"`  // assists per game
	Mpg       string `json:"mpg"`  // minutes per game
	Tpg       string `json:"topg"` // turnovers per game
	Spg       string `json:"spg"`  // steals per game
	Bpg       string `json:"bpg"`  // blocks per game
	Fg2p      string `json:"fg2p"` // fg %
	Fg3p      string `json:"tpp"`  // three point %
	Ftp       string `json:"ftp"`  // free throw %
}

type NbaBoxscore

type NbaBoxscore struct {
	Meta NbaMeta `json:"meta"`
	Game NbaGame `json:"game"`
}

func NbaGetBoxscore

func NbaGetBoxscore(id string) *NbaBoxscore

type NbaFormatted

type NbaFormatted struct {
	Description string `json:"description"`
}

type NbaGame

type NbaGame struct {
	ID           string       `json:"gameId"`
	GameCode     string       `json:"gameCode"`
	WeekNumber   int          `json:"weekNumber"`
	WeekName     string       `json:"weekName"`
	GameLabel    string       `json:"gameLabel"`
	GameSubLabel string       `json:"gameSubLabel"`
	SeriesText   string       `json:"seriesText"`
	GameTime     string       `json:"gameTimeUTC"` // UTC
	Status       string       `json:"gameStatusText"`
	Away         NbaTeamScore `json:"awayTeam"`
	Home         NbaTeamScore `json:"homeTeam"`
}

type NbaGameActions added in v0.2.6

type NbaGameActions struct {
	Actions []NbaAction `json:"actions"`
}

type NbaGameData

type NbaGameData struct {
	ID        string       `json:"gameId"`
	SeasonID  string       `json:"seasonYear"`
	Date      string       `json:"homeStartDate"`
	StartUtc  string       `json:"startTimeUTC"`
	EndUtc    string       `json:"endTimeUTC"`
	AwayScore NbaTeamScore `json:"vTeam"`
	HomeScore NbaTeamScore `json:"hTeam"`
}

type NbaGameDates

type NbaGameDates struct {
	GameDate string    `json:"gameDate"` // 10/05/2023 00:00:00
	Games    []NbaGame `json:"games"`
}

type NbaLeague

type NbaLeague struct {
	Players []NbaPlayerInfo `json:"standard"`
}

type NbaLeague2

type NbaLeague2 struct {
	NbaStats2 `json:"standard"`
}

type NbaLeague3

type NbaLeague3 struct {
	Teams []NbaTeamStandard `json:"standard"`
}

type NbaLeague4

type NbaLeague4 struct {
	NbaRegularSeason2 `json:"regularSeason"`
}

type NbaLeague5

type NbaLeague5 struct {
	NbaRegularSeason2 `json:"regularSeason"`
}

type NbaLeague6

type NbaLeague6 struct {
	NbaStandard4 `json:"standard"`
}

type NbaLeaguePlayers

type NbaLeaguePlayers struct {
	NbaLeague `json:"league"`
	SeasonID  string `json:"season"`
}

type NbaLeagueSchedule

type NbaLeagueSchedule struct {
	SeasonYear string         `json:"seasonYear"`
	LeagueId   string         `json:"leagueId"`
	GameDates  []NbaGameDates `json:"gameDates"`
	Weeks      []NbaWeek      `json:"weeks"`
}

type NbaLegacyGame added in v0.5.6

type NbaLegacyGame struct {
	ID    string `json:"gid"`
	Code  string `json:"gcode"`
	State string `json:"stt"`
}

type NbaLegacyMonthlyGames added in v0.5.6

type NbaLegacyMonthlyGames struct {
	Games []NbaLegacyGame `json:"g"`
}

type NbaLegacyMonthlySchedule added in v0.5.6

type NbaLegacyMonthlySchedule struct {
	Mscd NbaLegacyMonthlyGames `json:"mscd"`
}

type NbaLegacySchedule added in v0.5.6

type NbaLegacySchedule struct {
	Lscd []NbaLegacyMonthlySchedule `json:"lscd"`
}

func NbaGetLegacySchedule added in v0.5.6

func NbaGetLegacySchedule(y string) *NbaLegacySchedule

type NbaMeta

type NbaMeta struct {
	Version int    `json:"version"`
	Request string `json:"request"`
	Time    string `json:"time"`
}

type NbaPlayByPlay added in v0.2.6

type NbaPlayByPlay struct {
	Meta NbaMeta        `json:"meta"`
	Game NbaGameActions `json:"game"`
}

func NbaGetPlays added in v0.2.6

func NbaGetPlays(id string) *NbaPlayByPlay

type NbaPlayer

type NbaPlayer struct {
	ID         int                 `json:"personId"`
	First      string              `json:"firstName"`
	Last       string              `json:"familyName"`
	Name       string              `json:"name"`
	NameShort  string              `json:"nameI"`
	Jersey     string              `json:"jerseyNum"`
	Position   string              `json:"position"`
	Starter    string              `json:"starter"`
	Order      int                 `json:"order"`
	Statistics NbaPlayerStatistics `json:"statistics"`
}

type NbaPlayerData

type NbaPlayerData struct {
	ID             string  `json:"personId"`
	TeamID         int     `json:"teamId"`
	First          string  `json:"firstName"`
	Last           string  `json:"familyName"`
	Points         int     `json:"points"`
	Minutes        string  `json:"minutesCalculated"`
	Fgm            int     `json:"fieldGoalsMade"`
	Fga            int     `json:"fieldGoalsAttempted"`
	Ftm            int     `json:"freeThrowsMade"`
	Fta            int     `json:"freeThrowsAttempted"`
	Fg2m           int     `json:"twoPointersMade"`
	Fg2a           int     `json:"twoPointersAttempted"`
	Fg3m           int     `json:"threePointersMade"`
	Fg3a           int     `json:"threePointersAttempted"`
	Oreb           int     `json:"reboundsOffensive"`
	Dreb           int     `json:"reboundsDefensive"`
	Treb           int     `json:"reboundsTotal"`
	Assists        int     `json:"assists"`
	Fouls          int     `json:"foulsPersonal"`
	FoulsOffensive int     `json:"foulsOffensive"`
	FoulsDrawn     int     `json:"foulsDrawn"`
	FoulsTechnical int     `json:"foulsTechnical"`
	Steals         int     `json:"steals"`
	Turnovers      int     `json:"turnovers"`
	Blocks         int     `json:"blocks"`
	Blocked        int     `json:"blocksReceived"`
	PlusMinus      float32 `json:"plusMinusPoints"`
	Position       string  `json:"position"`
	Fastbreak      int     `json:"pointsFastBreak"`
	Paint          int     `json:"pointsInThePaint"`
	SecondChance   int     `json:"pointsSecondChance"`
}

type NbaPlayerInfo

type NbaPlayerInfo struct {
	ID        string `json:"personId"`
	First     string `json:"firstName"`
	Last      string `json:"lastName"`
	TeamID    int    `json:"teamId"`
	Jersey    string `json:"jerseyNum"`
	Position  string `json:"position"`
	Starter   string `json:"starter"`
	Feet      string `json:"heightFeet"`
	Inches    string `json:"heightInches"`
	Meters    string `json:"heightMeters"`
	Pounds    string `json:"weightPounds"`
	Kilograms string `json:"weightKilograms"`
	Dob       string `json:"dateOfBirthUTC"`
	Rookie    string `json:"nbaDebutYear"`
	Years     string `json:"yearsPro"`
	College   string `json:"collegeName"`
	Active    bool   `json:"isActive"`
}

type NbaPlayerProfile

type NbaPlayerProfile struct {
	NbaLeague2 `json:"league"`
	ID         string `json:"id"`
	SeasonID   string `json:"seasonId"`
	First      string `json:"first"`
	Last       string `json:"last"`
}

type NbaPlayerStatistics

type NbaPlayerStatistics struct {
	Assists      int     `json:"assists"`
	Blocks       int     `json:"blocks"`
	Blocked      int     `json:"blocksReceived"`
	Fga          int     `json:"fieldGoalsAttempted"`
	Fgm          int     `json:"fieldGoalsMade"`
	Fgp          float32 `json:"fieldGoalsPercentage"`
	FoulsOff     int     `json:"foulsOffensive"`
	FoulsDrawn   int     `json:"foulsDrawn"`
	Fouls        int     `json:"foulsPersonal"`
	Technicals   int     `json:"foulsTechnical"`
	Fta          int     `json:"freeThrowsAttempted"`
	Ftm          int     `json:"freeThrowsMade"`
	Ftp          float32 `json:"freeThrowsPercentage"`
	Minutes      string  `json:"minutesCalculated"`
	Plus         float32 `json:"plus"`
	PlusMinus    float32 `json:"plusMinusPoints"`
	Points       int     `json:"points"`
	PointsFast   int     `json:"pointsFastBreak"`
	PointsPaint  int     `json:"pointsInThePaint"`
	PointsSecond int     `json:"pointsSecondChance"`
	Dreb         int     `json:"reboundsDefensive"`
	Oreb         int     `json:"reboundsOffensive"`
	Treb         int     `json:"reboundsTotal"`
	Steals       int     `json:"steals"`
	Fg3a         int     `json:"threePointersAttempted"`
	Fg3m         int     `json:"threePointersMade"`
	Fg3p         float32 `json:"threePointersPercentage"`
	Turnovers    int     `json:"turnovers"`
	Fg2a         int     `json:"twoPointersAttempted"`
	Fg2m         int     `json:"twoPointersMade"`
	Fg2p         float32 `json:"twoPointersPercentage"`
}

type NbaPlayerStats

type NbaPlayerStats struct {
	Latest           NbaAdvStats `json:"latest"`
	Career           NbaAdvStats `json:"careerSummary"`
	NbaRegularSeason `json:"regularSeason"`
}

type NbaRankStat

type NbaRankStat struct {
	Average string `json:"avg"`
	Rank    string `json:"rank"`
}

type NbaRanks

type NbaRanks struct {
	NbaStandard2 `json:"league"`
	SeasonID     string `json:"seasonId"`
}

type NbaRegularSeason

type NbaRegularSeason struct {
	SeasonInfo []NbaSeasonStats `json:"season"`
}

type NbaRegularSeason2

type NbaRegularSeason2 struct {
	Teams []NbaTeamRanks `json:"teams"`
}

type NbaSchedule

type NbaSchedule struct {
	Meta           NbaMeta           `json:"meta"`
	LeagueSchedule NbaLeagueSchedule `json:"leagueSchedule"`
}

func NbaGetSchedule

func NbaGetSchedule() *NbaSchedule

type NbaScoreData

type NbaScoreData struct {
	Score      int    `json:"score"`
	PeriodType string `json:"periodType"`
	Period     int    `json:"period"`
}

type NbaScoreboard

type NbaScoreboard struct {
	GameDate   string    `json:"gameDate"`
	LeagueId   string    `json:"leagueId"`
	LeagueName string    `json:"leagueName"`
	Games      []NbaGame `json:"games"`
}

type NbaScoreboardToday

type NbaScoreboardToday struct {
	Meta       NbaMeta       `json:"meta"`
	Scoreboard NbaScoreboard `json:"scoreboard"`
}

func NbaGetScoreboardToday

func NbaGetScoreboardToday() *NbaScoreboardToday

type NbaSeasonStats

type NbaSeasonStats struct {
	SeasonID int           `json:"seasonYear"`
	Teams    []NbaAdvStats `json:"teams"`
	Total    NbaAdvStats   `json:"total"`
}

type NbaStandard2

type NbaStandard2 struct {
	NbaLeague4 `json:"standard"`
}

type NbaStandard3

type NbaStandard3 struct {
	NbaTeam2 `json:"standard"`
}

type NbaStandard4

type NbaStandard4 struct {
	SeasonID int        `json:"seasonYear"`
	Teams    []NbaTeam3 `json:"teams"`
}

type NbaStats

type NbaStats struct {
	Players []NbaPlayerData `json:"activePlayers"`
	Away    NbaTeam         `json:"vTeam"`
	Home    NbaTeam         `json:"hTeam"`
}

type NbaStats2

type NbaStats2 struct {
	NbaPlayerStats `json:"stats"`
}

type NbaTeam

type NbaTeam struct {
	NbaTeamData `json:"totals"`
}

type NbaTeam2

type NbaTeam2 struct {
	Players []NbaTeamPlayer `json:"players"`
	TeamID  int             `json:"teamId"`
}

type NbaTeam3

type NbaTeam3 struct {
	TeamID    int    `json:"teamId"`
	W         string `json:"win"`
	L         string `json:"loss"`
	Pct       string `json:"winPct"`
	Gb        string `json:"gamesBehind"`
	Rank      string `json:"confRank"`
	Cw        string `json:"confWin"`
	Cl        string `json:"confLoss"`
	Dw        string `json:"divWin"`
	Dl        string `json:"divLoss"`
	Hw        string `json:"homeWin"`
	Hl        string `json:"homeLoss"`
	Aw        string `json:"awayWin"`
	Al        string `json:"awayLoss"`
	L10w      string `json:"lastTenWin"`
	L10l      string `json:"lastTenLoss"`
	Streak    string `json:"streak"`
	WinStreak bool   `json:"isWinStreak"`

	TeamSites `json:"teamSitesOnly"`
}

type NbaTeamData

type NbaTeamData struct {
	Assists         int     `json:"assists"`
	Atr             float64 `json:"assistsTurnoverRatio"`
	Bench           int     `json:"benchPoints"`
	Bl              int     `json:"biggestLead"`
	Bls             string  `json:"biggestLeadScore"`
	Bsr             int     `json:"biggestScoringRun"`
	Bsrs            string  `json:"biggestScoringRunScore"`
	Blocks          int     `json:"blocks"`
	Blocked         int     `json:"blocksReceived"`
	FastbreakA      int     `json:"fastBreakPointsAttempted"`
	FastbreakM      int     `json:"fastBreaKPointsMade"`
	FastbreakP      float64 `json:"fastBreakPointsPercentage"`
	Fga             int     `json:"fieldGoalsAttempted"`
	EffectiveFG     float64 `json:"fieldGoalsEffectiveAdjusted"`
	Fgm             int     `json:"fieldGoalsMade"`
	Fgp             float64 `json:"fieldGoalsPercentage"`
	FoulsO          int     `json:"foulsOffensive"`
	Fouled          int     `json:"foulsDrawn"`
	Fouls           int     `json:"foulsPersonal"`
	Technicals      int     `json:"foulsTechnical"`
	Fta             int     `json:"freeThrowsAttempted"`
	Ftm             int     `json:"freeThrowsMade"`
	Ftp             float64 `json:"freeThrowsPercentage"`
	LeadChanges     int     `json:"leadChanges"`
	Minutes         string  `json:"minutesCalculated"`
	Points          int     `json:"points"`
	Against         int     `json:"pointsAgainst"`
	Fastbreak       int     `json:"pointsFastBreak"`
	PointsTurnovers int     `json:"pointsFromTurnovers"`
	Paint           int     `json:"pointsInThePaint"`
	PaintA          int     `json:"pointsInThePaintAttempted"`
	PaintM          int     `json:"pointsInThePaintMade"`
	PaintP          float64 `json:"pointsInThePaintPercentage"`
	PointsSecond    int     `json:"pointsSecondChance"`
	Dreb            int     `json:"reboundsDefensive"`
	Oreb            int     `json:"reboundsOffensive"`
	Treb            int     `json:"reboundsPersonal"`
	SecondA         int     `json:"secondChancePointsAttempted"`
	SecondM         int     `json:"secondChancePointsMade"`
	SecondP         float64 `json:"secondChancePointsPercentage"`
	Steals          int     `json:"steals"`
	Fg3a            int     `json:"threePointersAttempted"`
	Fg3m            int     `json:"threePointersMade"`
	Fg3p            float64 `json:"threePointersPercentage"`
	Leading         string  `json:"timeLeading"`
	Ties            int     `json:"timesTied"`
	TrueA           float64 `json:"trueShootingAttempts"`
	TrueP           float64 `json:"trueShootingPercentage"`
	Turnovers       int     `json:"turnovers"`
	Fg2a            int     `json:"twoPointersAttempted"`
	Fg2m            int     `json:"twoPointersMade"`
	Fg2p            float64 `json:"twoPointersPercentage"`
}

type NbaTeamPlayer

type NbaTeamPlayer struct {
	ID string `json:"personId"`
}

type NbaTeamRanks

type NbaTeamRanks struct {
	ID             int         `json:"teamId"`
	Fgp            NbaRankStat `json:"fgp"`
	Fg3p           NbaRankStat `json:"tpp"`
	Ftp            NbaRankStat `json:"ftp"`
	Oreb           NbaRankStat `json:"orpg"`
	Dreb           NbaRankStat `json:"drpg"`
	Treb           NbaRankStat `json:"trpg"`
	Assists        NbaRankStat `json:"apg"`
	Turnovers      NbaRankStat `json:"tpg"`
	Steals         NbaRankStat `json:"spg"`
	Blocks         NbaRankStat `json:"bpg"`
	Fouls          NbaRankStat `json:"pfpg"`
	Points         NbaRankStat `json:"ppg"`
	OpponentPoints NbaRankStat `json:"oppg"`
	Efficiency     NbaRankStat `json:"eff"`
	Minutes        NbaRankStat `json:"min"`
	Abbreviation   string      `json:"abbreviation"`
}

type NbaTeamRoster

type NbaTeamRoster struct {
	NbaStandard3 `json:"league"`
}

type NbaTeamScore

type NbaTeamScore struct {
	ID         int            `json:"teamId"`
	ShortName  string         `json:"teamTriCode"`
	Score      int            `json:"score"`
	Periods    []NbaScoreData `json:"periods"`
	Players    []NbaPlayer    `json:"players"`
	Statistics NbaTeamData    `json:"statistics"`
}

type NbaTeamStandard

type NbaTeamStandard struct {
	ID         int    `json:"teamId"`
	IsNba      bool   `json:"isNBAFranchise"`
	City       string `json:"city"`
	Code       string `json:"tricode"`
	Full       string `json:"fullName"`
	Short      string `json:"nickname"`
	Conference string `json:"confName"`
	Division   string `json:"divName"`
}

type NbaTeamStandings

type NbaTeamStandings struct {
	NbaLeague6 `json:"league"`
}

type NbaTeamStats

type NbaTeamStats struct {
	ShortName string          `json:"triCode"`
	Players   []NbaPlayerData `json:"activePlayers"`
}

type NbaTeams

type NbaTeams struct {
	NbaLeague3 `json:"league"`
	SeasonID   string `json:"seasonId"`
}

type NbaWeek

type NbaWeek struct {
	WeekNumber int    `json:"weekNumber"`
	StartDate  string `json:"startDate"` // UTC
	EndDate    string `json:"endDate"`   // UTC
}

type Period added in v0.2.16

type Period struct {
	Number     int    `json:"number"`
	PeriodType string `json:"periodType"`
	Away       int    `json:"away"`
	Home       int    `json:"home"`
}

type Play

type Play struct {
	ID     string `json:"id"`
	Detail string `json:"detail"`
}

type PlayerGame added in v0.2.16

type PlayerGame struct {
	GameID     string  `json:"gameId"`
	TeamID     int     `json:"teamId"`
	HomeTeamID int     `json:"homeTeamId"`
	AwayTeamID int     `json:"awayTeamId"`
	HomeCode   string  `json:"homeCode"`
	AwayCode   string  `json:"awayCode"`
	GameDate   string  `json:"gameDate"`
	Starter    string  `json:"starter"`
	Minutes    int     `json:"minutes"`
	PlusMinus  float32 `json:"plusMinus"`
	GameType   int     `json:"gameType"`
	Base       `json:"stats"`
}

func TPlayerGame added in v0.2.18

func TPlayerGame(p NbaPlayer) PlayerGame

type PlayerInfo

type PlayerInfo struct {
	ID        int      `json:"personId"`
	First     string   `json:"firstName"`
	Last      string   `json:"familyName"`
	Full      string   `json:"full"`
	Abv       string   `json:"abv"`
	Jersey    string   `json:"jerseyNum"`
	Position  string   `json:"position"`
	Nicknames []string `json:"nicknames"`
}

func TPlayerInfo added in v0.2.19

func TPlayerInfo(p NbaPlayer) PlayerInfo

type PlayerMap added in v0.5.0

type PlayerMap struct {
	Players map[int]*PlayerInfo `json:"players"`
}

type PlayerSeason

type PlayerSeason struct {
	Games map[string]PlayerGame `json:"games"`
	Info  PlayerInfo            `json:"info"`
}

type Season

type Season struct {
	ID           string               `json:"id"`
	Players      map[int]PlayerSeason `json:"players"`
	Teams        int                  `json:"teams"`
	Games        map[string]Game      `json:"games"`
	Leaderboard  int                  `json:"leaderboard"`
	Standings    int                  `json:"standings"`
	Transactions int                  `json:"transactions"`
}

type SeasonTeam added in v0.2.16

type SeasonTeam struct {
	Games map[string]Game `json:"games"`
	Info  TeamInfo        `json:"info"`
}

type Standing added in v0.4.2

type Standing struct {
	TeamID       int     `json:"teamId"`
	Name         string  `json:"name"`
	City         string  `json:"city"`
	Code         string  `json:"code"`
	Wins         int     `json:"wins"`
	Losses       int     `json:"losses"`
	Gb           float32 `json:"gamesBack"`
	WinPct       float32 `json:"winPct"`
	HomeW        int     `json:"homeWins"`
	HomeL        int     `json:"homeLosses"`
	AwayW        int     `json:"awayWins"`
	AwayL        int     `json:"awayLosses"`
	DivW         int     `json:"divWins"`
	DivL         int     `json:"divLosses"`
	ConfW        int     `json:"confWins"`
	ConfL        int     `json:"confLosses"`
	Ppg          float32 `json:"pointsPerGame"`
	Oppg         float32 `json:"oppPointsPerGame"`
	Streak       int     `json:"streak"`
	IsW          bool    `json:"isW"`
	Last10W      int     `json:"last10W"`
	Last10L      int     `json:"last10L"`
	Base         `json:"base"`
	TeamAdvanced `json:"advanced"`
}

type StreakData added in v0.5.0

type StreakData struct {
	Streak      int  `json:"streak"`
	IsWinStreak bool `json:"IsWinStreak"`
}

type TeamAdvanced added in v0.4.0

type TeamAdvanced struct {
	BiggestLead int     `json:"biggestLead"`
	BiggestRun  int     `json:"biggestRun"`
	Bench       int     `json:"bench"`
	Pft         int     `json:"pointsFromTurnovers"`
	At          float32 `json:"assistToTurnoverRatio"`
	Efgp        float32 `json:"effectiveFieldGoalPercentage"`
	TimeLeading string  `json:"timeLeading"`
	Pf          int     `json:"pointsFor"`
	Pa          int     `json:"pointsAgainst"`
	P1          int     `json:"p1"`
	P2          int     `json:"p2"`
	P3          int     `json:"p3"`
	P4          int     `json:"p4"`
	Pot         int     `json:"pot"`
	Pa1         int     `json:"pa1"`
	Pa2         int     `json:"pa2"`
	Pa3         int     `json:"pa3"`
	Pa4         int     `json:"pa4"`
	Paot        int     `json:"paot"`
}

type TeamGame added in v0.2.16

type TeamGame struct {
	ID      int                `json:"id"`
	Abv     string             `json:"abv"`
	Score   int                `json:"score"`
	Players map[int]PlayerGame `json:"players"`
}

type TeamInfo

type TeamInfo struct {
	ID   int    `json:"id"`
	Name string `json:"name"`
	Code string `json:"abv"`
	City string `json:"full"`
	Abv  string `json:"abv"`
}

type TeamMap added in v0.4.2

type TeamMap struct {
	Name       string `json:"name"`
	City       string `json:"city"`
	Code       string `json:"code"`
	Abv        string `json:"abv"`
	Division   string `json:"division"`
	Conference string `json:"conference"`
}

type TeamSites

type TeamSites struct {
	Short      string `json:"teamTricode"`
	Mascot     string `json:"teamCode"`
	StreakText string `json:"streakText"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL