https://github.com/stevepartridge/mlb
Go Client for the MLB API
https://github.com/stevepartridge/mlb
api api-client client go mlb mlb-api
Last synced: 5 months ago
JSON representation
Go Client for the MLB API
- Host: GitHub
- URL: https://github.com/stevepartridge/mlb
- Owner: stevepartridge
- License: mit
- Created: 2015-04-01T09:01:07.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2023-01-10T18:21:30.000Z (over 3 years ago)
- Last Synced: 2025-08-14T19:18:23.375Z (10 months ago)
- Topics: api, api-client, client, go, mlb, mlb-api
- Language: Go
- Homepage:
- Size: 43.9 KB
- Stars: 3
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Go Client for the MLB API
[](https://goreportcard.com/report/github.com/stevepartridge/mlb)
[](https://godoc.org/github.com/stevepartridge/mlb)
[](https://raw.githubusercontent.com/stevepartridge/mlb/master/LICENSE)
[](http://gocover.io/github.com/stevepartridge/mlb)
[](https://travis-ci.org/stevepartridge/mlb)
API Client for MLB [statsapi.mlb.com](http://statsapi.mlb.com/docs/)
### Example Usage
```golang
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](http://statsapi.mlb.com/docs/).