syntax = "proto3"; package kairos.v1; option go_package = "github.com/kairos/proto/kairos/v1"; // Live sports scores feed, schema version 1. // // Game data only, no market data, in one shape for every sport: head-to-head // games (football, tennis, table tennis, esports, chess, fights) and fields of // many competitors (golf, motorsport, racing). Typed fields hold what every // sport has. What only some sports have goes in the venue's own strings // (period, clock), the score text and `attributes`, so a new sport or score // format fits without a schema change. // // Conventions: // - Times are int64 Unix milliseconds named `*_at_ms`; 0 when not known. // - A vocabulary (phase, kind, subtype, side, role) is snake_case text from a // documented list. Read a value you do not know as the list's fallback // ("unknown" for phase, "other" for kind); lists may grow. // - Scores, sides and per-competitor lists are in `competitors` order. // - `attributes` holds only documented keys (snake_case; a provider's id is // `__id`). Ignore a key you do not know; keys are added, // never renamed. // - Adding a field or a vocabulary value keeps schema_version; a breaking // change bumps it. // One side of the game: a team, a player, a pair, a driver. message SportsCompetitor { string name = 1; // Short name, e.g. "LAL": from Polymarket's team list, TxODDS or ESPN. // Often empty (most esports, tennis and soccer teams have none); never derived from the name. string abbreviation = 2; // "home" or "away" in a two-sided game; empty in a field of many competitors. string side = 3; // The competitor's score as text: "98", "3" (sets won), "2" (maps won), // "245/6", "-5" (to par), "1:32.456". Empty when there is no score feed. string score = 4; // The score as a number, when it is one. optional double score_value = 5; // Place in a field of many competitors (1 = leading). optional int32 position = 6; // Serving, batting, in possession, or to move. bool has_turn = 7; // Facts about this competitor no common field covers, e.g. "seed", "cards". map attributes = 8; } // One segment of the score: a set, game, inning, quarter, half, period, map, // round, frame, end or leg. Segments nest, e.g. the game in play inside a set. message SportsScorePart { // What the segment is: "set", "game", "inning", "quarter", "map", ...; // "segment" when the venue does not say. string kind = 1; // Its name within the game: "1", "2", "OT", "current". string label = 2; // One score per competitor, in `competitors` order, as the venue writes it. repeated string scores = 3; // Anything else reported for the segment, e.g. a tiebreak "8-6". string detail = 4; bool in_progress = 5; repeated SportsScorePart parts = 6; } message SportsGame { reserved 8, 9, 15, 16; reserved "live", "ended", "updated_at", "scheduled_at"; // Opaque; equal to `gameId` on GET /sports/live-events for a game listed there. Do not parse it. string game_id = 1; // League or tour code, e.g. "nba", "epl", "atp", "cricwbbl", "val". The `league:` scope. string league = 2; // e.g. "basketball", "soccer", "tennis", "cricket", "golf", "esports", or // "other" for a league not yet classified. The `family:` scope. string sport_family = 3; // The competition's name when a source gives one, e.g. "NFL" from TxODDS; // usually empty. `league` is always set and is what to group by. string competition = 4; // Two for a head-to-head game, home first; every entrant for a field. repeated SportsCompetitor competitors = 5; // The game's lifecycle, the same for every sport and source; the only one. // In play: live, break (between periods: half-time, an intermission, the end // of a quarter), overtime, shootout. Not started: scheduled. Finished: final. // Stopped: suspended (to resume), delayed. Not played: postponed, cancelled. // unknown: Kairos lists the game but cannot tell, e.g. a game with no score // feed (source predictfun or schedule). Read a value you do not know as unknown. string phase = 6; // The venue's status, verbatim (e.g. "InProgress", "running", "F/OT"). A label; // use phase for the lifecycle. string status = 7; // The whole score as one line, in `competitors` order whatever order the venue // writes it in: "98-94", "6-2, 7-6(8-6), 2-2:30-15", "11-9, 8-11, 11-7", // "000-000|2-0|Bo3", "0-1|Submission". Empty when there is no score feed. string score = 10; repeated SportsScorePart parts = 11; // The venue's period, verbatim, e.g. "Q4", "2H", "HT", "End 3", "2/3", "S3". string period = 12; // The venue's game clock, verbatim, e.g. "05:12". string clock = 13; // Event slug, for joining the game to its markets on GET /sports/live-events. string slug = 14; // No score state for 120 seconds, so the score may be behind; also true for a // game with no score feed. A change of stale alone is sent as CHANGED. bool stale = 17; // Where the game's state comes from: "polymarket" for a live score feed; // "predictfun" or "schedule" for a listed game with none. One match is one // game: a TxODDS or ESPN game describing a Polymarket game is folded into it, // which then carries that source's events and its id (txodds_fixture_id, // espn_event_id). "txodds" or "espn" only for a game no Polymarket game matches. string source = 18; // Documented facts no typed field covers: other providers' ids for the game // ("sportradar_game_id") and facts only some sports have ("possession"). map attributes = 19; // When the score state was observed; 0 for a game with no score feed. int64 updated_at_ms = 20; // Scheduled start, when the source gives one. int64 scheduled_at_ms = 21; // When the game finished, when the source gives it. int64 finished_at_ms = 22; } enum SportsUpdateKind { SPORTS_UPDATE_KIND_UNSPECIFIED = 0; // The game changed; replace what you hold for game_id. SPORTS_UPDATE_KIND_CHANGED = 1; // The game left what this subscription covers; drop it and its events. Sent when // it ended more than five minutes ago, when it has been off every source for 30 s // (a source that fails briefly removes nothing), and to a family: or league: // scope the game moved out of; it is still live under its new routing keys. SPORTS_UPDATE_KIND_REMOVED = 2; // The game re-sent unchanged by the publisher's periodic pass; replace what you // hold, as for CHANGED. Most snapshot rows carry it, and so do live frames after a gateway restart. SPORTS_UPDATE_KIND_REFRESH = 3; } // One game's change. // WebSocket: tag 0x23 [SportsGameUpdate]. NATS (internal): subject sports.v1.update. // // Ordering: (lease_epoch, seq) only grows. A larger lease_epoch means a new // publisher; accept it and every later frame. For one game, ignore a frame // whose (lease_epoch, seq) is not greater than the one you hold. message SportsGameUpdate { uint32 schema_version = 1; uint64 lease_epoch = 2; uint64 seq = 3; string game_id = 4; SportsUpdateKind kind = 5; // Unset when kind is REMOVED. SportsGame game = 6; int64 published_at_ms = 7; // Digest of `game`; the same digest means the same game state. string content_hash = 8; // Routing keys, set on every kind including REMOVED. string sport_family = 9; string league = 10; } // The games a subscription covers, sent after each accepted subscribe. // WebSocket: tag 0x24 [SportsSnapshot]. Large snapshots arrive in several // chunks; apply each, and treat the scope as loaded at last_chunk. message SportsSnapshot { uint32 schema_version = 1; // The subscription this answers: "all", "family:", "league:" or "game:". string scope = 2; repeated SportsGameUpdate games = 3; uint32 chunk_index = 4; bool last_chunk = 5; // False while the gateway may lack games: after it restarts, after a new publisher // takes over, or after 30 s of publisher silence, until the publisher's next full // pass. Games that arrive later come as ordinary updates. bool complete = 6; // Only for a `sports.events` subscription: each covered game's most recent // events, oldest first per game, deletions omitted. Games come only with `sports`. repeated SportsEventUpdate events = 7; } // Play-by-play, in one shape for every sport (KAI-2877). Typed fields hold what // every event has; a sport's own detail goes in the source's verbatim strings, // `attributes` and `measures`, so a new sport needs no schema change. // A person in an event: scorer, assister, batter, pitcher, fighter, driver. message SportsParticipant { // As the source writes it; empty when the source gives only an id. string name = 1; // The source's own id for the person; empty when it has none. string id = 2; // What they did here, snake_case: "scorer", "assist", "player_in", // "player_out", "carded", "injured", "penalized", "shooter", "batter", // "pitcher", "fouled"; "player" when the source does not say. string role = 3; // Their side, as an index into SportsGame.competitors; unset when unknown. optional int32 competitor_index = 4; } // A measured detail of an event, e.g. pitch speed, lap time, shot distance or a // court position (a measure whose parts are "x" and "y"). message SportsEventMeasure { // snake_case, e.g. "pitch_speed", "lap_time", "shot_distance", "coordinate". string name = 1; // As the source writes it. string value = 2; // The value as a number, when it is one. optional double number = 3; // e.g. "mph", "s", "ft"; empty when the source gives none. string unit = 4; repeated SportsEventMeasure parts = 5; } // One thing that happened in a game. message SportsGameEvent { // Stable for the life of the game and unique across the feed: ":". string event_id = 1; string game_id = 2; // "txodds" or "espn" for a play-by-play feed; "scoreboard" for an event // Kairos derived from the game's own score and phase changes. Not the game's source. string source = 3; string source_event_id = 4; // Only grows for one event_id. A correction, enrichment or deletion of the // event arrives as the same event_id with a larger revision. uint64 revision = 5; // A feed error, such as a duplicate; drop it. An overturned play is never deleted: it is revised with attribute overturned=true. bool deleted = 6; // Normalized across sports: game_start, period_start, period_end, game_end, // score, shot, foul, penalty, card, substitution, timeout, injury, review, // stoppage, set_piece, offside, possession, turnover, rebound, violation, // play, pitch, at_bat, lap, pit_stop, knockdown, round_end, point, rally, or // other. "play" is a routine play no other kind names. Treat a kind you do // not know as "other"; the list may grow. string kind = 7; // The normalized refinement of kind, snake_case, from a list per kind, e.g. // card: yellow, red; score: touchdown, field_goal; set_piece: corner; empty // when there is none. Treat one you do not know as empty. string subtype = 22; // The source's own type, verbatim, e.g. "penalty_flag", "touchdown", "Jump Shot"; // for an event Kairos derived (a period start), the derived name. string source_type = 8; // The source's own text for the event, verbatim; empty when it has none. string description = 9; // The period the event happened in, as the source writes it: "Q4", "H2", "3". string period = 10; // The game clock at the event: "67'" (soccer minute), "08:00" (time left in // an American-football quarter), or the source's own text ("05:12"). string clock = 11; // Wall time the event happened, in ms; 0 when the source does not say. int64 occurred_at_ms = 12; // Order within the game: sort ascending, ties by event_id. Late arrivals // carry the key of when they happened, not of when they arrived. int64 sort_key = 13; // The source's own sequence number for the event within the game; 0 when it has none. uint64 sequence = 14; // The side the event belongs to, as an index into SportsGame.competitors; // unset for an event of the whole game (a period end, a timeout by the officials). optional int32 competitor_index = 15; repeated SportsParticipant participants = 16; // The score right after the event, one per competitor in SportsGame.competitors // order, as SportsCompetitor.score writes it; empty when the source does not say. repeated string scores = 17; // The event changed the score. bool scoring = 18; // Facts no common field covers, keyed in snake_case, e.g. "points", // "outcome", "subject", "period_name". map attributes = 19; repeated SportsEventMeasure measures = 20; // When Kairos first saw this revision, in ms. int64 received_at_ms = 21; } // One event's change. // WebSocket: tag 0x25 [SportsEventUpdate], only on a `sports.events` // subscription. NATS (internal): subject sports.v1.event. // // Ordering: shares (lease_epoch, seq) with SportsGameUpdate. For one event_id, // ignore a frame whose event.revision is not greater than the one you hold. // When a game is REMOVED, drop its events too. message SportsEventUpdate { uint32 schema_version = 1; uint64 lease_epoch = 2; uint64 seq = 3; string game_id = 4; // Routing keys, as on SportsGameUpdate. string sport_family = 5; string league = 6; SportsGameEvent event = 7; int64 published_at_ms = 8; // Digest of the event without revision and received_at_ms. string content_hash = 9; } // Internal, NATS subject sports.v1.manifest; never sent to WebSocket clients. // The publisher's whole live set; a gateway drops cached games it does not list. message SportsFeedManifest { uint32 schema_version = 1; uint64 lease_epoch = 2; uint64 seq = 3; repeated string game_ids = 4; int64 published_at_ms = 5; }