jasonhancock / mlb

Go Client for the MLB API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Go Client for the MLB API

Go Report Card godoc license Coverage Build Status

API Client for MLB statsapi.mlb.com

Example Usage

import(
  "fmt"
  "time"

  "github.com/stevepartridge/mlb"
)

mlbApi, err := mlb.New()
if err != nil {
  fmt.Println("aww, bad things happened", err.Error())
}

teams, err := mlbApi.GetTeams()
if err != nil {
  fmt.Println("well, dang", err.Error())
}

for i := range teams {
  fmt.Println(teams[i].Name)
}

start, _ := time.Parse("2006/01/02", "2017/05/17")
end := start.AddDate(0, 1, 0) // one month

games, err := mlbApi.GetGamesByDateRange(start, end)
if err != nil {
  fmt.Println("well, dang", err.Error())
}

for i := range games {
  fmt.Printf("----- \n %+v \n-----\n\n", games[i])
}
Work in progress

This is a continued work in progress. For any of the unimplemented endpoints using the mlbApi.Call(...) method should work with any of them.

The full documention of the MLB API.

About

Go Client for the MLB API

License:MIT License


Languages

Language:Go 100.0%