gobert

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2023 License: MIT Imports: 10 Imported by: 0

README

BoxscGobertore

Go client to fetch NBA players and teams info, as well as game statistics from basketball reference

Usage

Installation
go get github.com/Funshinho/gobert
Importing
 import "github.com/Funshinho/gobert
Usage
players := gobert.GetPlayers(2023)               // Returns the roster for all teams
players := gobert.GetPlayers(2023, "MIA", "LAL") // Returns the roster for the given teams
teams := gobert.GetTeams()                       // Returns the list of teams

Documentation

Index

Constants

View Source
const NBA_REFERENCE_ENDPOINT = "https://basketball-reference.com"

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 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 {
	Url string
}

func NewClient

func NewClient(opts ...Option) *Client

func (Client) GetPlayers

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

GetPlayers returns the list of teams for the given season by list of teams, or all teams if no teams specified

func (Client) GetTeams

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

GetTeams returns the list of teams for the current season

type Game

type Game struct {
	ID         string
	HomeTeam   string
	VistorTeam string
}

Game represents the teams that were against

type Option

type Option func(client *Client)

func WithUrl

func WithUrl(url string) Option

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