boxscore

package module
v2.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2023 License: MIT Imports: 11 Imported by: 0

README

Boxscore

Go client to fetch NBA players and teams info, as well as game statistics from RapidAPI endpoint

Usage

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

Documentation

Index

Constants

View Source
const NBA_DATA_ENDPOINT = "https://www.balldontlie.io/api/v1"
View Source
const NBA_DATA_ENDPOINT_V2 = "https://tank01-fantasy-stats.p.rapidapi.com"
View Source
const NBA_PLAYERS_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

type ApiClient struct {
	Url        string
	PlayersUrl string
}

func NewApiClient

func NewApiClient(url ...string) ApiClient

func (ApiClient) GetBoxscoreData

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

GetBoxscoreData returns the boxscore from a given date and game identifier

func (ApiClient) GetCurrentPlayersData added in v2.1.0

func (c ApiClient) GetCurrentPlayersData() (map[string]interface{}, error)

GetPlayersData returns the list of players for current season

func (ApiClient) GetPlayerData

func (c ApiClient) GetPlayerData(firstName string, lastName string) (map[string]interface{}, error)

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

func (ApiClient) GetPlayersData

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

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

func (ApiClient) GetScoreboardData

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

GetScoreboardData returns the scoreboard from a given date

func (ApiClient) GetTeamsData

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

GetTeamsData returns the list of teams for the current season

type ApiV2Client added in v2.1.0

type ApiV2Client struct {
	Url     string
	ApiKey  string
	ApiHost string
}

func NewApiV2Client added in v2.1.0

func NewApiV2Client(url string, apiKey string, apiHost string) ApiV2Client

func NewDefaultApiV2Client added in v2.1.0

func NewDefaultApiV2Client(apiKey string, apiHost string) ApiV2Client

func (ApiV2Client) GetBoxscoreData added in v2.1.0

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

GetBoxscoreData returns the boxscore from a given date and game identifier

func (ApiV2Client) GetCurrentPlayersData added in v2.1.0

func (c ApiV2Client) GetCurrentPlayersData() (map[string]interface{}, error)

GetCurrentPlayersData returns the list of players for current season

func (ApiV2Client) GetPlayerData added in v2.1.0

func (c ApiV2Client) GetPlayerData(firstName string, lastName string) (map[string]interface{}, error)

GetPlayerData returns the given player info from first and last name

func (ApiV2Client) GetPlayerDataByID added in v2.1.0

func (c ApiV2Client) GetPlayerDataByID(ID string) (map[string]interface{}, error)

GetPlayerData returns the given player info from its ID

func (ApiV2Client) GetPlayersData added in v2.1.0

func (c ApiV2Client) GetPlayersData(year string) (map[string]interface{}, error)

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

func (ApiV2Client) GetScoreboardData added in v2.1.0

func (c ApiV2Client) GetScoreboardData(date string) (map[string]interface{}, error)

GetScoreboardData returns the scoreboard from a given date

func (ApiV2Client) GetTeamsData added in v2.1.0

func (c ApiV2Client) GetTeamsData() (map[string]interface{}, error)

GetTeamsData returns the list of teams for the current season

type AverageStats

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

type Client struct {
	ApiClient ApiClient
}

func NewClient

func NewClient(url ...string) Client

func (Client) GetBoxscore

func (c Client) GetBoxscore(date string, homeTeam string, visitorTeam string) (Boxscore, error)

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

func (Client) GetBoxscores

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

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

func (Client) GetGames

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

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

func (Client) GetPlayers

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

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

func (Client) GetTeams

func (c Client) GetTeams() ([]Team, error)

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

type ClientV2 added in v2.1.0

type ClientV2 struct {
	ApiV2Client ApiV2Client
}

func NewClientV2 added in v2.1.0

func NewClientV2(url string, apiKey string, apiHost string) ClientV2

func NewDefaultClientV2 added in v2.1.0

func NewDefaultClientV2(apiKey string, apiHost string) ClientV2

func (ClientV2) GetBoxscore added in v2.1.0

func (c ClientV2) GetBoxscore(date string, homeTeam string, visitorTeam string) (Boxscore, error)

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

func (ClientV2) GetBoxscores added in v2.1.0

func (c ClientV2) GetBoxscores(date string) ([]Boxscore, error)

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

func (ClientV2) GetGames added in v2.1.0

func (c ClientV2) GetGames(date string) ([]Game, error)

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

func (ClientV2) GetPlayers added in v2.1.0

func (c ClientV2) GetPlayers() ([]Player, error)

GetPlayers returns the list of players for current season

func (ClientV2) GetTeams added in v2.1.0

func (c ClientV2) GetTeams() ([]Team, error)

GetTeams returns the list of players for the current season

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 (
	Center       Position = "C"
	Guard        Position = "G"
	PointGuard   Position = "PG"
	SmallGuard   Position = "SG"
	Forward      Position = "F"
	SmallForward Position = "SF"
	PowerForward Position = "PF"
)

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

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