mlbt 0.2.0

A terminal user interface for the MLB stats API. Watch a baseball game in your terminal! ⚾
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
# mlbt

[![CI](https://github.com/mlb-rs/mlbt/actions/workflows/ci.yml/badge.svg?event=push)](https://github.com/mlb-rs/mlbt/actions/workflows/ci.yml)
[![dependency status](https://deps.rs/repo/github/mlb-rs/mlbt/status.svg)](https://deps.rs/repo/github/mlb-rs/mlbt)
[![Built With Ratatui](https://ratatui.rs/built-with-ratatui/badge.svg)](https://ratatui.rs/)

mlb.com in your terminal. Gameday, scores, stats, standings, teams, and player
profiles. Powered by MLB's Stats API, check today's games or dig through decades
of historical information. Go beyond the broadcast and nerd out with win
probability, leverage index, exit velo, and more.

<img src="https://github.com/user-attachments/assets/1c11e22b-df11-46df-8774-5783b77def84" alt="Demo showing the Schedule, Gameday, Stats, and Standings."/>

## Table of Contents

- [Installation]#installation
    - [Cargo]#cargo
    - [Homebrew]#homebrew
    - [Binaries]#binaries
    - [Docker]#docker
- [Features]#features
- [Usage]#usage
    - [Scoreboard]#scoreboard
    - [Gameday]#gameday
    - [Stats]#stats
    - [Standings]#standings
    - [Team Page]#team-page
    - [Player Profile]#player-profile
    - [Date Picker]#date-picker
    - [Help]#help
- [Config]#config
- [Shout out]#shout-out
- [Copyright Notice]#copyright-notice
- [License]#license

## Installation

### Cargo

Install a pre-built binary using [cargo-binstall](https://github.com/cargo-bins/cargo-binstall):

```bash
cargo binstall mlbt
```

Or build from source:

```bash
cargo install mlbt
```

### Homebrew

```bash
brew tap mlb-rs/mlbt
brew install mlbt
```

To update to the latest version:

```bash
brew upgrade mlbt
```

### Binaries

macOS, Linux, and Windows binaries are available on the
[releases](https://github.com/mlb-rs/mlbt/releases) page.

| Platform               | Target                          |
|------------------------|---------------------------------|
| macOS (Apple Silicon)  | `aarch64-apple-darwin`          |
| macOS (Intel)          | `x86_64-apple-darwin`           |
| Linux (x86_64)         | `x86_64-unknown-linux-gnu`      |
| Linux (x86_64, static) | `x86_64-unknown-linux-musl`     |
| Linux (ARM64)          | `aarch64-unknown-linux-gnu`     |
| Linux (ARM64, static)  | `aarch64-unknown-linux-musl`    |
| Linux (ARMv7)          | `armv7-unknown-linux-gnueabihf` |
| Windows (x86_64)       | `x86_64-pc-windows-msvc`        |

`.deb` and `.rpm` packages are also available for Linux x86_64 and ARM64.

### Docker

`mlbt` publishes docker images on [ghcr](https://github.com/mlb-rs/mlbt/pkgs/container/mlbt).

```bash
docker run -it --rm --name mlbt ghcr.io/mlb-rs/mlbt
```

`mlbt` follows [semver](https://semver.org/) practices.
You can execute individual releases explicitly.

```bash
docker run -it --rm --name mlbt ghcr.io/mlb-rs/mlbt:v0.2.0
```

Alternatively build the `mlbt` image with:

```bash
docker build -t mlbt .
```

Execute `mlbt` within the container with:

```bash
docker run -it --rm --name mlbt mlbt:latest
```

## Features

- scoreboard and box score
    - sorted by favorite team
    - full box score
    - probable pitchers for upcoming games
    - win probability graph
    - selectable date

- gameday
    - pitch display
    - batter strike zone with heat map coloring
    - selectable at bats (view the pitches and outcome of any at bat in the game)
    - hit stats: exit velocity, launch angle, distance
    - ABS challenge information for 2026+ games
    - leverage index and win probability change per at bat

- pitching and hitting stats
    - player stats
    - team stats
    - sorting
    - fuzzy search for players and teams
    - selectable date

- standings
    - sorted by favorite team
    - division/league view
    - selectable date

- team page
    - roster (active and 40-man)
    - schedule with calendar view
    - recent transactions

- player profile
    - player bio
    - career stats
    - recent games

- configuration
    - favorite team
    - time zone

## Usage

After installing, run `mlbt` from your terminal to open the program.

Press `q` to exit at any time.

### Tabs

There are four main tabs.

- Scoreboard
- Gameday
- Stats
- Standings

Press `f` for full screen mode to hide the tab bar.

### Scoreboard

Press `1` to activate this tab.

| Key                 | Description                                            |
|---------------------|--------------------------------------------------------|
| `j` / ``           | move down                                              |
| `k` / ``           | move up                                                |
| `Enter`             | view current game in Gameday                           |
| `:`                 | activate date picker (see [Date Picker]#date-picker) |
| `w`                 | toggle win probability graph                           |
| `h`                 | switch to home team in box score                       |
| `a`                 | switch to away team in box score                       |
| `Shift` +  `j`/ `` | scroll box score down                                  |
| `Shift` +  `k`/ `` | scroll box score up                                    |

### Gameday

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:

| Key | Description                  |
|-----|------------------------------|
| `i` | info pane                    |
| `p` | pitches pane                 |
| `b` | box score pane               |
| `w` | toggle win probability graph |

To view different at bats in the game, use:

| Key       | Description                                    |
|-----------|------------------------------------------------|
| `j` / `` | move to previous at bat                        |
| `k` / `` | move to next at bat                            |
| `l`       | move to the "live" at bat, or latest available |
| `s`       | move to first at bat of the game               |

To interact with the box score, use:

| Key                 | Description                      |
|---------------------|----------------------------------|
| `h`                 | switch to home team in box score |
| `a`                 | switch to away team in box score |
| `Shift` +  `j`/ `` | scroll box score down            |
| `Shift` +  `k`/ `` | scroll box score up              |

### Stats

Press `3` to activate this tab.

Inside the stats tab there are two panes: *stats table* and *options*. The stats
table is used for selecting players/teams and searching. The options pane is
used for sorting the stats and toggling columns on/off.

| Key                 | Description                                            |
|---------------------|--------------------------------------------------------|
| `` / `` / `Tab`   | switch between stats table and options pane            |
| `j` / ``           | move down in active pane                               |
| `k` / ``           | move up in active pane                                 |
| `Shift` + `j` / `` | page down in stats table                               |
| `Shift` + `k` / `` | page up in stats table                                 |
| `:`                 | activate date picker (see [Date Picker]#date-picker) |

You can switch between `pitching` and `hitting` stats and filter based on `team`
or `player` using:

| Key | Description |
|-----|-------------|
| `p` | pitching    |
| `h` | hitting     |
| `t` | team        |
| `l` | player      |

#### Search

You can fuzzy search for a player or team in the stats table using:

| Key          | Description                |
|--------------|----------------------------|
| `Ctrl` + `f` | activate fuzzy search      |
| `Enter`      | finish fuzzy search        |
| `Esc`        | clear fuzzy search results |

While the stats table is active, press `Enter` to view a
[player profile](#player-profile) or a [team page](#team-page).

#### Stats Options

The stats options pane can be turned on/off with `o`.

Within each stat group (pitching or hitting) you can toggle the display of
individual stat columns by selecting the stat with `Enter`. To sort the stats by
a column, you can press `s`. To flip the sort order from ascending to descending
or vice versa press `s` again.

| Key     | Description                           |
|---------|---------------------------------------|
| `Enter` | toggle stat column                    |
| `s`     | sort by the currently selected column |
| `o`     | toggle options pane                   |

> If your terminal is too small to display all columns, they will be turned off
> starting from the right side.

### Standings

Press `4` to activate this tab.

| Key       | Description                                            |
|-----------|--------------------------------------------------------|
| `j` / `` | move down                                              |
| `k` / `` | move up                                                |
| `Enter`   | view [team page]#team-page                           |
| `:`       | activate date picker (see [Date Picker]#date-picker) |
| `l`       | toggle division/league view                            |

### Player Profile

The player profile shows a player's career stats and recent games. It can be
opened from [Stats](#stats) or from a [team page](#team-page) roster by pressing
`Enter`.

| Key                 | Description          |
|---------------------|----------------------|
| `s`                 | toggle stat category |
| `j` / ``           | scroll down          |
| `k` / ``           | scroll up            |
| `Shift` + `j` / `` | page down            |
| `Shift` + `k` / `` | page up              |
| `Esc`               | close profile        |

### Team Page

The team page shows a team's roster, schedule, and recent transactions. It can
be opened from [Standings](#standings) or from [Stats](#stats) by pressing
`Enter`.

| Key                 | Description                                        |
|---------------------|----------------------------------------------------|
| `` / `` / `Tab`   | switch section                                     |
| `j` / ``           | move down                                          |
| `k` / ``           | move up                                            |
| `Shift` + `j` / `` | page down                                          |
| `Shift` + `k` / `` | page up                                            |
| `c`                 | toggle calendar                                    |
| `r`                 | toggle roster type                                 |
| `Enter`             | view [player profile]#player-profile from roster |
| `Esc`               | close team page                                    |

### Date Picker

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`.

| Key           | Description                     |
|---------------|---------------------------------|
| `` / ``     | use arrow keys to navigate date |
| `Enter`       | confirm the selected date       |
| `Esc`         | cancel selection                |
| `today` / `t` | go back to the current day      |

> 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.

### Help

Press `?` from any tab to open the help page.

| Key                 | Description    |
|---------------------|----------------|
| `j` / ``           | move down      |
| `k` / ``           | move up        |
| `Shift` + `j` / `` | page down      |
| `Shift` + `k` / `` | page up        |
| `Esc`               | close help box |
| `"`                 | display logs   |

## Config

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.

### Available settings

- `favorite_team`: This will make that team always show up first in the schedule
  if they have a game that day and be highlighted in the standings.
  See [here]https://github.com/mlb-rs/mlbt/blob/main/src/components/constants.rs#L83
  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 is `US/Pacific`. Some common options are:
    * `US/Pacific`
    * `US/Mountain`
    * `US/Central`
    * `US/Eastern`
    * For the full list
      see [here]https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
- `log_level`: Set the log level to be displayed. If not present, `error` level
  is used. Use a lowercase word, e.g. `debug`.
  See [here]https://github.com/mlb-rs/mlbt/blob/main/src/config.rs#L16
  for the options.

### Example config

```toml
# See https://github.com/mlb-rs/mlbt#config for options
favorite_team = "Chicago Cubs"
timezone = "US/Pacific"
log_level = "error"
```

## Shout out

This was originally built with the
wonderful [tui-rs](https://github.com/fdehau/tui-rs). It is now using the also
wonderful fork, [ratatui](https://github.com/ratatui/ratatui).

These TUIs were extremely helpful:
[spotify-tui](https://github.com/Rigellute/spotify-tui),
[tickrs](https://github.com/tarkah/tickrs),
[bottom](https://github.com/ClementTsang/bottom).

A reference MLB stats API client by
[toddrob99](https://github.com/toddrob99/MLB-StatsAPI) helped make up for the
lack of API documentation.

## Copyright Notice

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.

## License

This project is under the
[MIT License](https://github.com/mlb-rs/mlbt/blob/main/LICENSE).