boxscore

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 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"
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 GetMockServer

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

GetMockServer initializes the mock responses when calling data api

Types

type ApiClient added in v1.2.0

type ApiClient struct {
	Url string
}

func NewApiClient added in v1.2.0

func NewApiClient(url ...string) ApiClient

func (ApiClient) GetBoxscoreData added in v1.2.0

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

GetBoxscoreData returns the boxscore from a given date and game identifier

func (ApiClient) GetPlayerStatsData added in v1.2.0

func (c ApiClient) GetPlayerStatsData(year string, playerId string) map[string]interface{}

GetPlayerStatsData returns the list of statistics of a player until the given season (year)

func (ApiClient) GetPlayersData added in v1.2.0

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

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

func (ApiClient) GetScoreboardData added in v1.2.0

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

GetScoreboardData returns the scoreboard from a given date

func (ApiClient) GetTeamsData added in v1.2.0

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

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

type AverageStats added in v1.2.0

type AverageStats struct {
	PlayerID         string
	PointsPerGame    float64
	ReboundsPerGame  float64
	AssistsPerGame   float64
	BlocksPerGame    float64
	StealsPerGame    float64
	TurnoversPerGame float64
	FGP              float64 // Field goal percentage
	TPP              float64 // Three points percentage
	FTP              float64 // Free throw percentage
}

type Boxscore

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

Boxscore represents the boxscore of a game

type Client added in v1.2.0

type Client struct {
	ApiClient ApiClient
}

func NewClient added in v1.2.0

func NewClient(url ...string) Client

func (Client) GetBoxscore added in v1.2.0

func (c Client) 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 (Client) GetBoxscores added in v1.2.0

func (c Client) GetBoxscores(date string) []Boxscore

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

func (Client) GetGames added in v1.2.0

func (c Client) GetGames(date string) []Game

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

func (Client) GetPlayerStats added in v1.2.0

func (c Client) GetPlayerStats(year string, playerId string) AverageStats

GetPlayerStats returns the average stats of a player for the given season (ex 2021 for season 2021/2022)

func (Client) GetPlayers added in v1.2.0

func (c Client) GetPlayers(year string) []Player

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

func (Client) GetTeams added in v1.2.0

func (c Client) GetTeams(year string) []Team

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

type Game

type Game struct {
	ID         string
	HomeTeam   string
	VistorTeam string
}

Game represents the teams that were against

type Player

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

Player represents the player information

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

Jump to

Keyboard shortcuts

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