nba

package
v0.0.0-...-5888283 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const BoxscoreURL = "https://cdn.nba.com/static/json/liveData/boxscore/boxscore_%s.json"
View Source
const PlayerHeadshotURL = "https://cdn.nba.com/headshots/nba/latest/260x190/%d.png"
View Source
const TimeBirthdateFormat = "2006-01-02"

TimeBirthdateFormat - yyyy-mm-dd format used by players api response

View Source
const TimeDayFormat = "20060102"

TimeDayFormat - Year/month/day format used by the NBA api

View Source
const UTCFormat = "2006-01-02T15:04:00.000Z"

UTCFormat - UTC format used by the NBA api

Variables

View Source
var ErrNotFound = errors.New("not found")

Functions

This section is empty.

Types

type ArenaInfo

type ArenaInfo struct {
	Name    string `json:"name"`
	City    string `json:"city"`
	Country string `json:"country"`
}

type Boxscore

type Boxscore struct {
	GameNode struct {
		GameID               string             `json:"gameId"`
		GameTimeLocal        string             `json:"gameTimeLocal"` // ex. 2021-07-14T20:00:00-05:00
		GameTimeUTC          datetime           `json:"gameTimeUTC"`
		GameTimeHome         string             `json:"gameTimeHome"`      // ex. 2021-07-14T20:00:00-05:00
		GameTimeAway         string             `json:"gameTimeAway"`      // ex. 2021-07-14T20:00:00-07:00
		GameET               string             `json:"gameEt"`            // ex. 2021-07-14T20:00:00-04:00
		TotalDurationMinutes int                `json:"duration"`          // duration in minutes (real world time) from tipoff to final buzzer
		GameCode             string             `json:"gameCode"`          // ex. 20210714/PHXMIL
		GameStatusText       string             `json:"gameStatusText"`    // ex. [Q3 03:03, Final]
		GameStatus           GameStatus         `json:"gameStatus"`        // ex. [1 - scheduled, 2 - in progress, 3 - final]
		RegulationPeriods    int                `json:"regulationPeriods"` // not sure why this would be anything but 4?
		Period               int                `json:"period"`
		GameClock            duration           `json:"gameClock"` // ex. PT11M34.00S
		Attendance           int                `json:"attendance"`
		Sellout              string             `json:"sellout"` // ex. [0,1]
		Arena                BoxscoreArena      `json:"arena"`
		Officials            []BoxscoreOfficial `json:"officials"`
		HomeTeam             BoxscoreTeam       `json:"homeTeam"`
		AwayTeam             BoxscoreTeam       `json:"awayTeam"`
	} `json:"game"`
}

func (Boxscore) Final

func (b Boxscore) Final() bool

type BoxscoreArena

type BoxscoreArena struct {
	ID       int     `json:"arenaId"`
	Name     string  `json:"arenaName"`
	City     *string `json:"arenaCity"`
	State    *string `json:"arenaState"`    // ex. MN
	Country  string  `json:"arenaCountry"`  // ex. US
	Timezone string  `json:"arenaTimezone"` // ex. America/Chicago
}

type BoxscoreGameClockMinutes

type BoxscoreGameClockMinutes struct {
	Duration int
	// contains filtered or unexported fields
}

func (*BoxscoreGameClockMinutes) UnmarshalJSON

func (bgc *BoxscoreGameClockMinutes) UnmarshalJSON(data []byte) error

type BoxscoreOfficial

type BoxscoreOfficial struct {
	PersonID     int    `json:"personId"`
	Name         string `json:"name"`  // ex. Tony Brothers
	NameI        string `json:"nameI"` // ex. T. Brothers
	FirstName    string `json:"firstName"`
	LastName     string `json:"familyName"`
	JerseyNumber string `json:"jerseyNum"`
	Assignment   string `json:"assignment"` // ex. [OFFICIAL1, OFFICIAL2, OFFICIAL3]
}

type BoxscorePeriod

type BoxscorePeriod struct {
	Period     int    `json:"period"`
	PeriodType string `json:"periodType"` // ex. [REGULAR, OVERTIME?]
	Points     int    `json:"score"`
}

type BoxscorePlayer

type BoxscorePlayer struct {
	Name                  string                   `json:"name"`  // ex. Jrue Holiday
	NameI                 string                   `json:"nameI"` // ex. J. Holiday
	FirstName             string                   `json:"firstName"`
	LastName              string                   `json:"familyName"`
	Status                string                   `json:"status"`                // ex. [ACTIVE, INACTIVE]
	NotPlayingReason      *string                  `json:"notPlayingReason"`      // ex. INACTIVE_INJURY only set if status is INACTIVE
	NotPlayingDescription *string                  `json:"notPlayingDescription"` // ex. Left Ankle; Surgery only set if status is INACTIVE
	Order                 int                      `json:"order"`                 // I believe this is the order in which they played e.g. 6 is the 6th man or 1st off the bench
	ID                    int                      `json:"personId"`
	JerseyNumber          string                   `json:"jerseyNum"`
	Position              *string                  `json:"position"` // ex. [PG, SG, SF, PF, C] only set for starters?
	Starter               string                   `json:"starter"`  // ex. [0,1]
	OnCourt               string                   `json:"oncourt"`  // ex. [0,1]
	Played                string                   `json:"played"`   // ex. [0,1]
	Statistics            BoxscorePlayerStatistics `json:"statistics"`
}

type BoxscorePlayerStatistics

type BoxscorePlayerStatistics struct {
	Assists                 int                      `json:"assists"`
	Blocks                  int                      `json:"blocks"`
	BlocksReceived          int                      `json:"blocksReceived"` // times the player got blocked?
	FieldGoalsAttempted     int                      `json:"fieldGoalsAttempted"`
	FieldGoalsMade          int                      `json:"fieldGoalsMade"`
	FieldGoalsPercentage    float64                  `json:"fieldGoalsPercentage"` // ex. 0.444444444444444
	FoulsOffensive          int                      `json:"foulsOffensive"`
	FoulsDrawn              int                      `json:"foulsDrawn"`
	FoulsPersonal           int                      `json:"foulsPersonal"`
	FoulsTechnical          int                      `json:"foulsTechnical"`
	FreeThrowsAttempted     int                      `json:"freeThrowsAttempted"`
	FreeThrowsMade          int                      `json:"freeThrowsMade"`
	FreeThrowsPercentage    float64                  `json:"freeThrowsPercentage"` // ex. 1
	Minus                   float64                  `json:"minus"`                // boxscore minus
	Minutes                 duration                 `json:"minutes"`              // ex. PT34M43.00S
	MinutesCalculated       BoxscoreGameClockMinutes `json:"minutesCalculated"`    // ex. PT35M, PT00M
	Plus                    float64                  `json:"plus"`                 // boxscore plus
	PlusMinus               float64                  `json:"plusMinusPoints"`      // boxscore plus minus
	Points                  int                      `json:"points"`
	PointsFastBreak         int                      `json:"pointsFastBreak"`
	PointsInThePaint        int                      `json:"pointsInThePaint"`
	PointsSecondChance      int                      `json:"pointsSecondChance"`
	ReboundsDefensive       int                      `json:"reboundsDefensive"`
	ReboundsOffensive       int                      `json:"reboundsOffensive"`
	ReboundsTotal           int                      `json:"reboundsTotal"`
	Steals                  int                      `json:"steals"`
	ThreePointersAttempted  int                      `json:"threePointersAttempted"`
	ThreePointersMade       int                      `json:"threePointersMade"`
	ThreePointersPercentage float64                  `json:"threePointersPercentage"` // ex. 0.2
	Turnovers               int                      `json:"turnovers"`
	TwoPointersAttempted    int                      `json:"twoPointersAttempted"`
	TwoPointersMade         int                      `json:"twoPointersMade"`
	TwoPointersPercentage   float64                  `json:"twoPointersPercentage"`
}

type BoxscoreSummary

type BoxscoreSummary struct {
	GameDate            time.Time
	GameInSequence      int // ex. game in season series between opponents or playoff round game number
	GameID              string
	GameStatusID        GameStatus // ex. [1 - scheduled, 2 - in progress, 3 - final]
	GameStatusText      string     // ex. Final
	GameCode            string     // ex. 20180207/MINCLE
	HomeTeam            BoxscoreSummaryTeam
	AwayTeam            BoxscoreSummaryTeam
	SeasonStartYear     int
	Period              int
	PCTime              string // no idea what this is
	TVBroadcasts        []BoxscoreSummaryTVBroadcast
	WHStatus            int // no idea what this is
	Attendance          int
	GameDurationSeconds time.Duration
	//"GAME_DATE_EST",
	//"GAME_SEQUENCE",
	//"GAME_ID",
	//"GAME_STATUS_ID",
	//"GAME_STATUS_TEXT",
	//"GAMECODE",
	//"HOME_TEAM_ID",
	//"VISITOR_TEAM_ID",
	//"SEASON",
	//"LIVE_PERIOD",
	//"LIVE_PC_TIME",
	//"NATL_TV_BROADCASTER_ABBREVIATION",
	//"LIVE_PERIOD_TIME_BCAST",
	//"WH_STATUS"
	Teams      []BoxscoreSummaryTeam
	Officials  []BoxscoreSummaryOfficial
	LineScores []BoxscoreSummaryLineScore
	GameInfo   BoxscoreSummaryGameInfo
}

type BoxscoreSummaryGameInfo

type BoxscoreSummaryGameInfo struct {
}

type BoxscoreSummaryLineScore

type BoxscoreSummaryLineScore struct {
	TeamID int
	Points int
}

type BoxscoreSummaryOfficial

type BoxscoreSummaryOfficial struct {
	OfficialID   int
	FirstName    string
	LastName     string
	JerseyNumber string
}

type BoxscoreSummaryTVBroadcast

type BoxscoreSummaryTVBroadcast struct {
	NationalTVBroadcasterAbbreviation *string // ex. ESPN
	PeriodTimeBroadcast               string  // ex. Q5  - ESPN
}

type BoxscoreSummaryTeam

type BoxscoreSummaryTeam struct {
	LeagueID           string
	TeamID             int
	TeamAbbreviation   string
	TeamCity           string
	PointsInPaint      int
	PointsSecondChance int
	PointsFastBreak    int
	LargestLead        int

	//"LEAGUE_ID",
	//"TEAM_ID",
	//"TEAM_ABBREVIATION",
	//"TEAM_CITY",
	//"PTS_PAINT",
	//"PTS_2ND_CHANCE",
	//"PTS_FB",
	//"LARGEST_LEAD",
	//"LEAD_CHANGES",
	//"TIMES_TIED",
	//"TEAM_TURNOVERS",
	//"TOTAL_TURNOVERS",
	//"TEAM_REBOUNDS",
	//"PTS_OFF_TO"
	LineScores []boxscoreSummaryLineScore
}

type BoxscoreTeam

type BoxscoreTeam struct {
	ID                int                    `json:"teamId"`
	Name              string                 `json:"teamName"`
	City              string                 `json:"teamCity"`
	Tricode           string                 `json:"teamTricode"`
	Points            int                    `json:"score"`
	InBonus           string                 `json:"inBonus"` // ex. [0,1]
	TimeoutsRemaining int                    `json:"timeoutsRemaining"`
	Periods           []BoxscorePeriod       `json:"periods"`
	Players           []BoxscorePlayer       `json:"players"`
	Statistics        BoxscoreTeamStatistics `json:"statistics"`
}

type BoxscoreTeamStatistics

type BoxscoreTeamStatistics struct {
	Assists                      int      `json:"assists"`
	AssistsToTurnoverRatio       float64  `json:"assistsTurnoverRatio"` // ex. 0.866666666666667
	BenchPoints                  int      `json:"benchPoints"`
	BiggestLead                  int      `json:"biggestLead"`
	BiggestLeadScore             string   `json:"biggestLeadScore"` // ex. 16-29
	BiggestScoringRun            int      `json:"biggestScoringRun"`
	BiggestScoringRunScore       string   `json:"biggestScoringRunScore"` // ex. 35-29
	Blocks                       int      `json:"blocks"`
	BlocksReceived               int      `json:"blocksReceived"` // times the team got blocked?
	FastBreakPointsAttempted     int      `json:"fastBreakPointsAttempted"`
	FastBreakPointsMade          int      `json:"fastBreakPointsMade"`
	FastBreakPointsPercentage    float64  `json:"fastBreakPointsPercentage"` // ex. 0.375
	FieldGoalsAttempted          int      `json:"fieldGoalsAttempted"`
	FieldGoalsEffectiveAdjusted  float64  `json:"fieldGoalsEffectiveAdjusted"` // ex. 0.41538461538461496
	FieldGoalsMade               int      `json:"fieldGoalsMade"`
	FieldGoalsPercentage         float64  `json:"fieldGoalsPercentage"` // ex. 0.444444444444444
	FoulsOffensive               int      `json:"foulsOffensive"`
	FoulsDrawn                   int      `json:"foulsDrawn"`
	FoulsPersonal                int      `json:"foulsPersonal"`
	FoulsTeam                    int      `json:"foulsTeam"`
	FoulsTechnical               int      `json:"foulsTechnical"`
	FoulsTeamTechnical           int      `json:"foulsTeamTechnical"`
	FreeThrowsAttempted          int      `json:"freeThrowsAttempted"`
	FreeThrowsMade               int      `json:"freeThrowsMade"`
	FreeThrowsPercentage         float64  `json:"freeThrowsPercentage"` // ex. 1
	LeadChanges                  int      `json:"leadChanges"`
	Minutes                      duration `json:"minutes"`           // ex. PT34M43.00S
	MinutesCalculated            duration `json:"minutesCalculated"` // ex. PT35M, PT00M
	Points                       int      `json:"points"`
	PointsAgainst                int      `json:"pointsAgainst"`
	PointsFastBreak              int      `json:"pointsFastBreak"`
	PointsOffTurnovers           int      `json:"pointsFromTurnovers"`
	PointsInThePaint             int      `json:"pointsInThePaint"`
	PointsInThePaintAttempted    int      `json:"pointsInThePaintAttempted"`
	PointsInThePaintMade         int      `json:"pointsInThePaintMade"`
	PointsInThePaintPercentage   float64  `json:"pointsInThePaintPercentage"` // ex. 0.5
	PointsSecondChance           int      `json:"pointsSecondChance"`
	PointsSecondChanceAttempted  int      `json:"secondChancePointsAttempted"`
	PointsSecondChanceMade       int      `json:"secondChancePointsMade"`
	PointsSecondChancePercentage float64  `json:"secondChancePointsPercentage"`
	ReboundsDefensive            int      `json:"reboundsDefensive"`
	ReboundsOffensive            int      `json:"reboundsOffensive"`
	ReboundsPersonal             int      `json:"reboundsPersonal"` // rebounds made by one player?
	ReboundsTeam                 int      `json:"reboundsTeam"`     // from nba.com No individual rebound is credited in situations where the whistle stops play before there is player possession following a shot attempt. Instead only a team rebound is credited to the team that gains possession following a stop in play. For example, if the ball goes out of bounds after the field goal attempt, a team rebound is awarded to the team in white since no player secured possession.
	ReboundsTeamDefensive        int      `json:"reboundsTeamDefensive"`
	ReboundsTeamOffensive        int      `json:"reboundsTeamOffensive"`
	ReboundsTotal                int      `json:"reboundsTotal"`
	Steals                       int      `json:"steals"`
	ThreePointersAttempted       int      `json:"threePointersAttempted"`
	ThreePointersMade            int      `json:"threePointersMade"`
	ThreePointersPercentage      float64  `json:"threePointersPercentage"` // ex. 0.2
	TimeLeading                  duration `json:"timeLeading"`             // ex. PT09M26.00S
	TimesTied                    int      `json:"timesTied"`
	TrueShootingAttempts         float64  `json:"trueShootingAttempts"`   // ex. 71.72
	TrueShootingPercentage       float64  `json:"trueShootingPercentage"` // ex. 0.53680981595092
	Turnovers                    int      `json:"turnovers"`
	TurnoversTeam                int      `json:"turnoversTeam"` // 5 second inbound violation, 24 second shot clock violation or others not attributable to a single player
	TurnoversTotal               int      `json:"turnoversTotal"`
	TwoPointersAttempted         int      `json:"twoPointersAttempted"`
	TwoPointersMade              int      `json:"twoPointersMade"`
	TwoPointersPercentage        float64  `json:"twoPointersPercentage"`
}

type Client

type Client struct {
	Cache ObjectCacher
	// contains filtered or unexported fields
}

func NewClient

func NewClient(cache ObjectCacher, options ...rlhttp.ClientOption) Client

func (Client) CommonTeamInfo

func (c Client) CommonTeamInfo(ctx context.Context, leagueID string, teamID int) (TeamCommonInfo, error)

func (Client) CurrentLeagueSchedule

func (c Client) CurrentLeagueSchedule(ctx context.Context, objectKey string) (LeagueSchedule, error)

func (Client) FranchiseHistory

func (c Client) FranchiseHistory(ctx context.Context, leagueID string) ([]Franchise, error)

func (Client) GetBoxscoreDetailed

func (c Client) GetBoxscoreDetailed(ctx context.Context, gameID string, objectKey string) (Boxscore, error)

preferred: new boxscore with more stats, details, ids. however, returns error if game is in the future

func (Client) GetBoxscoreSummary

func (c Client) GetBoxscoreSummary(ctx context.Context, gameID string, objectKey string) (BoxscoreSummary, error)

func (Client) GetTodaysScoreboard

func (c Client) GetTodaysScoreboard(ctx context.Context, objectKey string) (TodaysScoreboard, error)

func (*Client) LeagueGameLog

func (c *Client) LeagueGameLog(ctx context.Context, seasonStartYear int, seasonType SeasonType) ([]GameLog, error)

func (Client) PlayByPlayForGame

func (c Client) PlayByPlayForGame(ctx context.Context, gameID string, outputWriters ...OutputWriter) (PlayByPlay, error)

func (Client) PlayByPlayV3ForGame

func (c Client) PlayByPlayV3ForGame(ctx context.Context, gameID string, outputWriters ...OutputWriter) (PlayByPlayV3, error)

func (Client) TeamStandings

func (c Client) TeamStandings(ctx context.Context, leagueID string, seasonStartYear int, seasonType SeasonType) ([]TeamStanding, error)

type Franchise

type Franchise struct {
	LeagueID           string
	TeamID             int
	City               string
	Name               string
	StartYear          int
	EndYear            int
	Years              int
	Games              int
	Wins               int
	Losses             int
	PlayoffAppearances int
	DivisionTitles     int
	ConferenceTitles   int
	LeagueTitles       int
	Active             bool
	TeamSeasons        []TeamSeason
}

type Game

type Game struct {
	GameID           string     `json:"gameId"`
	GameCode         string     `json:"gameCode"`
	GameStatus       GameStatus `json:"gameStatus"`
	GameStatusText   string     `json:"gameStatusText"`
	GameSequence     int        `json:"gameSequence"`
	GameDateEst      time.Time  `json:"gameDateEst"`
	GameTimeEst      time.Time  `json:"gameTimeEst"`
	GameDateTimeEst  time.Time  `json:"gameDateTimeEst"`
	GameDateUTC      time.Time  `json:"gameDateUTC"`
	GameTimeUTC      time.Time  `json:"gameTimeUTC"`
	GameDateTimeUTC  time.Time  `json:"gameDateTimeUTC"`
	AwayTeamTime     time.Time  `json:"awayTeamTime"`
	HomeTeamTime     time.Time  `json:"homeTeamTime"`
	Day              string     `json:"day"`
	MonthNum         int        `json:"monthNum"`
	WeekNumber       int        `json:"weekNumber"`
	WeekName         string     `json:"weekName"`
	IfNecessary      bool       `json:"ifNecessary"`
	SeriesGameNumber string     `json:"seriesGameNumber"`
	SeriesText       string     `json:"seriesText"` // ex. "Preseason"
	ArenaName        string     `json:"arenaName"`
	ArenaState       string     `json:"arenaState"`
	ArenaCity        string     `json:"arenaCity"`
	PostponedStatus  string     `json:"postponedStatus"`
	BranchLink       string     `json:"branchLink"`
	Broadcasters     struct {
		NationalTvBroadcasters []struct {
			BroadcasterScope        string `json:"broadcasterScope"`
			BroadcasterMedia        string `json:"broadcasterMedia"`
			BroadcasterID           int    `json:"broadcasterId"`
			BroadcasterDisplay      string `json:"broadcasterDisplay"`
			BroadcasterAbbreviation string `json:"broadcasterAbbreviation"`
			TapeDelayComments       string `json:"tapeDelayComments"`
			RegionID                int    `json:"regionId"`
		} `json:"nationalTvBroadcasters"`
		NationalRadioBroadcasters []interface{} `json:"nationalRadioBroadcasters"`
		HomeTvBroadcasters        []struct {
			BroadcasterScope        string `json:"broadcasterScope"`
			BroadcasterMedia        string `json:"broadcasterMedia"`
			BroadcasterID           int    `json:"broadcasterId"`
			BroadcasterDisplay      string `json:"broadcasterDisplay"`
			BroadcasterAbbreviation string `json:"broadcasterAbbreviation"`
			TapeDelayComments       string `json:"tapeDelayComments"`
			RegionID                int    `json:"regionId"`
		} `json:"homeTvBroadcasters"`
		HomeRadioBroadcasters []struct {
			BroadcasterScope        string `json:"broadcasterScope"`
			BroadcasterMedia        string `json:"broadcasterMedia"`
			BroadcasterID           int    `json:"broadcasterId"`
			BroadcasterDisplay      string `json:"broadcasterDisplay"`
			BroadcasterAbbreviation string `json:"broadcasterAbbreviation"`
			TapeDelayComments       string `json:"tapeDelayComments"`
			RegionID                int    `json:"regionId"`
		} `json:"homeRadioBroadcasters"`
		AwayTvBroadcasters    []interface{} `json:"awayTvBroadcasters"`
		AwayRadioBroadcasters []struct {
			BroadcasterScope        string `json:"broadcasterScope"`
			BroadcasterMedia        string `json:"broadcasterMedia"`
			BroadcasterID           int    `json:"broadcasterId"`
			BroadcasterDisplay      string `json:"broadcasterDisplay"`
			BroadcasterAbbreviation string `json:"broadcasterAbbreviation"`
			TapeDelayComments       string `json:"tapeDelayComments"`
			RegionID                int    `json:"regionId"`
		} `json:"awayRadioBroadcasters"`
		IntlRadioBroadcasters []interface{} `json:"intlRadioBroadcasters"`
		IntlTvBroadcasters    []interface{} `json:"intlTvBroadcasters"`
	} `json:"broadcasters"`
	HomeTeam struct {
		TeamID      int    `json:"teamId"`
		TeamName    string `json:"teamName"`
		TeamCity    string `json:"teamCity"`
		TeamTricode string `json:"teamTricode"`
		TeamSlug    string `json:"teamSlug"`
		Wins        int    `json:"wins"`
		Losses      int    `json:"losses"`
		Score       int    `json:"score"`
		Seed        int    `json:"seed"`
	} `json:"homeTeam"`
	AwayTeam struct {
		TeamID      int    `json:"teamId"`
		TeamName    string `json:"teamName"`
		TeamCity    string `json:"teamCity"`
		TeamTricode string `json:"teamTricode"`
		TeamSlug    string `json:"teamSlug"`
		Wins        int    `json:"wins"`
		Losses      int    `json:"losses"`
		Score       int    `json:"score"`
		Seed        int    `json:"seed"`
	} `json:"awayTeam"`
	PointsLeaders []struct {
		PersonID    int     `json:"personId"`
		FirstName   string  `json:"firstName"`
		LastName    string  `json:"lastName"`
		TeamID      int     `json:"teamId"`
		TeamCity    string  `json:"teamCity"`
		TeamName    string  `json:"teamName"`
		TeamTricode string  `json:"teamTricode"`
		Points      float64 `json:"points"`
	} `json:"pointsLeaders"`
}

type GameDuration

type GameDuration struct {
	Hours   string `json:"hours"`
	Minutes string `json:"minutes"`
}

type GameLog

type GameLog struct {
	GameID               string
	HomeTeam             TeamGameLog
	AwayTeamID           TeamGameLog
	TotalDurationMinutes int
}

type GameScoreboard

type GameScoreboard struct {
	Active       bool             `json:"isGameActivated"`
	GameDuration GameDuration     `json:"gameDuration"`
	ID           string           `json:"gameId"`
	Period       Period           `json:"period"`
	StartTimeUTC time.Time        `json:"startTimeUTC"`
	EndTimeUTC   time.Time        `json:"endTimeUTC,omitempty"`
	HomeTeamInfo TeamBoxscoreInfo `json:"hTeam"`
	AwayTeamInfo TeamBoxscoreInfo `json:"vTeam"`
}

type GameStatus

type GameStatus int
const (
	GameStatusScheduled GameStatus = 1
	GameStatusStarted   GameStatus = 2
	GameStatusCompleted GameStatus = 3
)

type GameVideoBroadcastInfo

type GameVideoBroadcastInfo struct {
	LeaguePass bool `json:"isLeaguePass"`
}

type LeagueSchedule

type LeagueSchedule struct {
	Meta struct {
		Version int       `json:"version"`
		Request string    `json:"request"`
		Time    time.Time `json:"time"`
	} `json:"meta"`
	LeagueSchedule struct {
		SeasonYear string `json:"seasonYear"` // ex. 2022-23
		LeagueID   string `json:"leagueId"`
		GameDates  []struct {
			GameDate string `json:"gameDate"`
			Games    []Game `json:"games"`
		} `json:"gameDates"`
		Weeks []struct {
			WeekNumber int       `json:"weekNumber"`
			WeekName   string    `json:"weekName"`
			StartDate  time.Time `json:"startDate"`
			EndDate    time.Time `json:"endDate"`
		} `json:"weeks"`
		BroadcasterList []struct {
			BroadcasterID           int    `json:"broadcasterId"`
			BroadcasterDisplay      string `json:"broadcasterDisplay"`
			BroadcasterAbbreviation string `json:"broadcasterAbbreviation"`
			RegionID                int    `json:"regionId"`
		} `json:"broadcasterList"`
	} `json:"leagueSchedule"`
}

type ObjectCacher

type ObjectCacher interface {
	// GetObject gets the object given the key from the cache; returns ErrNotFound if the object is not found in the cache
	GetObject(ctx context.Context, key string) ([]byte, error)
	PutObject(ctx context.Context, key string, obj io.Reader) error
}

ObjectCacher defines the interface to implement to use for caching nba calls.

type OutputWriter

type OutputWriter interface {
	Put(ctx context.Context, b []byte) error
}

type Period

type Period struct {
	Current int `json:"current"`
}

type PlayByPlay

type PlayByPlay struct {
	Meta struct {
		Version int    `json:"version"`
		Code    int    `json:"code"`
		Request string `json:"request"`
		Time    string `json:"time"`
	} `json:"meta"`
	Game struct {
		GameID  string `json:"gameId"`
		Actions []struct {
			ActionNumber             int       `json:"actionNumber"`
			Clock                    duration  `json:"clock"`
			TimeActual               time.Time `json:"timeActual"`
			Period                   int       `json:"period"`
			PeriodType               string    `json:"periodType"`
			ActionType               string    `json:"actionType"`
			SubType                  string    `json:"subType,omitempty"`
			Qualifiers               []string  `json:"qualifiers"` // ex. ["2ndchance"], ["pointsinthepaint"], ["pointsinthepaint", "2ndchance"], ["fromturnover"]
			PersonID                 int       `json:"personId"`
			X                        *float64  `json:"x"`
			Y                        *float64  `json:"y"`
			Possession               int       `json:"possession"`
			ScoreHome                string    `json:"scoreHome"`
			ScoreAway                string    `json:"scoreAway"`
			Edited                   time.Time `json:"edited"`
			OrderNumber              int       `json:"orderNumber"`
			XLegacy                  *int      `json:"xLegacy"`
			YLegacy                  *int      `json:"yLegacy"`
			IsFieldGoal              int       `json:"isFieldGoal"`
			Side                     *string   `json:"side"` // ex. "left", "right"
			Description              string    `json:"description,omitempty"`
			PersonIdsFilter          []int     `json:"personIdsFilter"`
			TeamID                   int       `json:"teamId,omitempty"`
			TeamTricode              string    `json:"teamTricode,omitempty"`
			Descriptor               string    `json:"descriptor,omitempty"`
			JumpBallRecoveredName    string    `json:"jumpBallRecoveredName,omitempty"`
			JumpBallRecoverdPersonID int       `json:"jumpBallRecoverdPersonId,omitempty"`
			PlayerName               string    `json:"playerName,omitempty"`
			PlayerNameI              string    `json:"playerNameI,omitempty"`
			JumpBallWonPlayerName    *string   `json:"jumpBallWonPlayerName,omitempty"`
			JumpBallWonPersonID      *int      `json:"jumpBallWonPersonId,omitempty"`
			JumpBallLostPlayerName   *string   `json:"jumpBallLostPlayerName,omitempty"`
			JumpBallLostPersonID     *int      `json:"jumpBallLostPersonId,omitempty"`
			ShotDistance             float64   `json:"shotDistance,omitempty"`
			ShotResult               string    `json:"shotResult,omitempty"`
			PointsTotal              int       `json:"pointsTotal,omitempty"`
			AssistPlayerNameInitial  *string   `json:"assistPlayerNameInitial,omitempty"`
			AssistPersonID           *int      `json:"assistPersonId,omitempty"`
			AssistTotal              *int      `json:"assistTotal,omitempty"`
			OfficialID               int       `json:"officialId,omitempty"`
			ShotActionNumber         int       `json:"shotActionNumber,omitempty"`
			ReboundTotal             int       `json:"reboundTotal,omitempty"`
			ReboundDefensiveTotal    int       `json:"reboundDefensiveTotal,omitempty"`
			ReboundOffensiveTotal    int       `json:"reboundOffensiveTotal,omitempty"`
			FoulPersonalTotal        int       `json:"foulPersonalTotal,omitempty"`
			FoulTechnicalTotal       int       `json:"foulTechnicalTotal,omitempty"`
			FoulDrawnPlayerName      *string   `json:"foulDrawnPlayerName,omitempty"`
			FoulDrawnPersonID        *int      `json:"foulDrawnPersonId,omitempty"`
			TurnoverTotal            int       `json:"turnoverTotal,omitempty"`
			StealPlayerName          *string   `json:"stealPlayerName,omitempty"`
			StealPersonID            *int      `json:"stealPersonId,omitempty"`
			Value                    string    `json:"value,omitempty"`
			BlockPlayerName          *string   `json:"blockPlayerName,omitempty"`
			BlockPersonID            *int      `json:"blockPersonId,omitempty"`
		} `json:"actions"`
	} `json:"game"`
}

type PlayByPlayV3

type PlayByPlayV3 struct {
	Meta struct {
		Version int       `json:"version"`
		Request string    `json:"request"`
		Time    time.Time `json:"time"`
	} `json:"meta"`
	Game struct {
		GameID         string `json:"gameId"`
		VideoAvailable int    `json:"videoAvailable"`
		Actions        []struct {
			ActionNumber   int    `json:"actionNumber"`
			Clock          string `json:"clock"`
			Period         int    `json:"period"`
			TeamID         int    `json:"teamId"`
			TeamTricode    string `json:"teamTricode"`
			PersonID       int    `json:"personId"`
			PlayerName     string `json:"playerName"`
			PlayerNameI    string `json:"playerNameI"`
			XLegacy        int    `json:"xLegacy"`
			YLegacy        int    `json:"yLegacy"`
			ShotDistance   int    `json:"shotDistance"`
			ShotResult     string `json:"shotResult"`
			IsFieldGoal    int    `json:"isFieldGoal"`
			ScoreHome      string `json:"scoreHome"`
			ScoreAway      string `json:"scoreAway"`
			PointsTotal    int    `json:"pointsTotal"`
			Location       string `json:"location"`
			Description    string `json:"description"`
			ActionType     string `json:"actionType"`
			SubType        string `json:"subType"`
			VideoAvailable int    `json:"videoAvailable"`
			ActionID       int    `json:"actionId"`
		} `json:"actions"`
	} `json:"game"`
}

type Player

type Player struct {
	ID              string `json:"personId"`
	TeamID          string `json:"teamId"`
	FirstName       string `json:"firstName"`
	LastName        string `json:"lastName"`
	Jersey          string `json:"jersey"`
	CurrentlyInNBA  bool   `json:"isActive"`
	Position        string `json:"pos"`
	HeightFeet      string `json:"heightFeet"`
	HeightInches    string `json:"heightInches"`
	HeightMeters    string `json:"heightMeters"`
	WeightPounds    string `json:"weightPounds"`
	WeightKilograms string `json:"weightKilograms"`
	DateOfBirthUTC  string `json:"dateOfBirthUTC"` // this is in format yyyy-mm-dd (nba.TimeBirthdateFormat)
	NBADebutYear    string `json:"nbaDebutYear"`
	YearsPro        string `json:"yearsPro"`
	CollegeName     string `json:"collegeName"`
	LastAffiliation string `json:"lastAffiliation"`
	Country         string `json:"country"`
}

func GetPlayers

func GetPlayers(seasonStartYear int) ([]Player, error)

type PlayerStats

type PlayerStats struct {
	ID                    string `json:"personId"`
	TeamID                string `json:"teamId"`
	Points                string `json:"points"`
	Minutes               string `json:"min"`
	FieldGoalsMade        string `json:"fgm"`
	FieldGoalsAttempted   string `json:"fga"`
	FieldGoalPercentage   string `json:"fgp"`
	FreeThrowsMade        string `json:"ftm"`
	FreeThrowsAttempted   string `json:"fta"`
	FreeThrowsPercentage  string `json:"ftp"`
	ThreePointsMade       string `json:"tpm"`
	ThreePointsAttempted  string `json:"tpa"`
	ThreePointsPercentage string `json:"tpp"`
	OffensiveRebounds     string `json:"offReb"`
	DefensiveRebounds     string `json:"defReb"`
	TotalRebounds         string `json:"totReb"`
	Assists               string `json:"assists"`
	PersonalFouls         string `json:"pfouls"`
	Steals                string `json:"steals"`
	Turnovers             string `json:"turnovers"`
	Blocks                string `json:"blocks"`
	PlusMinus             string `json:"plusMinus"`
	DidNotPlayStatus      string `json:"dnp"`
}

type Players

type Players struct {
	LeagueNode struct {
		Players []Player `json:"standard"`
	} `json:"league"`
}

type RefereeInfo

type RefereeInfo struct {
	FullName string `json:"firstNameLastName"`
}

type Scoreboard

type Scoreboard struct {
	Games []GameScoreboard `json:"games"`
}

type ScoreboardDetailed

type ScoreboardDetailed struct {
	GameDate   string `json:"gameDate"`   // ex. 2021-11-08
	LeagueID   string `json:"leagueId"`   // ex. 00 for NBA, 15 for Las Vegas, 13 for California classical, 16 for Utah, and 14 for Orlando
	LeagueName string `json:"leagueName"` // ex. National Basketball Association
	Games      []struct {
		GameID            string         `json:"gameId"`         // ex. 20211108
		GameCode          string         `json:"gameCode"`       // ex. 20211108/NYKPHI
		GameStatus        int            `json:"gameStatus"`     // ex. 1
		GameStatusText    string         `json:"gameStatusText"` // ex. 7:00 pm ET
		Period            int            `json:"period"`
		GameClock         duration       `json:"gameClock"`
		GameTimeUTC       time.Time      `json:"gameTimeUTC"`
		GameTimeET        time.Time      `json:"gameTimeET"`
		RegulationPeriods int            `json:"regulationPeriods"`
		IfNecessary       bool           `json:"ifNecessary"`
		SeriesGameNumber  string         `json:"seriesGameNumber"`
		SeriesText        SeriesText     `json:"seriesText"`
		HomeTeam          TeamScoreboard `json:"homeTeam"`
		AwayTeam          TeamScoreboard `json:"awayTeam"`
	} `json:"games"`
	GameLeaders struct {
		HomeTeamLeaders ScoreboardTeamLeaders `json:"homeLeaders"`
		AwayTeamLeaders ScoreboardTeamLeaders `json:"awayLeaders"`
	} `json:"gameLeaders"`
}

type ScoreboardTeamLeaders

type ScoreboardTeamLeaders struct {
	PersonID     int     `json:"personId"`
	Name         string  `json:"name"`
	JerseyNumber string  `json:"jerseyNum"`
	Position     string  `json:"position"`
	TeamTricode  string  `json:"teamTricode"`
	PlayerSlug   *string `json:"playerSlug"`
	Points       int     `json:"points"`
	Rebounds     int     `json:"rebounds"`
	Assists      int     `json:"assists"`
}

type SeasonStage

type SeasonStage string
const (
	SeasonStagePreseason SeasonStage = "Preseason"
	SeasonStageRegular   SeasonStage = ""         // NBA appears to use empty string as regular season game for SeriesText in its API
	SeasonStageAllStar   SeasonStage = "AllStar"  // TODO: this is a guess
	SeasonStagePost      SeasonStage = "Playoffs" // TODO: this is a guess
	SeasonStagePlayIn    SeasonStage = "PlayIn"   // TODO: this is a guess
)

type SeasonType

type SeasonType string
const (
	SeasonTypeRegular       SeasonType = "Regular Season"
	SeasonTypePre           SeasonType = "Pre Season"
	SeasonTypePlayoffs      SeasonType = "Playoffs"
	SeasonTypeAllStar       SeasonType = "All Star"
	SeasonTypeAllStarHyphen SeasonType = "All-Star"
)

type SeriesText

type SeriesText string
const (
	SeriesTextEmpty               SeriesText = "" // "" - this is probably just always regular season
	SeriesTextISTChampionship     SeriesText = "Championship"
	SeriesTextISTEastGroupA       SeriesText = "East Group A"         // In season tournament
	SeriesTextISTEastGroupB       SeriesText = "East Group B"         // In season tournament
	SeriesTextISTEastGroupC       SeriesText = "East Group C"         // In season tournament
	SeriesTextISTEastQuarterFinal SeriesText = "East Quarterfinal"    // In season tournament
	SeriesTextISTEastSemiFinal    SeriesText = "East Semifinal"       // In season tournament
	SeriesTextMexicoCityGame      SeriesText = "NBA Mexico City Game" // Regular season
	SeriesTextParisGame           SeriesText = "NBA Paris Game"       // Regular season
	SeriesTextPreseason           SeriesText = "Preseason"
	SeriesTextISTWestGroupA       SeriesText = "West Group A"      // In season tournament
	SeriesTextISTWestGroupB       SeriesText = "West Group B"      // In season tournament
	SeriesTextISTWestGroupC       SeriesText = "West Group C"      // In season tournament
	SeriesTextISTWestQuarterFinal SeriesText = "West Quarterfinal" // In season tournament
	SeriesTextISTWestSemiFinal    SeriesText = "West Semifinal"    // In season tournament
)

type TeamBoxscoreInfo

type TeamBoxscoreInfo struct {
	TeamID          string  `json:"teamId"`
	TriCode         TriCode `json:"triCode"`
	Wins            string  `json:"win"`
	Losses          string  `json:"loss"`
	SeriesWins      string  `json:"seriesWin"`
	SeriesLosses    string  `json:"seriesLoss"`
	Points          string  `json:"score"`
	PointsByQuarter []struct {
		Points string `json:"score"`
	} `json:"linescore"`
}

type TeamCommonInfo

type TeamCommonInfo struct {
	TeamID          int
	SeasonStartYear int
	SeasonEndYear   int
	City            string
	Name            string
	Abbreviation    string
	Conference      string
	Division        string
	Code            string
	Slug            string
	SeasonIDs       []int
}

type TeamGameLog

type TeamGameLog struct {
	TeamID                 int
	FieldGoalsMade         int
	FieldGoalsAttempted    *int
	ThreePointersMade      *int
	ThreePointersAttempted *int
	FreeThrowsMade         int
	FreeThrowsAttempted    int
	OffensiveRebounds      *int
	DefensiveRebounds      *int
	TotalRebounds          *int
	Assists                *int
	Steals                 *int
	Blocks                 *int
	Turnovers              *int
	PersonalFouls          *int
	Points                 int
	PlusMinus              int
}

type TeamLeaders

type TeamLeaders struct {
	PointsNode struct {
		Points      string `json:"value"`
		PlayersNode []struct {
			PlayerID string `json:"personId"`
		} `json:"players"`
	} `json:"points"`
	ReboundsNode struct {
		Rebounds    string `json:"value"`
		PlayersNode []struct {
			PlayerID string `json:"personId"`
		} `json:"players"`
	} `json:"points"`
	AssistsNode struct {
		Assists     string `json:"value"`
		AssistsNode []struct {
			PlayerID string `json:"personId"`
		} `json:"players"`
	} `json:"points"`

	PointsLeaders   []string
	Points          int
	ReboundsLeaders []string
	Rebounds        int
	AssistsLeaders  []string
	Assists         int
	BlocksLeaders   []string
	Blocks          int
	StealsLeaders   []string
	Steals          int
	// contains filtered or unexported fields
}

type TeamScoreboard

type TeamScoreboard struct {
	TeamID            int     `json:"teamId"`
	TeamName          string  `json:"teamName"` // ex. 76ers
	TeamCity          string  `json:"teamCity"`
	TeamTricode       string  `json:"tricode"`
	Wins              int     `json:"wins"`
	Losses            int     `json:"losses"`
	Score             int     `json:"score"`
	Seed              *int    `json:"seed"`    // ex. null
	InBonus           *string `json:"inBonus"` // ex. null
	TimeoutsRemaining int     `json:"timeoutsRemaining"`
	Periods           []struct {
		Period     int    `json:"period"`
		PeriodType string `json:"periodType"`
		Score      int    `json:"score"`
	} `json:"periods"`
}

type TeamSeason

type TeamSeason struct {
	Year int // year the season started
	City string
	Name string
}

type TeamStanding

type TeamStanding struct {
	LeagueID        string
	SeasonStartYear int
	SeasonType      SeasonType
	TeamID          int
	Conference      string
	Division        string
}

type TeamStats

type TeamStats struct {
	BiggestLead        string          `json:"biggestLead"`
	LongestRun         string          `json:"longestRun"`
	PointsInPaint      string          `json:"pointsInPaint"`
	PointsOffTurnovers string          `json:"pointsOffTurnovers"`
	SecondChancePoints string          `json:"secondChancePoints"`
	TeamStatsTotals    TeamStatsTotals `json:"totals"`
}

type TeamStatsTotals

type TeamStatsTotals struct {
	Points               string      `json:"points"`
	Minutes              duration    `json:"min"`
	FieldGoalsMade       string      `json:"fgm"`
	FieldGoalsAttempted  string      `json:"fga"`
	FieldGoalPercentage  string      `json:"fgp"`
	FreeThrowsMade       string      `json:"ftm"`
	FreeThrowsAttempted  string      `json:"fta"`
	FreeThrowPercentage  string      `json:"ftp"`
	ThreePointsMade      string      `json:"tpm"`
	ThreePointsAttempted string      `json:"tpa"`
	ThreePointPercentage string      `json:"tpp"`
	OffensiveRebounds    string      `json:"offReb"`
	DefensiveRebounds    string      `json:"defReb"`
	TotalRebounds        string      `json:"totReb"`
	Assists              string      `json:"assists"`
	PersonalFouls        string      `json:"pfouls"`
	Steals               string      `json:"steals"`
	Turnovers            string      `json:"turnovers"`
	Blocks               string      `json:"blocks"`
	PlusMinus            string      `json:"plusMinus"`
	TeamLeaders          TeamLeaders `json:"leaders"`
}

type TodaysScoreboard

type TodaysScoreboard struct {
	Scoreboard ScoreboardDetailed `json:"scoreboard"`
}

type TriCode

type TriCode string
const (
	AtlantaHawks          TriCode = "ATL"
	BostonCeltics         TriCode = "BOS"
	BrooklynNets          TriCode = "BKN"
	CharlotteHornets      TriCode = "CHA"
	ChicagoBulls          TriCode = "CHI"
	ClevelandCavaliers    TriCode = "CLE"
	DallasMavericks       TriCode = "DAL"
	DenverNuggets         TriCode = "DEN"
	DetroitPistons        TriCode = "DET"
	GoldenStateWarriors   TriCode = "GSW"
	HoustonRockets        TriCode = "HOU"
	IndianaPacers         TriCode = "IND"
	LosAngelesClippers    TriCode = "LAC"
	LosAngelesLakers      TriCode = "LAL"
	MemphisGrizzlies      TriCode = "MEM"
	MiamiHeat             TriCode = "MIA"
	MilwaukeeBucks        TriCode = "MIL"
	MinnesotaTimberwolves TriCode = "MIN"
	NewOrleansPelicans    TriCode = "NOP"
	NewYorkKnicks         TriCode = "NYK"
	OklahomaCityThunder   TriCode = "OKC"
	OrlandoMagic          TriCode = "ORL"
	Philadelphia76ers     TriCode = "PHI"
	PhoenixSuns           TriCode = "PHX"
	PortlandTrailblazers  TriCode = "POR"
	SacramentoKings       TriCode = "SAC"
	SanAntonioSpurs       TriCode = "SAS"
	TorontoRaptors        TriCode = "TOR"
	UtahJazz              TriCode = "UTA"
	WashingtonWizards     TriCode = "WAS"
)

type VideoBroadcasterInfo

type VideoBroadcasterInfo struct {
	ShortName string `json:"shortName"`
	LongName  string `json:"longName"`
}

Jump to

Keyboard shortcuts

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