npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

bbdata

v0.10.0

Published

Baseball data CLI for querying, scouting reports, and analytics — built for humans and AI agents

Readme

bbdata

npm version node license

Baseball data CLI for querying stats, generating scouting reports, and building analytics pipelines — built for humans and AI agents.

Install

# Global (CLI usage)
npm install -g bbdata

# Local (programmatic API)
npm install bbdata

Requires Node.js 18+.

Quick Start

# Pitcher's pitch mix, velocity, spin, whiff rates
bbdata query pitcher-arsenal --player "Corbin Burnes" --format table

# Advance scouting report for a starting pitcher
bbdata report advance-sp --player "Gerrit Cole" --audience coach

# Pitch movement chart (SVG)
bbdata viz movement --player "Shohei Ohtani" -o ohtani.svg

Commands

bbdata query [template]

Query baseball data using pre-built templates. Returns structured data in your choice of format.

Key options:

| Flag | Description | |---|---| | -p, --player <name> | Player name | | --players <names> | Comma-separated names (matchups/comparisons) | | -s, --season <year> | Season year (default: current) | | -f, --format <fmt> | json (default), table, csv, markdown | | --source <src> | Force data source: savant, fangraphs, mlb-stats-api | | --no-cache | Bypass cache | | --stdin | Read pre-fetched JSON from stdin | | --data <path> | Load data from a local .json or .csv file (Savant CSV schema) |

Run bbdata query --help for the full option list.

21 templates across 5 categories:

Pitcher (8) — pitcher-arsenal, pitcher-velocity-trend, pitcher-handedness-splits, pitcher-raw-pitches, pitcher-recent-form, pitcher-by-count, pitcher-tto, pitcher-season-profile

Hitter (7) — hitter-batted-ball, hitter-vs-pitch-type, hitter-hot-cold-zones, hitter-handedness-splits, hitter-zone-grid, hitter-raw-bip, hitter-season-profile

Matchup (2) — matchup-pitcher-vs-hitter, matchup-situational

Leaderboard (2) — leaderboard-custom, leaderboard-comparison

Trend (2) — trend-rolling-average, trend-year-over-year

bbdata query hitter-batted-ball --player "Aaron Judge" --format table
bbdata query leaderboard-custom --stat ERA --min-ip 100 --top 10 --format csv

bbdata report [template]

Generate scouting reports rendered from Handlebars templates. Reports pull data from multiple query templates automatically.

Key options:

| Flag | Description | |---|---| | -p, --player <name> | Player name | | -a, --audience <role> | coach, gm, scout, analyst (default: analyst) | | -f, --format <fmt> | markdown (default), json | | --validate | Run validation checklist on the report | | --no-strict | Emit stub shell instead of exiting on missing data |

13 templates across 6 categories:

Pro Scoutingpro-pitcher-eval, pro-hitter-eval, relief-pitcher-quick

Amateur Scoutingcollege-pitcher-draft, college-hitter-draft, hs-prospect

Advanceadvance-sp, advance-lineup

Player Developmentdev-progress, post-promotion

Executivetrade-target-onepager, draft-board-card, draft-board-card-pitcher

bbdata report pro-pitcher-eval --player "Corbin Burnes"
bbdata report trade-target-onepager --player "Vladimir Guerrero Jr." --audience gm

bbdata viz [type]

Generate data visualizations as SVG.

Chart types:

| Type | Description | |---|---| | movement | Pitch movement plot (horizontal break vs vertical break) | | movement-binned | Binned density variant for compact inline use | | spray | Batted ball spray chart | | zone | 3x3 strike zone heatmap (xwOBA) | | rolling | Rolling performance trend line |

Key options: --colorblind (viridis palette), -a, --audience (coach/analyst/frontoffice/presentation), --size WxH, -o, --output <path>

bbdata viz spray --player "Aaron Judge" --audience coach
bbdata viz zone --player "Shohei Ohtani" --colorblind

Output Formats

All commands support --format:

  • json (default) — Structured { data, meta } envelope. Designed for piping to AI agents and scripts.
  • table — Human-readable ASCII table.
  • csv — Standard CSV.
  • markdown — Markdown table.

Decorative output (progress, warnings) goes to stderr. Data goes to stdout. Every format is pipe-safe.

Programmatic API

import { query, report, viz, getConfig, setConfig } from 'bbdata';

const result = await query({
  template: 'pitcher-arsenal',
  player: 'Corbin Burnes',
  season: 2025,
  format: 'json',
});

console.log(result.data);   // Array of row objects
console.log(result.meta);   // { template, source, cached, sampleSize, season, queryTimeMs }

All TypeScript types are exported — see QueryOptions, ReportOptions, VizOptions, QueryResult, ReportResult, VizResult, and more.

Data Sources

The CLI tries adapters in preference order and falls back automatically:

  • Savant — Pitch-level Statcast data (Baseball Savant CSV)
  • FanGraphs — Season-level aggregated stats
  • MLB Stats API — Rosters, schedules, and universal fallback for player resolution

Override with --source savant (or fangraphs, mlb-stats-api). Sources can be toggled in config.

Configuration

Config lives at ~/.bbdata/config.json (validated with Zod, graceful defaults if missing or corrupted):

{
  "defaultFormat": "json",
  "defaultAudience": "analyst",
  "cache": {
    "enabled": true,
    "maxAgeDays": 30
  },
  "sources": {
    "savant": { "enabled": true },
    "fangraphs": { "enabled": true },
    "mlbStatsApi": { "enabled": true }
  }
}

Access programmatically with getConfig() / setConfig().

Caching

Query results are cached in SQLite (via sql.js/WASM — zero native dependencies). Cache keys are SHA256 hashes of source:params. Default expiration is 30 days, configurable via cache.maxAgeDays. Bypass with --no-cache.

If sql.js fails to initialize, the CLI continues without cache.

Changelog

See CHANGELOG.md.

License

MIT