UZSL Live API v1

To‘liq hujjat: GraphQL (Hudl/StatsBomb shape) + REST. Graphics: faqat api_url, client_id, client_secret. Ma’lumot: live eventlar (~3s) → memory → API (request pathda SB dump yo‘q).

1. Config 2. Live oqim 3. Auth 4. GraphQL 5. REST 6. Explorer 7. Checklist

1. Faqat shuni almashtiring

Eskihttps://live-api.statsbomb.com/v1/
UZhttp://uzstats.uzsl.uz/apiv1/v1/
DOhttps://dostats.uzsl.uz/apiv1/v1/
client_id / secretAdmin → Graphics client
'api_url' => "https://dostats.uzsl.uz/apiv1/v1/",
'client_id' => "<from admin>",
'client_secret' => "<from admin>",

Aliaslar: POST /v1/token = POST /token; POST /v1/graphql = POST /graphql (apiv1 prefix bilan).

2. Live ma’lumot oqimi

StatsBomb events (~3s tick)
  → MatchTracker memory
     ├─ team stats  → GraphQL live_team_match_aggregated_stat · REST /broadcast · /stats
     ├─ player panel → REST /admin/explore/.../players/{id}
     └─ async SQLite (events, match_stats, player_match_stats)

3. Auth

UsulQayerdaQanday
Graphics Bearer POST /v1/token → GraphQL Authorization: Bearer <access_token>
API key REST / broadcast / explore API X-API-Key yoki Authorization: Bearer
SSE /broadcast/.../stream ?api_key=
Admin /admin/* POST /admin/login yoki HTTP Basic
curl -X POST https://dostats.uzsl.uz/apiv1/v1/token \
  -H 'content-type: application/json' \
  -d '{"client_id":"YOUR_ID","client_secret":"YOUR_SECRET"}'
# → { "access_token":"uzsl_…", "token_type":"Bearer", "expires_in":86400 }

4. GraphQL (lokal)

Default GRAPHQL_MODE=local. Upstream majburiy: header X-GraphQL-Upstream: 1.

RootManbaMajburiy filter
live_competition_seasonconfig
live_matchSQLite catalogodatda competition/season
live_match_eventSQLite eventswhere.match_id._eq
live_match_event_aggregateSQLitewhere
live_team_match_aggregated_statmemory → SQLitewhere.match_id._eq

Boshqa rootlar (lineup, player agg, …): upstream header yoki REST Explorer.

4.1 Competition / season

query {
  live_competition_season {
    competition_id
    competition_name
    season_id
    season_name
  }
}

4.2 Matches

query Matches {
  live_match(
    where: { competition_id: { _eq: 1839 }, season_id: { _eq: 316 } }
    order_by: { match_date: desc }
    limit: 20
  ) {
    match_id match_name match_date match_local_kick_off
    match_home_team_id match_home_team_name
    match_away_team_id match_away_team_name
    match_home_score match_away_score match_play_status
    competition_id season_id
  }
}

4.3 Events

query MatchEvents($match_id: Int!) {
  live_match_event(
    where: { match_id: { _eq: $match_id } }
    order_by: { index: asc }
    limit: 1000
  ) {
    id match_id name type outcome
    team_id player_id
    period minute second timestamp index
    xg key_pass card advantage
    updated_at
  }
}
query EventCount($match_id: Int!) {
  live_match_event_aggregate(where: { match_id: { _eq: $match_id } }) {
    aggregate { count }
  }
}

4.4 Team aggregated stats (Hudl)

query TeamAgg($mid: Int!) {
  live_team_match_aggregated_stat(where: { match_id: { _eq: $mid } }) {
    match_id team_id stat_name value
  }
}

Filter: stat_name: { _eq: "xg" } yoki team_id: { _eq: … }.

stat_namevalueIzoh
xgfloatExpected goals
shots / shots-on-target / shots-off-target / shots-blockedint
passes-attempted / passes-completedint
pass-success-ratio0–1Hudl ratio (masalan 0.83 = 83%)
possession0–1ratio
key-passes / tackles-attempted / touchesint
goalkeeper-saves / corners-attemptedint
fouls-committed / offsidesint
yellow-cards / red-cardsint

4.5 curl

curl -X POST https://dostats.uzsl.uz/apiv1/v1/graphql \
  -H 'Authorization: Bearer ACCESS_TOKEN' \
  -H 'content-type: application/json' \
  -d '{"query":"query { live_competition_season { competition_id season_id } }"}'
{
  "operationName": "Matches",
  "variables": {},
  "query": "query Matches { live_match(limit: 5) { match_id match_name } }"
}

5. REST API

Swagger: /docs · JSON katalog: /endpoints · Auth: X-API-Key

5.1 Public / health

MethodPathAuthIzoh
GET/Monitor UI
GET/healthHealth
GET/endpointsBu katalog (JSON)
GET/v1/Shu docs
GET/docs · /redoc · /openapi.jsonOpenAPI
GET/debug/requestsAPI keySo‘rov log

5.2 Graphics

MethodPathAuthIzoh
POST/v1/token · /tokenclient_id/secret → Bearer 24h
POST/v1/graphql · /graphqlBearer / keyLokal GraphQL
GET/broadcast/{match_id}/statskeyTeam stats memory (~ms)
GET/broadcast/{match_id}/streamkey / ?api_keySSE

5.3 Matches & live

MethodPathIzoh
GET/competitionsCompetition/seasons
GET/matches?date=YYYY-MM-DDLokal matchlar
GET/matches/{id}Metadata + score
GET/matches/{id}/statsTeam stats (memory→sqlite→sync)
GET/matches/{id}/events?limit=&offset=Events page
POST/matches/{id}/syncSB pull + recompute
POST/matches/{id}/trackLive poller start
DELETE/matches/{id}/trackStop
GET/liveTracked matches + tick status
curl -H "X-API-Key: KEY" \
  http://uzstats.uzsl.uz/apiv1/matches/1453630/stats
curl -H "X-API-Key: KEY" \
  http://uzstats.uzsl.uz/apiv1/broadcast/1453630/stats

5.4 Admin

MethodPathIzoh
GET/adminAdmin UI
POST/admin/login{username,password} → access_token
GET/POST/admin/api-keysCRUD + peer sync
GET/POST/admin/api-keys/export|import|syncCluster
DELETE/admin/api-keys/{id}Revoke
GET/POST/DELETE/admin/oauth-clientsGraphics clients
GET/POST/admin/oauth-clients/export|import
GET/admin/usage · POST .../resetTraffic
GET/admin/system · /admin/system/localUZ+DO load
GET/admin/catalog · POST .../syncSeason fixtures

6. Match Explorer (REST + UI)

UI: /admin/explore · Auth: admin token / API key

MethodPathIzoh
GET/admin/explore/tournamentTurnir meta
GET/admin/explore/matches?q & date_gte/lte & limit
GET/admin/explore/matches/{id}Detail + team stats + score
GET/admin/explore/matches/{id}/eventsTimeline
GET/admin/explore/matches/{id}/lineupsLineups + jabha + key stats
GET/admin/explore/matches/{id}/players/{pid}Hudl player panel (live memory)
GET/admin/explore/matches/{id}/pitchZones 3×3 + shot/pass
POST/admin/explore/matches/{id}/refreshHydrate parts

Player panel maydonlari

Goals, Total xG, Average xG per shot, Shots, Shots On Target, Assists, Key Passes, Possession, Passes, Successful Dribbles, Pass Completion %, Fouls Committed, Yellow / Second Yellow / Red Cards, Offsides, Corners. Javobda panel[] + source (memory|sqlite|events) + tracking.

7. Checklist — graphics

  1. Admin → Graphics client → client_id / client_secret
  2. api_url = UZ yoki DO …/apiv1/v1/
  3. Kod: token + graphql o‘zgarmasin
  4. Team stats: live_team_match_aggregated_stat yoki /broadcast/{id}/stats
  5. Player panel: Explorer yoki explore REST (SB player dump emas)

README (server): repo README.md · StatsBomb guide: live-data-api-guide.statsbomb.com