Sidebar Standings | Reddit for Developers
close

Readme

sidebar-standing

Automatically updates a subreddit's sidebar standings — both the new-Reddit TextArea widget and the old-Reddit wiki config/sidebar — with standings for your configured team's sport. Registered sports are MLB, NBA, NHL, and NFL. A Devvit cron task polls every 5 minutes; the orchestrator writes a fresh update when settings change, when the operator's template wiki page content changes, or every hour otherwise. App upgrade triggers an immediate update.

What this app does

After you configure the sport and matching per-sport team dropdown (mlbTeamId / nflTeamId / nhlTeamId / nbaTeamId), the app runs a periodic fetch-render-write pipeline and writes standings to:

  • New Reddit: A TextArea sidebar widget (created automatically if it doesn't exist; named by the widgetName setting, default "Standings")
  • Old Reddit: The config/sidebar wiki page, replacing the content between [](/redball/standings) markers (or appending a new marker-wrapped block if none exists)

Both surfaces update independently — a failure on one does not block the other. When fresh standings are unavailable for any reason (API outage, off-season, shape change), the previously published content is preserved; the app never blanks your sidebar.

Three modular content sections

The app manages up to three independent content sections, each writing into config/sidebar:

Section Sports Default Enable setting
Standings All (MLB, NFL, NHL, NBA) On (controlled by enableWiki) enableWiki
Schedule MLB only Off enableSchedule
Stats MLB only Off enableStats

Each section is independently enabled and independently ordered — the section appears wherever you place its marker pair in config/sidebar. You can have standings at the top, schedule in the middle, and stats at the bottom, or any arrangement you want.

The schedule and stats sections are wiki-only (old Reddit config/sidebar). Standings also writes to the new-Reddit TextArea widget. The wiki write is a single read-modify-write of config/sidebar that splices all enabled sections in one operation — your sidebar is never over-written section by section.

Marker pairs and placement

Each section is delimited by a marker pair in config/sidebar. Markers are wiki-internal — the app writes them around the section content at write time. You do not put them in your Liquid templates, and you do not need to write them by hand for the standings section (it auto-appends if missing).

For the schedule and stats sections, you must place the marker pair manually where you want that section to appear. The marker is the same token used as both the open and close delimiter:

Section Marker token
Standings [](/redball/standings)
Schedule [](/redball/schedule)
Stats [](/redball/stats)

Example config/sidebar layout (standings on top, schedule below, stats at the bottom):

[](/redball/standings)
... bot-managed standings content ...
[](/redball/standings)

... your other sidebar content ...

[](/redball/schedule)
... bot-managed schedule content ...
[](/redball/schedule)

... more sidebar content ...

[](/redball/stats)
... bot-managed stats content ...
[](/redball/stats)

The app replaces only the content between each marker pair and preserves everything outside. If a section fails to render or is disabled, its existing marker block is left untouched.

Install and initial setup

  1. Install sidebar-standing from the Devvit app directory on your subreddit.
  2. Go to your subreddit's app settings and configure sport and the matching per-sport team dropdown (mlbTeamId for MLB, nflTeamId for NFL, etc.). Both are required; there are no defaults. Optionally set localTimezone to your preferred IANA zone (defaults to UTC).
  3. Save settings. Within at most 5 minutes, the next cron tick fires the first standings update.
  4. Confirm the widget and/or wiki sidebar updated correctly.
  5. If you are migrating from a redball sidebar_updater deployment: the existing [](/redball/standings) marker block in your old-Reddit sidebar is picked up automatically on the first update — no manual sidebar editing required. After confirming the Devvit app works, disable your redball sidebar_updater deployment for this sub.

Moderator controls

Update sidebar standings now

A subreddit moderator can trigger an immediate standings re-render at any time from the Reddit mod menu:

  1. Go to your subreddit.
  2. Open the mod menu (the moderator tools area on new Reddit, or the mod sidebar on old Reddit).
  3. Select "Update sidebar standings now".

The action runs the full fetch-render-write pipeline immediately, bypassing the change-aware throttle (which normally suppresses re-renders when nothing relevant has changed and the last update was under one hour ago). A toast notification reports the outcome:

  • "Sidebar standings updated." — the widget and/or wiki page were written successfully.
  • "No update was made — check Sport/Team settings, confirm your template renders content, or see the app logs." — the update was skipped. Common reasons: sport or the matching team ID setting is not configured; the standings API returned no data (off-season or transient outage); the template rendered empty content. Check app settings and logs.
  • "Refresh failed — see the app logs." — an unexpected error occurred. Check the Devvit app logs in your developer console.

Preserve-on-no-data still applies: if fresh standings are unavailable for any reason, the previously published sidebar content is preserved — this action never blanks your sidebar (SU7 behavior).

This action is moderator-only. It does not affect the automatic cron schedule — the next scheduled update fires at the next cron tick regardless.

Settings reference

Setting Default Description
sport (required — no default) Sport for this sub: mlb, nfl, nhl, or nba.
mlbTeamId / nflTeamId / nhlTeamId / nbaTeamId (required — no default) Per-sport team dropdown for standings filtering. Only the dropdown matching the configured sport is consulted at runtime.
localTimezone "America/New_York" Curated dropdown of US timezones plus UTC, used to format the standings "Updated" timestamp. Options: Eastern, Central, Mountain, Mountain–Phoenix (no DST), Pacific, Alaska, Hawaii, UTC.
enableWidget true Update (or create) the new-Reddit TextArea widget.
enableWiki true Update the old-Reddit config/sidebar wiki page.
widgetName "Standings" Short name of the TextArea widget to update or create. Match your existing widget name to avoid creating a duplicate (e.g. Eagles use "2024 Division Standings").
widgetBgColor "" Optional hex background color for the widget (e.g. #014980). Empty = Reddit default styling.
widgetHeaderColor "" Optional hex header color for the widget. Empty = Reddit default styling.
enableSchedule false Enable the schedule section (MLB only). When true, the bot updates the [](/redball/schedule) marker block in config/sidebar with the current month's schedule. Has no effect for NFL/NHL/NBA. The marker pair must already exist in config/sidebar where you want the schedule to appear.
enableStats false Enable the stats section (MLB only). When true, the bot updates the [](/redball/stats) marker block in config/sidebar with team stat leaders. Has no effect for NFL/NHL/NBA. The marker pair must already exist in config/sidebar.
standingsTemplateWikiPage "" (blank — uses app default) Wiki page name for the Liquid template used when rendering the old-Reddit sidebar standings section. Leave blank to use sidebar-standing/default-{sport}-standings (seeded automatically). Set a wiki page name to point at a custom template.
standingsTemplateWidgetPage "" (blank — uses app default) Wiki page name for the Liquid template used when rendering the new-Reddit widget. Leave blank to use sidebar-standing/default-{sport}-standings. Operators with different old/new templates (e.g. r/Flyers) point this at a separate custom page.
scheduleTemplateWikiPage "" (blank — uses app default) Wiki page name for the Liquid template for the schedule section. Leave blank to use sidebar-standing/default-{sport}-schedule (seeded automatically). Set a wiki page name to point at a custom template. Only consulted when enableSchedule is true. MLB only.
statsTemplateWikiPage "" (blank — uses app default) Wiki page name for the Liquid template for the stats section. Leave blank to use sidebar-standing/default-{sport}-stats (seeded automatically). Set a wiki page name to point at a custom template. Only consulted when enableStats is true. MLB only.

The sidebar-standing/ wiki folder

All bot-managed default template pages live under the sidebar-standing/ wiki path:

Page Purpose
sidebar-standing/default-mlb-standings Default MLB standings template (bot-owned)
sidebar-standing/default-mlb-schedule Default MLB schedule template (bot-owned)
sidebar-standing/default-mlb-stats Default MLB stats template (bot-owned)
sidebar-standing/default-nfl-standings Default NFL standings template (bot-owned)
sidebar-standing/default-nhl-standings Default NHL standings template (bot-owned)
sidebar-standing/default-nba-standings Default NBA standings template (bot-owned)

Bot-owned pages are refreshed on every app upgrade. Do not edit them directly — your edits will be overwritten. To customize, create your own page with a different name and point the relevant *TemplateWikiPage setting at it.

Recommended naming for custom pages: keep your custom pages under sidebar-standing/ for organization. For example, a Phillies custom standings template might live at sidebar-standing/phillies-standings. This keeps all sidebar-standing-related wiki pages grouped together in the wiki index.

Marker convention for redball migration

The app uses [](/redball/standings) as the begin/end marker in the old-Reddit config/sidebar wiki page. This is the same marker token redball's sidebar_updater uses, which means:

  • If your sidebar already has a [](/redball/standings) block (placed by redball), the app finds it on first run and replaces it without any operator intervention.
  • If your sidebar has no such block, the app appends one at the end.

Operators do NOT add these markers manually. They are wiki-write-internal — the app inserts them around the rendered standings content at write time. Custom Liquid templates do NOT include them — your template emits pure standings content; the markers are handled by the app.

Per-sport notes

MLB

Data source endpoints:

  • Standings: https://statsapi.mlb.com/api/v1/standings?leagueId=103,104&season=YYYY&standingsTypes=regularSeason
  • Schedule: https://statsapi.mlb.com/api/v1/schedule?sportId=1&teamId={id}&startDate=...&endDate=...&hydrate=broadcasts(all),linescore,team
  • Stats leaders: https://statsapi.mlb.com/api/v1/stats?stats=season&group=hitting|pitching&gameType=R&season=YYYY&teamId={id}&playerPool=All&hydrate=person

Team IDs are MLB StatsAPI numeric IDs (for example 143 for Philadelphia Phillies). Standings are filtered to the configured team's division (for example NL East).

Default MLB template renders:

  • Division header ({{ divisionShortName }} Standings)
  • Markdown table columns Team | W | L | GB
  • Footer timestamp (^Updated: {{ updatedAt }} — Reddit-supertext line that displays the timestamp in the operator's configured localTimezone with the IANA short zone abbreviation appended; non-breaking spaces inside the formatted value keep the entire supertext run unbroken)
  • Configured team's row is bolded — every cell in the row matching the operator's mlbTeamId is wrapped in markdown **...**. Custom templates can change emphasis style by replacing the {% if row.isMyTeam %}…{% else %}…{% endif %} branch (see Available Liquid variables below for row.isMyTeam).

MLB team subreddit links come from static MLB_TEAMS mappings. If a team has no mapping, row.teamSubreddit is null and link rendering may be empty/broken in custom templates.

NBA

Team IDs are ESPN numeric IDs. Standings filter by conference (East or West — the only sport that is not division-level). Data source: site.api.espn.com (ESPN's community-discovered API; not stats.nba.com which is blocked by anti-bot TLS enforcement).

Data source endpoint:

  • https://site.api.espn.com/apis/v2/sports/basketball/nba/standings?region=us&lang=en&season=YYYY&type=0&limit=100

Default NBA template renders:

  • Conference header (**{{ conferenceName }} Standings**)
  • Markdown table columns Team | W | L | PCT | GB
  • Footer timestamp (^Updated: {{ updatedAt }} — Reddit-supertext-safe, timezone-aware timestamp)
  • Configured team's row is bolded using {% if row.isMyTeam %}...{% endif %}.

NHL

Team IDs are NHL API three-letter abbreviations (for example PHI for Philadelphia Flyers). Standings filter by division. Data source: api-web.nhle.com.

Data source endpoint:

  • https://api-web.nhle.com/v1/standings/now

Default NHL template renders:

  • Division header (**{{ divisionName }} Division**)
  • Markdown table columns Team | W | L | OTL | PTS
  • Footer timestamp (^Updated: {{ updatedAt }} — Reddit-supertext-safe, timezone-aware timestamp)
  • Configured team's row is bolded using {% if row.isMyTeam %}...{% endif %}.

NFL

Team IDs are ESPN numeric IDs (for example 21 for Philadelphia Eagles). Standings filter by division. Data source: site.api.espn.com.

Data source endpoint:

  • https://site.api.espn.com/apis/v2/sports/football/nfl/standings?region=us&lang=en&season=YYYY&type=2&limit=100

The NFL standings response includes two conference groups in children[] (AFC and NFC). Each conference has a flat standings.entries[] list (16 teams) with no nested division sub-groups. Division assignment is derived from the static NFL_TEAMS map, then the module selects the configured team's division.

Why the app renders division standings (not full conference standings):

  • Division output is 4 teams, which fits sidebar space without forcing overly compact templates.
  • This matches MLB and NHL behavior (all division-scoped).
  • It also matches redball's long-running operator expectation for NFL sidebars.

Default NFL template renders:

  • Division header (**{{ divisionName }} Standings**)
  • Markdown table columns Team | W | L | T | PCT
  • Footer timestamp (^Updated: {{ updatedAt }} — Reddit-supertext-safe, timezone-aware timestamp)
  • Configured team's row is bolded using {% if row.isMyTeam %}...{% endif %}.

Custom-template authoring guide

Overview

By default, the app renders each section using a per-sport built-in Liquid template. To customize the output, create a wiki page on your subreddit with your own Liquid template content, then point the relevant *TemplateWikiPage setting at that page name.

The built-in default pages are bot-owned and refreshed on every app upgrade — do not edit them directly. Any edits to sidebar-standing/default-{sport}-{section} will be overwritten. Use a custom page name (recommended: keep under sidebar-standing/ for organization, e.g. sidebar-standing/phillies-standings).

Mako-to-Liquid migration

If you have existing redball Mako templates, the syntax is similar but not identical:

Mako Liquid equivalent
<% if condition: %> {% if condition %}
<% endif %> {% endif %}
<% for item in list: %> {% for item in list %}
<% endfor %> {% endfor %}
${variable} {{ variable }}
${variable | default('fallback')} {{ variable | default: 'fallback' }}

Shared scope variables (all sections)

These variables are available in every section template:

Variable Type Example Description
subreddit string Phillies Subreddit name (no r/ prefix)
updatedAt string 06/12/2026&nbsp;4:05&nbsp;PM&nbsp;EDT Render timestamp formatted in the operator's localTimezone. Pre-formatted with &nbsp; separators for Reddit supertext compatibility.

season (integer year) is available in all three sections. The schedule section also exposes year as an alias for season (identical value). See the per-section tables below.

Standings section — template-variable reference

Standings templates receive the full standings table for your team's division (or conference for NBA). All sports expose rows plus sport-specific header fields. Markers ([](/redball/standings)) are NOT in templates.

Common standings fields (all sports)

Variable Type Example Description
rows array — Standings rows for the division/conference, sorted by rank
rows[].teamName string Phillies Short team display name
rows[].teamSubreddit string or null /r/Phillies Subreddit path (with leading /r/) or null
rows[].wins number 37 Wins
rows[].losses number 31 Losses
rows[].isMyTeam boolean true true for the configured team's row; use to apply emphasis

MLB standings fields

Variable Type Example Description
season number 2026 Season year
divisionId number 204 MLB StatsAPI division ID
divisionName string National League East Full division name
divisionShortName string NL East Short division name
rows[].teamId number 143 MLB team ID
rows[].gamesBack string -, 8, 10.5 Games back
rows[].divisionRank string "1", "2" Division rank
rows[].pct string .612 Winning percentage (leading zero stripped)
rows[].lastTen string 6-4 Record over last 10 games
rows[].streak string W3, L1 Current streak code
rows[].homeRecord string 21-17 Home record as W-L
rows[].roadRecord string 12-20 Road record as W-L
rows[].runDiff number 45 Run differential (signed integer)

NBA standings fields

Variable Type Example Description
conferenceName string Eastern Conference Full conference name
rows[].teamId string "6" ESPN team ID
rows[].pct string .610 Win percentage
rows[].gamesBehind string -, 2.0 Games behind

NHL standings fields

Variable Type Example Description
divisionName string Metropolitan Full division name
rows[].teamId string PHI Team abbreviation
rows[].otLosses number 5 Overtime losses
rows[].points number 89 Points

NFL standings fields

Variable Type Example Description
divisionName string NFC East Full division name
rows[].teamId string "21" ESPN team ID
rows[].ties number 0 Ties
rows[].pct string .706 Win percentage
rows[].pointDifferential number 120 Point differential (may be absent)

Schedule section — template-variable reference

The schedule section is wiki-only and MLB-only. Enable with enableSchedule: true. Place [](/redball/schedule) marker pair in config/sidebar. Markers are NOT in templates.

Variable Type Example Description
grid string (pre-rendered table) Pre-rendered 7-column Sun–Sat markdown calendar. Use this for most custom templates. Home games bold, away games italic, off-days bare superscript.
weeks array — Structured primitive grid for full-custom layouts (e.g. CSS-flair schedules). Each element is a week object.
weeks[w].days array — Array of 7 day objects (or null for padding cells outside the month).
weeks[w].days[d].dayNum number 12 Calendar day number (1–31)
weeks[w].days[d].isOffday boolean true true if no game scheduled this day
weeks[w].days[d].games array — Array of game objects (0 for off-days, 1 for normal days, 2 for doubleheaders)
weeks[w].days[d].games[g].isHome boolean true true for home games
weeks[w].days[d].games[g].opponentId number 143 MLB team ID of opponent
weeks[w].days[d].games[g].opponentName string Padres Opponent short name
weeks[w].days[d].games[g].opponentSub string or null /r/Padres Opponent subreddit path or null
weeks[w].days[d].games[g].isFinal boolean true true for completed games
weeks[w].days[d].games[g].won boolean or null true Outcome from configured team's perspective; null if not final
weeks[w].days[d].games[g].runsFor number or null 5 Configured team's runs; null if not final
weeks[w].days[d].games[g].runsAgainst number or null 2 Opponent's runs; null if not final
weeks[w].days[d].games[g].timeText string or null 7:05 Local scheduled start time (H:MM, no am/pm); populated for all game states (final, live, and future). null only if the start time cannot be determined.
weeks[w].days[d].games[g].broadcasts string[] ["NBCSP", "FS1"] TV call-signs (type=TV, en, team-side only)
monthName string June Full month name
monthNum number 6 Month number 1–12
year number 2026 Season year
season number 2026 Season year — same value as year. Available for template consistency across sections.
teamName string Phillies Configured team's short name
updatedAt string 06/12/2026&nbsp;6:40&nbsp;PM&nbsp;EDT Render timestamp

Important notes:

  • Postponed games (with a rescheduleDate) are automatically filtered out. They re-appear on the new date.
  • Live games (currently in progress) are treated as future — they show scheduled start time and TV info.
  • Broadcasts are filtered to the team's own local TV only. National/opponent-side broadcasts are excluded.
  • The section is skipped silently (preserving existing content) when the schedule fetch fails (SU7).

Stats section — template-variable reference

The stats section is wiki-only and MLB-only. Enable with enableStats: true. Place [](/redball/stats) marker pair in config/sidebar. Markers are NOT in templates.

Variable Type Example Description
season number 2026 Season year — use in headers like ## {{ season }} Team Leaders.
hitting array — Hitting category objects, one per category, in order
hitting[i].key string HR, AVG, OPS Machine key
hitting[i].label string HR, AVG, OPS Display label (same as key)
hitting[i].leaders array — Up to 5 leaders sorted best-first
hitting[i].leaders[j].name string P Alonso Player display name ("First-initial Last")
hitting[i].leaders[j].value string 15, .263, 1.380 Formatted stat value
pitching array — Pitching category objects, same shape as hitting
record object — Team record object
record.home object — Home record
record.home.wins number 21 Home wins
record.home.losses number 17 Home losses
record.road object — Road record
record.road.wins number 12 Road wins
record.road.losses number 20 Road losses
record.total object — Overall record
record.total.wins number 33 Total wins
record.total.losses number 37 Total losses
updatedAt string 06/12/2026&nbsp;6:40&nbsp;PM&nbsp;EDT Render timestamp

Hitting category index reference (for direct index access in top-N paired templates):

Index Key Category
hitting[0] H Hits (all players)
hitting[1] XBH Extra-base hits = 2B+3B+HR (all players)
hitting[2] HR Home runs (all players)
hitting[3] RBI RBI (all players)
hitting[4] BB Walks (all players)
hitting[5] SB Stolen bases (all players)
hitting[6] AVG Batting average (qualified players only)
hitting[7] OBP On-base percentage (qualified players only)
hitting[8] SLG Slugging percentage (qualified players only)
hitting[9] OPS OPS (qualified players only)

Pitching category index reference:

Index Key Category
pitching[0] W Wins (all pitchers)
pitching[1] SV Saves (all pitchers)
pitching[2] HLD Holds (all pitchers)
pitching[3] IP Innings pitched (all pitchers)
pitching[4] SO Strikeouts (all pitchers)
pitching[5] AVG Opponent batting average (qualified pitchers only)
pitching[6] WHIP WHIP (qualified pitchers only)
pitching[7] ERA ERA (qualified pitchers only)

Qualification rules (rate stats):

  • Hitting: plateAppearances ≥ teamGamesPlayed × 3.1
  • Pitching: inningsPitched (decimal) ≥ teamGamesPlayed × 1.0 ("73.1" = 73â…“ innings)

If no player qualifies in a rate category, leaders[0].name and leaders[0].value are both "—". Counting stats always have at least one leader.

The default template uses only leaders[0]. Custom templates can use leaders[1] through leaders[4] for top-3 or top-5 paired layouts.

Limitations and troubleshooting

  • NBA uses ESPN, not stats.nba.com: The official stats.nba.com endpoint blocks non-browser TLS fingerprints. This app uses ESPN's site.api.espn.com which is accessible from Devvit's runtime.
  • All four sports are available: MLB, NBA, NHL, and NFL share the same fetch-render-write pipeline.
  • Off-season behavior: During off-season, the app preserves the previously published standings in the sidebar — it never blanks your sidebar when fresh data is unavailable. The standings shown may be from the prior season's final standings until the new season's data is available.
  • Widget name conflicts: If you change widgetName after the first run, the app creates a new widget with the new name and stops updating the old one. The old widget is left in place — delete it manually via Reddit's sidebar editor.
  • Custom widget names: The widgetName setting supports arbitrary strings (e.g. Eagles' "2024 Division Standings"). If you use a non-default name, confirm it matches your existing widget exactly (case-sensitive).
  • Template pointer defaults: All four *TemplateWikiPage settings default to blank. When blank, the app resolves the page name at runtime: sidebar-standing/default-{sport}-standings (standings), sidebar-standing/default-{sport}-schedule (schedule), or sidebar-standing/default-{sport}-stats (stats). These pages are seeded automatically on app install/upgrade — you do not need to create them. Set a pointer only when you want a custom template on a different page. The sidebar-standing/ wiki folder groups all bot-managed template pages together.
  • Schedule/stats sections are wiki-only: The enableSchedule and enableStats sections only write to config/sidebar (old Reddit). They have no effect on the new-Reddit TextArea widget.
  • Schedule/stats sections require marker pairs: Unlike standings (which auto-appends a marker block if missing), the schedule and stats sections require the marker pair to already exist in config/sidebar. The app will not append them on first run — you must place the markers manually as part of the cutover.

Fetch Domains

This app makes outbound HTTP requests to the following third-party domains, each declared in the app's devvit.json permissions.http.domains allowlist. All requests are read-only GET requests to public, unauthenticated endpoints — no credentials are stored or transmitted, and no subreddit-specific identifying information is sent beyond what is needed to fetch the requested resource (e.g. league ID, season year).

Domain Operator Purpose
statsapi.mlb.com MLB Advanced Media (Major League Baseball) MLB regular-season division standings, current-month schedule, and per-player team stats. Up to four requests per cron tick when the configured sport is MLB: one for standings (always), one for schedule (if enableSchedule is true), and two for per-player hitting and pitching stats (if enableStats is true).
api-web.nhle.com National Hockey League NHL division standings. Fetched once per cron tick when the configured sport is NHL.
site.api.espn.com ESPN NBA conference standings and NFL division standings. Fetched once per cron tick when the configured sport is NBA or NFL.

This app does NOT make outbound requests to any other domain.

About this app