Public Games API

The Public API provides published competition data for the National Games app, media partners, and other public integrations. It supports editions, sports and event categories, delegation rosters, fixtures, results, previews, and medal standings. Tournament OS staff publish data through the existing schedule and result approval workflow. OpenAPI 3.1 contract

Existing consumers can share the Markdown adoption guide for animated sport logos, PUBG Mobile squad identity, and public embeds. v1 adoption guide

Connect an integration

Use the Tournament OS deployment’s HTTPS origin followed by /api/public/v1. Use a separate base URL and token for staging and production. Local development uses http://localhost:3000/api/public/v1 when the app runs on port 3000.

  1. As a platform administrator, open Account menu → Public API → Create API token. Give the token a label, select an edition scope when the integration needs only one edition, and set an expiry of 1–365 days. The default is 90 days.
  2. Copy the secret when it appears and store it in the integration’s server-side secret store. Use Authorization: Bearer <token> on GET and HEAD. Create a replacement token before expiry and revoke the old token after verifying the replacement.
  3. For a public browser or native mobile app, route calls through your integration backend. The backend adds the bearer token and returns the public data your app needs. Keep the long-lived token out of JavaScript, app binaries, URLs, logs, and public configuration.

Use Revoke on an active token to stop requests immediately and retain the record. Delete removes the token from the list and ends any active access. A replacement token can be verified before revoking the old one.

PUBLIC_API_BASE=https://podium.example/api/public/v1
curl --fail-with-body \
  -H "Authorization: Bearer $TOURNAMENT_PUBLIC_API_TOKEN" \
  "$PUBLIC_API_BASE/editions?locale=en&page=1&pageSize=25"

Direct cross-origin browser requests require the exact HTTPS origin in the deployment’s comma-separated PUBLIC_API_ALLOWED_ORIGINS. The API accepts GET, HEAD, and OPTIONS and allows the Authorization request header without cookies. Allowed preflight requests return 204. Server-to-server and native requests without an Origin header can authenticate directly. Audience access to a rendered public page or iframe does not require an API token.

Resources and filters

IDs are strings. Use editionId, sportId, and eventId from their respective public rosters. Where an endpoint accepts a sport and an event together, use an event that belongs to the sport in that edition. Keep those IDs when a translation or display label changes.

GET path relative to /api/public/v1UseAdditional query parameters
/editionsDiscover accessible published editions, including featured entries.cmsTournamentId, featured, page, pageSize
/editions/{editionId}Read the edition identity, dates, branding, and its CMS reference.
/editions/{editionId}/sportsRead the edition’s ordered sports, logos, mascot videos, and counts.page, pageSize
/editions/{editionId}/eventsRead competition categories with fixture and result counts.sportId, page, pageSize
/editions/{editionId}/teamsRead the edition’s delegation roster.page, pageSize
/editions/{editionId}/fixturesRead the approved schedule for matches, races, heats, and sessions.sportId, eventId, view=upcoming, page, pageSize
/editions/{editionId}/resultsRead current official scorecards and their finishing entries.sportId, eventId, view=latest, page, pageSize
/editions/{editionId}/overviewRead the next two fixtures, latest two official results, and medals together.sportId
/editions/{editionId}/medalsRead a coherent edition medal publication, with overall and sport standings.sportId, snapshotId

All resources accept locale=en or locale=ne, with en as the default. The response reports the requested meta.locale. Missing Nepali text uses the stored display text. Locale affects display labels where translations exist. IDs, ranks, counts, dates, and times retain their values across locales. The integration owns translated status labels, Devanagari digits, and Bikram Sambat display.

Lists return { "data": [], "meta": { ... } } with page, pageSize, total, totalPages, state, and updatedAt. The default is page 1 with 25 items, the maximum page size is 100, and the maximum page number is 1,000,000. An out-of-range page returns an empty array with the original requested page and the actual total. An empty scope has totalPages: 0 and state: "published_empty". Fetch every page when you need the complete roster.

Use meta.total for a filtered list count and meta.counts on fixtures and results for the associated filter badges. counts.allEvents and counts.byEvent describe the full sport or edition and honor the list’s view, independent of the selected event and page. An event filter by itself implies the event’s sport for badges. Events with no matching records have a zero badge. /events also returns meta.counts.fixtures and meta.counts.results across its full scope. /overview returns fixtureCount, upcomingFixtureCount, and resultCount alongside the preview arrays.

Discovery gives a featured 10th National Games edition priority, using the explicit competition type and edition number. Other featured editions follow, then remaining editions. Within each group it uses the latest available branding or identity update and an edition ID tie-break. Roster resources return sortOrder for the requested scope. Fixtures sort by startsAt ascending with nulls last. Results sort by publishedAt descending with nulls last. Both use the fixture ID to break a timestamp tie.

Dates such as startDate and endDate are Gregorian civil dates. Keep YYYY-MM-DD intact when converting to Bikram Sambat. Treat timestamps as instants and use nepalDate to group fixtures in Asia/Kathmandu. For example, 2026-12-02T19:05:00Z falls on December 3 in Nepal. Keep a null start time in a separate pending group.

Sports return a nullable animatedLogoUrl for the uploaded or hosted video, with mascotVideoUrl still available as an alias. Use the separate logoUrl as the poster and fallback when the video is unavailable or the viewer prefers reduced motion. For published sports, load an uploaded video directly from its URL without an API bearer token.

For the designated PUBG Mobile event, published records can include Red and Blue squads from the same delegation. Key each fixture participant or result entrant by its ID and render its published name. Delegation keys identify the organization that receives medal credit. A later PRS sync preserves the lineup saved on an approved schedule. The same publication rules apply to data imported from a direct PRS connection and an uploaded snapshot.

Publication and identity

The API reads editions that staff made public. A private edition, an edition outside the token’s scope, and an unknown edition each return 404. An available scope with zero matching records returns 200 with an empty list. A medal table can be unpublished or published with zero awards. Read the corresponding state and timestamp before showing totals.

Fixture IDs persist across schedule changes. The stored phase label and optional round, match, and group identify the competitive unit. Execution status uses scheduled, time_pending, live, completed, or cancelled. The full schedule includes approved cancellations. Upcoming selects approved scheduled fixtures with known future start times. A live status indicates a live score explicitly made visible and bound to the current schedule. Participants use the approved schedule snapshot and can include multiple entrants in an individual race or team event. The participant order property is the published display order.

The results list uses fixtureId as its stable public result id. An approved correction replaces the displayed result and updates updatedAt while keeping id and publishedAt. Until approval, consumers see the last official version. The first-publication clock uses the overlap of result approval and public edition visibility from the audit history. For a published legacy edition without visibility history, it uses first recorded approval where available. When the applicable history is missing, the timestamp is null.

entries preserve tied rank values. A non-classified entry may have rank: null and an outcome of DNS, DNF, or DSQ. winner is the first classified rank 1 entry for the overview. Read all rank 1 entries when showing a tied result. result is the display mark and can contain a time, score, distance, or points. metric holds a numerical mark when present and its meaning depends on the sport and scoring profile. A heat winner has a medal only when the official awards projection supplies one. Retain structured entrant and performance fields in the adapter even when the current cards show a display string.

Medals use the official award records. Credit one award to a delegation for a relay or squad, regardless of roster size. Gold, silver, and bronze counts determine rank in that order. Equal counts share standard competition ranks such as 1, 1, 3; the delegation’s stable order resolves display order only. A zero-medal delegation has rank: null and numerical zero counts. Each sport includes the published delegation roster, including unranked rows.

Read overall and sport standings from the same snapshotId. Use GET .../medals?sportId=<sport-id>&snapshotId=<snapshot-id> for a later tab request. The filtered response includes the requested sport table and the overall reference. Render its sport table on a sport page. The sum of the sport totals across an unfiltered publication equals its overall totals. Historic snapshots carry the delegation and sport labels published at that time. medalsUpdatedAt identifies the medal dataset’s publication time and is independent of branding edits and request time.

For movement, calculate previousRank - rank from the same table. When both are present, 4 - 2 moves up two places, 1 - 2 moves down one, and zero means unchanged. Null means no comparable rank. Keep the selected snapshot reference with the rendered data. Existing editions with a logged public release or credited awards start with a baseline from API rollout. A legacy public edition without either may return unpublished. Publishing through Tournament OS creates a baseline even with zero awards. Subsequent changes to the published awards or roster establish comparison snapshots. Repeated reads leave the snapshot and movement consistent.

Map the National Games screens

ScreenSource and adapter mapping
Home permanent Games cardPrefer the existing CMS itournament(cmsTournamentId) for dates, logo, location, cover, and CMS-owned display content. Resolve the Competition API entry by cmsTournamentId and use the returned edition ID for its Games route. Use the explicit competitionType and editionNumber to identify the intended Games edition.
Home featured popupKeep the existing CMS itournaments discovery and use an explicit featured flag. Use the CMS ID to resolve the linked edition. When several records are featured, retain the UI’s preference for this Games edition, followed by most recently updated CMS record with a stable ID tie-break. With no featured record, omit the popup and keep the permanent Games card.
Games heroEdition detail supplies dates, name, location, logo, distinct mascot, and optional cover. Keep CMS ownership of this branding when a verified mapping exists. Use the supplied mascot asset only as an explicit configured fallback.
Games tally, carousel, and overviewUse /medals overall totals and medalsUpdatedAt, all pages of /sports for the carousel, and /overview for preview slices. Preserve the competition record total and the medal snapshot when opening full views.
Games fixtures and resultsUse /fixtures and /results without a sport filter. Fixture and result objects carry the event and sport references needed for row labels. Group the schedule by Nepal date. Render ranked entries and actual awards from results.
Games medalsUse /medals overall rows and every sport table’s totals. Link sport names using their IDs and keep the overall snapshot reference.
Sport header and eventsFind the sport by ID in /sports. Use its event and fixture counts plus the selected sport’s medal total. Use /events?sportId=... for category rows and their respective fixture/result counts.
Sport fixtures and resultsPass sportId and optionally eventId. Read badge totals from meta.counts. Render the requested event selection without changing the rest of the sport’s navigation.
Sport medalsPass sportId and the selected snapshotId to /medals; render the matching sport table with its own current and previous ranks.

In src/api/nationalGamesApi.ts, add a typed adapter for these resources. In useNationalGamesData, keep loading, unavailable, empty, and published states distinct and remove synthetic fallbacks from production. Use backend sports and delegation IDs consistently in the roster, schedule, results, and medal renderers. Replace local alias lists once the authoritative roster is configured, or use a maintained one-to-one mapping for existing assets. A legacy asset alias is presentation metadata. Keep the API’s ID as the identity used for navigation and joins.

Source decisions and remaining gaps

RequirementRelease behavior and source owner
Edition identity and CMS linkingStaff set cmsTournamentId in Edition → Staff & activity → Edition settings → Integration metadata. Record the actual competition type and public edition profile there. Missing mappings remain null until the CMS and competition administrators confirm the matching records. The external CMS continues to own its discovery, featured banners, and generic tournament popups.
Authoritative sports and delegationsThe roster is edition data, populated by approved PRS imports and local catalogue records. Confirm the official National Games roster with the organiser and add delegations with no approved entrants before publishing if they belong in the table. The pinned PRS seed has 32 sports, 383 events, and 11 delegations. Its placeholder images and the frontend’s aliases need a verified mapping to the published data. PRS catalogue at revision 37de333
Localization and mediaStaff can set English and Nepali edition names and locations. The other names use stored labels where no translations exist. Edition updatedAt is the latest known Tournament OS identity or branding change, including saved integration metadata and logged changes to inherited branding. Read the CMS branding timestamp from the CMS. Managed media resolve against the deployment origin and work without staff-session cookies. Dedicated sport/delegation translation and vetted mapping fields can be added when an authoritative source is available.
Fixture kinds, phases, lanes, and timingTournament OS retains schedule/stage labels and entrant display order. Use those references for phase labels. Pool lane allocations, a universal phase taxonomy, and fixture postponement/placeholder semantics need a competition-owner field contract. Missing venue and time are null when genuinely unavailable. The current schedule approval form requires a time and venue.
Results and awardsStaff-approved revisions establish official results and corrections. Provisional score values and private scorer notes are excluded. Officials can approve shared podium places and medals in a manual ranked final. Athlete performances and delegation award records serve separate roles in the response.
Medal comparisonsOverall and sport tables share one immutable edition snapshot. Previous ranks compare the preceding published snapshot and keep the original sport and delegation scopes. Treat the baseline’s prior ranks as unknown.
Publication and refreshChanges become available after approval and commit. The integration owner and host should agree the production availability and refresh target based on actual traffic and venue needs.

Errors and refresh

Responses include X-Request-Id for diagnosis and Cache-Control: private, no-store. The API does not specify a push feed. Refresh on page open and user request, using backoff and the token budget for periodic polling. An integration backend may coalesce upstream requests. Partition any downstream public data cache by edition, scope, locale, and snapshot as applicable. Do not cache its token with a response or expose it to consumers.

StatusCodeHandling
400invalid_requestFix malformed IDs or invalid, duplicated, or unsupported query parameters.
401unauthorizedCheck the bearer token’s configuration, expiry, or revocation. Responses include a WWW-Authenticate Bearer challenge.
403origin_not_allowedUse the deployment’s configured browser origin or route through the integration backend. A browser may conceal the response body when CORS denies access.
404not_foundCheck edition, sport, event, or snapshot identity and token scope. Private editions appear unavailable.
405method_not_allowedUse GET or HEAD to read the API. Browser preflight uses OPTIONS.
429rate_limitedWait Retry-After seconds, then retry. The fixed window resets at the next UTC minute. The default is 120 requests per minute per token, set by PUBLIC_API_REQUESTS_PER_MINUTE.
500unavailableKeep the last successful data visible with a freshness indication when appropriate, and retry with backoff. Provide the request ID to the operator.

Examples and integration checks

The examples use synthetic IDs and performances. To discover the permanent Games entry from an existing CMS record, query GET /editions?cmsTournamentId=example-cms-10. For Tournament OS featured discovery, use GET /editions?featured=true. The first ranked featured item follows the discovery order above. A successful response with an empty array means there is no popup candidate for that token.

An existing event can have an empty approved schedule. With a valid edition and event filter, a complete successful example is:

{
  "data": [],
  "meta": {
    "locale": "en",
    "page": 1,
    "pageSize": 25,
    "total": 0,
    "totalPages": 0,
    "state": "published_empty",
    "updatedAt": null,
    "counts": {
      "allEvents": 0,
      "byEvent": [{ "eventId": "10000000-0000-4000-8000-000000000005", "count": 0 }]
    }
  }
}

A published legacy edition without a medal snapshot can return this successful /medals response:

{
  "data": {
    "state": "unpublished",
    "snapshotId": null,
    "previousSnapshotId": null,
    "medalsUpdatedAt": null,
    "previousSnapshotAt": null,
    "overall": null,
    "sports": []
  },
  "meta": { "locale": "en" }
}

A published snapshot with zero awards has state: "published", a snapshot ID and time, zero totals, and the published roster with null ranks. The OpenAPI examples include that complete shape, a multi-entrant fixture crossing a Nepal day boundary, a heat with no medals, and a corrected medal result whose fixture ID and first publication time stay the same. The published tie example has rank 1, 1, 3, an unranked team, and two sport tables that reconcile with the overall tally. OpenAPI examples

An inaccessible resource returns 404 with a structured error body:

{
  "error": {
    "code": "not_found",
    "message": "The requested public resource is unavailable."
  }
}

Verify before connecting the National Games app

Run the integration suite against a disposable Tournament OS database with current migrations applied.

TOURNAMENT_DEMO=1 TOURNAMENT_DATABASE_URL=postgresql://localhost/tournament_os_api_test npm run test:public-api
CheckExpected result
API accessMissing or revoked credentials yield 401. Private and out-of-scope editions yield 404. Allowed browser preflight works without credentials. A rate-limited client receives Retry-After.
Discovery and brandingA CMS ID resolves to one edition and the requested locale falls back to the stored text. Empty featured discovery leaves the permanent card visible. Confirm CMS-side popup routing in the consuming client.
Roster and countsCompare the published sports and delegations with the organiser’s authoritative roster before launch. A one-item fixture page still returns full filtered counts and event badges. Verify known zero badges as well as unavailable IDs.
Schedule and resultsApproved reschedules retain fixture identity. Pending and cancelled fixtures stay out of upcoming previews. Use nepalDate to verify a fixture near a UTC day boundary. A correction keeps the result’s first publication order.
Awards and snapshotsA relay or squad award counts once. Verify shared awards, standard competition ranks, unranked zero rows, and arithmetic across all sport tables. A correction updates the affected published totals while the earlier snapshot remains available by ID.