- Integer id columns are decimal strings — Every id column of integers (
id,*_id,game_pk,playerId, …) comes back as exact decimal strings on every surface — parsers, producers, loaders, HockeyTech analytics. Compare and join ids as strings;Number(row.game_id)for a safe number back. (changelog) - 400 / 422 raise
InvalidParameterError— For every family (it wasAssetFetchError), never retried; the message names host, path and status with a redacted excerpt of the body. (changelog) - Typed returns — generated row types for
parsed: true— TypeScript only. A wrapper's raw payload resolves tounknown(wasany); verified endpoints resolve to their row interfaces; the summary dispatchers toParsedTables. Narrow or cast a raw payload. (changelog) - Wrapper failures raise
NoDataError/AssetFetchError— Instead of raw axios errors.NoDataError= the fetch worked and there is nothing there (404, ESPN{ code: 404 });AssetFetchError= the fetch failed (403 / 429 / 5xx after retries, network). Retries followDEFAULT_RETRY_STATUSESwith backoff. (changelog)
Parsers
These utilities never fetch a provider payload by themselves — they transform, classify, configure or look things up. The data surface (every espn* / native wrapper and load* loader) is under ESPN Reference.
Turn a raw provider payload (ESPN, MLB, NHL, stats.nba.com, …) into tidy rows — the same functions \{ parsed: true \} runs.
| Export | kind | module |
|---|---|---|
parseEndpoint | function | src/parsers/index.ts |
normalize | function | src/parsers/index.ts |
snakeCase | function | src/parsers/index.ts |
PARSERS | const | src/parsers/index.ts |
parserFor | function | src/parsers/index.ts |
NODE_ONLY_PARSERS | const | src/parsers/index.ts |
MULTI_TABLE_SECTIONS | const | src/parsers/index.ts |
ESPN_ENDPOINT_PARSERS | const | src/parsers/index.ts |
parserForEndpoint | function | src/parsers/index.ts |
parse_summary | function | src/parsers/index.ts |
SECTIONED_ENDPOINTS | const | src/parsers/index.ts |
SUMMARY_SECTION_PARSERS | const | src/parsers/index.ts |
parse_kenpom_page | function | src/parsers/index.ts |
parse_asa_goals_added_tables | function | src/parsers/index.ts |
parse_mls_standings_tables | function | src/parsers/index.ts |
parse_mls_match_tables | function | src/parsers/index.ts |
parse_nwsl_lineups_tables | function | src/parsers/index.ts |
parse_pff_report | function | src/parsers/index.ts |
parse_pff_player_detail | function | src/parsers/index.ts |
parse_pff_v2_table | function | src/parsers/index.ts |
parse_pff_matrix | function | src/parsers/index.ts |
parse_nfl_pro_stats | function | src/parsers/index.ts |
ParserFn | type | src/parsers/index.ts |
FlatParserFn | type | src/parsers/index.ts |
ParsedTables | type | src/parsers/index.ts |
ParsedResult | type | src/parsers/index.ts |
src/parsers/index.ts
The parser layer: every registered parser, the ESPN endpoint -> parser map and the summary dispatcher. Browser-safe except parse_kenpom_page (cheerio).
Import: import { … } from 'sportsdataverse/parsers'
parseEndpoint
Run the parser registered for an endpoint over its raw payload — tidy rows, a dict of sub-frames (the ESPN summary dispatcher, a dict-default multi-table parser), or null when no parser is registered.
export function parseEndpoint( kind: "espn" | "flat", key: string, raw: unknown, section?: string ): ParsedResult
Example:
import { parseEndpoint } from 'sportsdataverse/parsers';
const rows = parseEndpoint('scoreboard', raw);
normalize
json_normalize equivalent — flatten nested row objects into rectangular rows with _-joined, snake_cased keys; integer id columns become decimal strings.
export function normalize(rows: any[]): ParserRow[]
snakeCase
Convert a key to snake_case (camelCase, PascalCase, dot.separated, runs of capitals).
export function snakeCase(key: string): string
PARSERS
The flat parser registry — parser name -> function.
export const PARSERS: Record<string, FlatParserFn> =
parserFor
Look up a parser by name; undefined when missing, so the caller falls back to the raw payload.
export function parserFor(name?: string): FlatParserFn | undefined
NODE_ONLY_PARSERS
Names of the parsers registered by a node-side family runtime (not in the browser bundle).
export const NODE_ONLY_PARSERS
MULTI_TABLE_SECTIONS
The sub-frame names of every multi-table parser and the one it returns by default.
export const MULTI_TABLE_SECTIONS: Record<string, SectionSpec> =
ESPN_ENDPOINT_PARSERS
ESPN endpoint short -> parser function.
export const ESPN_ENDPOINT_PARSERS: Record<string, ParserFn | typeof parse_summary> =
parserForEndpoint
The parser registered for an ESPN endpoint short.
export function parserForEndpoint( short: string ): ParserFn | typeof parse_summary | undefined
parse_summary
The ESPN Site v2 summary dispatcher — 21 sub-frames keyed by section, or one with section.
export function parse_summary( payload: any, section?: string ): ParserRow[] | Record<string, ParserRow[]>
SECTIONED_ENDPOINTS
The ESPN endpoint shorts whose parsed result is the summary dispatcher's (they take section).
export const SECTIONED_ENDPOINTS: ReadonlySet<string>
SUMMARY_SECTION_PARSERS
The summary dispatcher's section -> sub-frame parser table.
export const SUMMARY_SECTION_PARSERS: Record<string, ParserFn> =
parse_kenpom_page
Every table of a KenPom HTML page keyed by its HTML id (node only — cheerio).
export function parse_kenpom_page(raw: any, section?: string): Record<string, Row[]> | Row[]
Import: import { parse_kenpom_page } from 'sportsdataverse'
parse_asa_goals_added_tables
American Soccer Analysis goals-added payload -> its tables.
export function parse_asa_goals_added_tables(raw: any): { summary: Row[]; actions: Row[] }
parse_mls_standings_tables
MLS standings payload -> its tables.
export function parse_mls_standings_tables(raw: any): { tables: Row[]; entries: Row[] }
parse_mls_match_tables
MLS match payload -> its tables.
export function parse_mls_match_tables(raw: any): MatchTables
parse_nwsl_lineups_tables
NWSL (StatsPerform) lineups payload -> its tables.
export function parse_nwsl_lineups_tables(raw: any): { teams: Row[]; players: Row[]; staff: Row[] }
parse_pff_report
A PFF Developer API /v1 report envelope -> rows (the restricted block is metadata, skipped).
export function parse_pff_report(raw: any, section?: string): Row[] | Tables
parse_pff_player_detail
A PFF Developer API player-detail envelope -> rows.
export function parse_pff_player_detail(raw: any, section?: string): Row[]
parse_pff_v2_table
A PFF Developer API /v2 table body -> rows typed from the body's own columns.
export function parse_pff_v2_table(raw: any, section?: string): Row[]
parse_pff_matrix
A PFF matrix body -> rows.
export function parse_pff_matrix(raw: any, report?: string): Tables
parse_nfl_pro_stats
An NFL Pro (Next Gen Stats) stats envelope -> rows.
export function parse_nfl_pro_stats(payload: any): Row[]
ParserFn
A one-table parser — (raw, section?) =\> ParserRow[].
export type ParserFn
FlatParserFn
A registered flat-API parser — rows, or a dict of row arrays for a multi-table payload.
export type FlatParserFn
ParsedTables
A dict of tables — section name -> rows.
export ParsedTables
ParsedResult
What parseEndpoint returns — rows, a dict of sub-frames, or null.
export type ParsedResult
Generated by tools/codegen/generate.mjs from tools/codegen/utilities.yaml — see How this library is built.