boxscore

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: May 30, 2022 License: MIT Imports: 8 Imported by: 0

README

Boxscore

Go client to fetch NBA players and teams info, as well as game statistics from https://data.nba.net

Usage

Installation
go get github.com/Funshinho/boxscore
Importing
 import "github.com/Funshinho/boxscore/v2"
Usage
boxscores := boxscore.GetBoxscores("20220101")
players := boxscore.GetPlayers("2021")
teams := boxscore.GetTeams("2021")

Documentation

Index

Constants

View Source
const NBA_DATA_ENDPOINT = "https://data.nba.net/data/10s/prod/v1"

Variables

This section is empty.

Functions

func GetBoxscoreData

func GetBoxscoreData(date string, gameId string) map[string]interface{}

GetBoxscoreData returns the boxscore from a given date and game identifier

func GetMockServer

func GetMockServer(t *testing.T) *httptest.Server

GetMockServer initializes the mock responses when calling data api

func GetPlayersData added in v1.1.0

func GetPlayersData(year string) map[string]interface{}

GetPlayersData returns the list of players for a given season (year)

func GetScoreboardData

func GetScoreboardData(date string) map[string]interface{}

GetScoreboardData returns the scoreboard from a given date

func GetTeamsData added in v1.1.0

func GetTeamsData(year string) map[string]interface{}

GetTeamsData returns the list of players for a given season (year)

Types

type Boxscore

type Boxscore struct {
	HomeTeam   string
	VistorTeam string
	StatsList  []Stats
}

Boxscore represents the boxscore of a game

func GetBoxscore

func GetBoxscore(date string, homeTeam string, visitorTeam string) Boxscore

GetBoxscore returns the boxscore of a game between two teams that was played from a given date

func GetBoxscores

func GetBoxscores(date string) []Boxscore

GetBoxscores returns the list of boxscores that was played from a given date

type Game

type Game struct {
	ID         string
	HomeTeam   string
	VistorTeam string
}

Game represents the teams that were against

func GetGames

func GetGames(date string) []Game

GetGames returns the list of games that was played from a given date

type Player

type Player struct {
	ID        string
	TeamID    string
	FirstName string
	LastName  string
	Position  Position
}

Player represents the player information

func GetPlayers added in v1.1.0

func GetPlayers(year string) []Player

GetPlayers returns the list of players in a given season (ex 2021 for season 2021/2022)

type Position

type Position string
const (
	Forward Position = "F"
	Center  Position = "C"
	Guard   Position = "G"
)

type Stats

type Stats struct {
	PlayerID  string
	FirstName string
	LastName  string
	TeamID    string
	Points    int
	Rebounds  int
	Assists   int
	Blocks    int
	Steals    int
	Turnovers int
	Fouls     int
	FGM       int // Field goal made
	FGA       int // Field goal attempted
	TPM       int // Three points made
	TPA       int // Three points attempted
	FTM       int // Free throw made
	FTA       int // Free throw attempted
}

Stats represents the statistics of a player

type Team added in v1.1.0

type Team struct {
	ID      string
	Name    string
	Tricode string
}

Player represents the team information

func GetTeams added in v1.1.0

func GetTeams(year string) []Team

GetTeams returns the list of players in a given season (ex 2021 for season 2021/2022)

Jump to

Keyboard shortcuts

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