A terminal user interface for the MLB Statcast API, written in Rust.
Check scores, standings, and stats. Even watch a live game using Gameday!
The MLB Statcast API is a publicly available (see its license information below) REST API that you can query to get back almost any information about a baseball game, past or present. If you've ever watched a baseball game on TV you've seen the data the API passes around in action. Two prime examples are the pitch/strike zone overlay, and home run stats (like distance and launch angle). This is accomplished by MLB's sophisticated Statcast vision system, which is implemented in every Major League ballpark.
This TUI is an interface for the API, with the intention of providing a light weight way to consume baseball data. See the features listed below for more details.
A TUI and baseball data make a pretty natural combination, at least compared to other sports. The Gameday view allows you to "watch" a live game by polling the API every 10 seconds. This matches the poll rate at which the official Gameday, found here, operates at. The goal with the TUI version is to mimic the official version as closely as possible.
brew tap mlb-rs/mlbt
brew install mlbt
To update to the latest version:
brew upgrade mlbt
macOS, Linux, and Windows binaries are available on the releases page.
After cloning or downloading the source:
cargo install mlbt --path .
Build image with:
docker build -t mlbt .
Execute mlbt
within the container with:
docker run -it --rm --name mlbt mlbt:latest
-
scoreboard and box score
- selectable date
-
gameday
-
standings
- team information
-
stats
- player stats
- team stats
-
CLI
-
configuration:
- favorite team
- time zone
- colors
- keymap
After installing, run mlbt
from you terminal to open the program.
Press q
to exit the program at any time.
There are four main tabs.
- Scoreboard
- Gameday
- Stats
- Standings
Press f
for full screen mode to hide the tab bar.
Press 1
to activate this tab.
j
: move downk
: move upEnter
: view current game in Gameday:
: activate date picker (see Date Picker)w
: toggle win probability graph
To switch the team displayed in the box score:
h
: home teama
: away team
Press 2
to activate this tab.
By default, the info
and pitches
panes are shown. However, each pane can be
toggled on and off using:
i
: info panep
: pitches paneb
: box score pane
To view different at bats in the game, use:
j
: move to previous playk
: move to next playl
: move to the "live" play, or the latest availables
: move to first play of the gamew
: toggle win probability graph
To switch the team displayed in the box score:
h
: home teama
: away team
Press 3
to activate this tab.
You can switch between pitching
and hitting
stats and filter based on team
or player
using:
p
: pitchingh
: hittingt
: teaml
: player
Within each stat group (pitching or hitting) you can toggle the display of
individual stat columns by selecting the stat with Enter
. This selection pane
can be turned on/off with o
.
To sort the stats by a column, instead of hitting Enter
you can press s
. To
flip the sort order from ascending to descending or vice versa press s
again.
j
: move downk
: move upEnter
: toggle stat columns
: sort by the currently selected column:
: activate date picker (see Date Picker)o
: toggle stat selection pane
If your terminal is too small to display all columns, they will be turned off starting from the left side.
Press 4
to activate this tab.
j
: move downk
: move up:
: activate date picker (see Date Picker)Enter
: display a teams roster (TODO)
With the date picker active, input a date in the form of YYYY-MM-DD
, or use
the left
/right
arrow keys, and press Enter
. To cancel, press Esc
. To go
back to the current day, enter today
or t
.
Note that each tab has its own date, i.e. if you're viewing older stats or standings, the schedule can be the current date.
?
: display help boxEsc
: close help box
If your terminal is too small to display the full help box, the border will be displayed red.
You can configure the TUI with the toml file located at your users' home
directory. For a user named Alice
this would be:
- Linux:
/home/alice/.config/mlbt/mlbt.toml
- Windows:
C:\Users\Alice\AppData\Roaming\mlbt\mlbt.toml
- macOS:
/Users/Alice/Library/Application Support/mlbt/mlbt.toml
You can see the path for your user in the
Help
page.
favorite_team
: This will make that team always show up first in the schedule if they have a game that day. See here for options (note: use the full name and not the short name).timezone
: This will change the time zone of the start time for the games in the schedule. The default isUS/Pacific
. Some common options are:US/Pacific
US/Mountain
US/Central
US/Eastern
- For the full list see here
# See https://github.com/mlb-rs/mlbt#config for options
favorite_team = "Chicago Cubs"
timezone = "US/Pacific"
This was originally built with the wonderful tui-rs. It is now using the also wonderful fork, ratatui.
These TUIs were extremely helpful: spotify-tui, tickrs, bottom.
A reference MLB stats API client by toddrob99 helped make up for the lack of API documentation.
The data used in this application is supplied by the MLB's Stats API. Use of this data is subject to the license posted here: http://gdx.mlb.com/components/copyright.txt.
This application and its author are not affiliated with the MLB.
This project is under the MIT License.