Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ below (see "Releasing" in the README).

## [Unreleased]

### Added

- **The bookmaker's name in the odds records.** Schema v1's `Odds` and `OddsLine` have a new field
`provider_name` next to `provider_id`, for example `"bet365"` for provider 1: the same names as
`GET /api/v1/odds/providers`, taken from the built-in table when the record is built (no request to
SofaScore, nothing stored changes). It is null for a provider the table does not know. The odds routes
of API v1 return it, and the `odds` export dataset has a `provider_name` column after `provider_id`.
An added field is free in schema v1, so `schema_version` stays 1.

## [3.2.0] - 2026-11-20

3.2.0 removes the four 2.x environment names that 3.1 still read with a warning; set without their new
Expand Down
13 changes: 13 additions & 0 deletions docs/api/openapi-v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -8832,6 +8832,18 @@
"title": "Provider Id",
"description": "SofaScore's id of the bookmaker the odds come from. Which bookmakers SofaScore offers depends on the country it sees the request from; the platform stores no address or location of the machine."
},
"provider_name": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Provider Name",
"description": "Name of the bookmaker of `provider_id`, as SofaScore writes it (the same names as `GET /api/v1/odds/providers`); null when the platform's built-in list of bookmakers does not know the id."
},
"fetched_at_utc": {
"anyOf": [
{
Expand All @@ -8858,6 +8870,7 @@
"event_id",
"key",
"provider_id",
"provider_name",
"fetched_at_utc",
"markets"
],
Expand Down
7 changes: 4 additions & 3 deletions docs/design/02-services.md
Original file line number Diff line number Diff line change
Expand Up @@ -4929,9 +4929,10 @@ As built at `216c2f9` (P30 #186, FX-30 #180, B1 #190, B2 #191). `docs/api/openap
reference data, and the platform never derives a country from the machine (`client.odds_country` comes
only from the user). Open (`03-implementation-plan.md` section 19): an optional reference fetch of the
listing, at most weekly, only when `client.odds_country` is set, through the client and the throttle and
never part of a match download, with every link stripped and the result merged over the table; and a
`provider_name` field in schema v1 (`Odds.provider_id` and `OddsLine.provider_id` are unchanged; an
additive change with the generated tables of `04-schema-v1.md`). The help text of `client.odds_provider`
never part of a match download, with every link stripped and the result merged over the table. Done on
2026-11-21: schema v1's `Odds` and `OddsLine` carry `provider_name` next to the unchanged `provider_id`,
looked up in the same table when the record is mapped (null for an unknown id; `04-schema-v1.md`, "Odds
and standings"). The help text of `client.odds_provider`
(`ssc describe config`, the config JSON Schema) names `1 = bet365 (international)` and the route.

As built at `395b6e0` (3.1.1 and 3.1.2: #220, #226, #230). `docs/api/openapi-v1.json` and
Expand Down
8 changes: 6 additions & 2 deletions docs/design/03-implementation-plan.md
Original file line number Diff line number Diff line change
Expand Up @@ -4844,7 +4844,7 @@ Pinned, and kept on purpose (not defects of the target design):
| Under an ASGI root path, `/<prefix>/api/v1` was answered without the access token | B2 #191 | done, B2 (#191); 3.0.0's default deployments never set a root path |
| The web UI cannot be served under a path prefix; an aborted search's cancel relies on the proxy closing its upstream connection | B2 #191 | documented in `docs/deploy/README.md`; the prefix: not planned (section 17) |
| The help text of `fetch.only_finished` in the web UI still names the 2.x match lists | the tenth revision | done, FX-34 (#194) (`05-web-ui.md` 6.16) |
| The Odds tab says "Bookmaker 1" (live validation M20); the providers' names are known only from SofaScore's per-country listing, which carries affiliate links | live validation, FX-24 gap 5 | done, B4 (#192): a built-in table and `GET /odds/providers`; a fetch of the listing and a schema field `provider_name`: open (section 19) |
| The Odds tab says "Bookmaker 1" (live validation M20); the providers' names are known only from SofaScore's per-country listing, which carries affiliate links | live validation, FX-24 gap 5 | done, B4 (#192): a built-in table and `GET /odds/providers`; the schema field `provider_name`: done (2026-11-21, section 20); a fetch of the listing: open (section 19) |
| The changelog entries of #180 to #192 (in their descriptions; P30's and FX-33's list the removals) | #180 to #192 | the 3.1 release pull request (section 19); done, #195 |
| The design documents were not updated by the live validation, FX-26, FX-27 and FX-16 | #174 to #176 | this revision (the ninth) |
| The sync's fallback to `leagues.txt` when the follows table cannot be read; `services/stats.py` with one used function; the docstrings of `cli/commands/watch.py`, `services/live/supervisor.py` (`--watch`, `watcher:<sport>`) and `services/follow_sync.py` (the player list "not stored"); `_task_row` of `ssc config show` printing a task's options as they are | the tenth revision | done, FX-34 (#194): the fallback stays and is logged as an error; the module removed; the docstrings corrected; an option the task does not define shown as `***` |
Expand Down Expand Up @@ -5674,7 +5674,11 @@ Open after 3.2.0 (the items of section 19's list that are not done, copied), in
would need a new Store area, a schedule and link stripping for a list that rarely changes. The table is
refreshed by hand when a provider is reported missing.
- **A `provider_name` field in schema v1** (`Odds`, `OddsLine`). Additive, with the generated tables of
`04-schema-v1.md`; until then a consumer reads the names from `GET /odds/providers`.
`04-schema-v1.md`; until then a consumer reads the names from `GET /odds/providers`. **Done (this PR,
2026-11-21).** `Odds` and `OddsLine` carry a nullable `provider_name` next to `provider_id`, filled by
`odds_from_payload` from the built-in table `sports.ODDS_PROVIDERS` (null for an unknown id), so the API's
odds records, the `odds` export dataset (column after `provider_id`) and the JSON Schema have it;
`schema_version` stays 1.
- **A replacement for `stage_name` and `listed_in`.** P30 dropped only the two score columns of the events
table: schema v1 reads `stage.name` from `stage_name`, and the listing rules (staleness, the reconcile of
a season's pages, the planner's listed events) read `listed_in`. Dropping them needs a design first.
Expand Down
23 changes: 19 additions & 4 deletions docs/design/04-schema-v1.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,15 @@ slices of rugby, volleyball, floorball and minifootball after the owner's decisi
#198, in 3.1.1; section 5). The trust routes, `cause` of the connection check and the follows default of
API v1 (`02-services.md` 6) return no record of this schema.

Amended on 2026-11-21, after the 3.2.0 release (not a numbered revision of the design documents). `Odds` and
`OddsLine` have a new nullable field `provider_name`, next to `provider_id`: the bookmaker's name from the
built-in table `ODDS_PROVIDERS` (`sofascore_scraper/sports.py`, B4, #192), null for an id the table does not
know ("Odds and standings"). Adding a field is free (section 3), so `schema_version` stays 1. The name is
derived when the record is mapped, so nothing stored changes and no request is made; the `odds` export
dataset has the column `provider_name` after `provider_id` (tabular columns follow the model's field order).
The generated tables, the two examples and the JSON Schema golden (`tests/golden/schema/json_schema.json`)
were regenerated (`REGEN_SCHEMA_DOC=1`, `REGEN_SCHEMA_GOLDEN=1`).

## 1. What the schema is, and what it is not

The platform stores SofaScore's responses as they are (one file per response, see `01-storage.md`). The
Expand Down Expand Up @@ -1031,7 +1040,10 @@ gives them, with a decimal derived as 1 + the fraction, rounded to three places
`sofascore_scraper/schema/mappers.py:632`). The mappers are `odds_from_payload`, `odds_lines` and `standings_rows`
(`:680-742`); `standings_rows` skips rows that have neither a team nor a position. The country SofaScore
answered for is not a field of `Odds`: it is in the slice's meta (`meta.country`) when the user set `[client]
odds_country`, and the provider id is in `meta.provider_id` as well as in the record. `winning_odds` and
odds_country`, and the provider id is in `meta.provider_id` as well as in the record. The bookmaker's name
(`provider_name`, since 2026-11-21) is not stored either: the mapper looks the id up in the built-in table
`ODDS_PROVIDERS` of `sofascore_scraper/sports.py` (B4, #192; the same names as `GET /api/v1/odds/providers`)
each time it builds the record, and an id the table does not know gives null. `winning_odds` and
`season_odds` have no model (their only samples were 404s); they are raw slices.

Since FX-21 (#164) the five models are in `MODELS` (after `LiveEvent`, `sofascore_scraper/schema/models.py:859` at
Expand All @@ -1054,12 +1066,14 @@ One read of an odds slice of an event: a snapshot.
| `event_id` | integer | no | | the request that fetched it | Id of the Event. |
| `key` | string, open set: `odds_all`, `odds_featured` | no | | slice registry (`sofascore_scraper/sports.py`) | Odds slice the record comes from: `odds_all` or `odds_featured`. |
| `provider_id` | integer | yes | | the request that fetched it | SofaScore's id of the bookmaker the odds come from. Which bookmakers SofaScore offers depends on the country it sees the request from; the platform stores no address or location of the machine. |
| `provider_name` | string | yes | | derived from `provider_id` (`sofascore_scraper/sports.py`, `ODDS_PROVIDERS`) | Name of the bookmaker of `provider_id`, as SofaScore writes it (the same names as `GET /api/v1/odds/providers`); null when the platform's built-in list of bookmakers does not know the id. |
| `fetched_at_utc` | string | yes | ISO 8601 UTC | time of the platform's request | When the odds were read. A read is a snapshot: odds change until the event ends, and only a later read shows a later price. |
| `markets` | array of [OddsMarket](#oddsmarket) | no | | `markets`, or the values of `featured` | The markets, in SofaScore's order. |
<!-- /fields:Odds -->

```json example:Odds
{"event_id": 17144927, "key": "odds_all", "provider_id": 1, "fetched_at_utc": "2026-09-21T14:13:20Z",
{"event_id": 17144927, "key": "odds_all", "provider_id": 1, "provider_name": "bet365",
"fetched_at_utc": "2026-09-21T14:13:20Z",
"markets": [{"market_id": 1, "name": "Full time", "group": "1X2", "period": "Full-time",
"choice_group": null, "label": null, "is_live": true, "suspended": false,
"choices": [{"name": "1", "fractional": "11/5", "decimal": 3.2, "initial_fractional": "13/10",
Expand Down Expand Up @@ -1114,6 +1128,7 @@ The flat row of the `odds` export dataset: one outcome of one market of one snap
| `event_id` | integer | no | | the request that fetched it | Id of the Event. |
| `key` | string, open set: `odds_all`, `odds_featured` | no | | slice registry (`sofascore_scraper/sports.py`) | Odds slice the row comes from. |
| `provider_id` | integer | yes | | the request that fetched it | As `Odds.provider_id`. |
| `provider_name` | string | yes | | derived from `provider_id` (`sofascore_scraper/sports.py`, `ODDS_PROVIDERS`) | As `Odds.provider_name`. |
| `fetched_at_utc` | string | yes | ISO 8601 UTC | time of the platform's request | When the snapshot was read. |
| `market_id` | integer | yes | | `marketId` | As `OddsMarket.market_id`. |
| `market_name` | string | yes | | `marketName` | As `OddsMarket.name`. |
Expand All @@ -1133,8 +1148,8 @@ The flat row of the `odds` export dataset: one outcome of one market of one snap
<!-- /fields:OddsLine -->

```json example:OddsLine
{"event_id": 17144927, "key": "odds_all", "provider_id": 1, "fetched_at_utc": "2026-09-21T14:13:20Z",
"market_id": 1, "market_name": "Full time", "market_group": "1X2", "market_period": "Full-time",
{"event_id": 17144927, "key": "odds_all", "provider_id": 1, "provider_name": "bet365",
"fetched_at_utc": "2026-09-21T14:13:20Z", "market_id": 1, "market_name": "Full time", "market_group": "1X2", "market_period": "Full-time",
"choice_group": null, "label": null, "is_live": true, "suspended": false, "choice": "1",
"fractional": "11/5", "decimal": 3.2, "initial_fractional": "13/10", "initial_decimal": 2.3,
"change": 1, "winning": null}
Expand Down
9 changes: 5 additions & 4 deletions docs/design/05-web-ui.md
Original file line number Diff line number Diff line change
Expand Up @@ -1288,9 +1288,10 @@ market that the featured list names twice (`default`, `fullTime`) is shown once.
with their raw view follow under "SofaScore's answer". The end-to-end test had found only the raw viewer
with "readable view coming soon" (F11). **As built (B4, #192; G38; finding M20 of the live validation):**
the heading names the bookmaker ("bet365"), from `GET /api/v1/odds/providers`, read once per page; an id
with no known name, or every id when the list cannot be read, stays numbered ("Bookmaker 5"). `Odds` still
carries only `provider_id`. The sub-key of an odds slice in the raw list and in the Data table shows the
name too. No betting link, campaign field or colour of SofaScore's provider listing is stored or shown.
with no known name, or every id when the list cannot be read, stays numbered ("Bookmaker 5"). Since
2026-11-21 the `Odds` record also carries `provider_name` from the same table; the tab still reads the
list. The sub-key of an odds slice in the raw list and in the Data table shows the name too. No betting
link, campaign field or colour of SofaScore's provider listing is stored or shown.

**As built (FX-26, #174): the score of every sport.** The multi-sport pass of the live validation
(2026-10-08, one finished match of each of 20 sports) found headers that showed less than the record holds
Expand Down Expand Up @@ -2075,7 +2076,7 @@ state at `43ecdfc`. The rows of G33, G35 to G41 and G43 give the state at `216c2
| G35 | A team record route with gender and country (`GET /teams/{id}` or a participant route; `FollowRecord` has neither), for a team follow's header (F5, F26; FX-24 gap 2) | **Built** by B1 (#190): `GET /api/v1/teams/{team_id}` → `TeamRecord` (the stored participant: `sport`, `type`, `name`, `country_code`, `gender`, `national`, … and `followed`), from the catalog, no SofaScore request; 404 `not_found` until a match of the team is stored. `/catalog/suggest` team hits carry `gender` and `national` too. UI: the header of a team follow (6.4), with the search hit as the fallback. | done (B1) |
| G36 | Whether a sport's participants are players (`participants: "individual" \| "team"` on `Sport`, F31; FX-24 gap 3) | **Built** by B1 (#190) as a required boolean `individual` on `Sport` (`SportSpec.individual`: tennis, badminton, table tennis, padel, snooker, darts, MMA; e-sports is a team sport). UI: `isIndividual()` reads the registry; `INDIVIDUAL_SPORTS` is gone (6.3), so R4 holds. | done (B1) |
| G37 | The season's name in the log parameters of `sync_schedule` and `sync_season_outdated` (F8; FX-24 gap 4) | **Built** by B2 (#191): sync log lines carry `league_name`, `season_name`, `season_year` (`resolved_name`, `resolved_year` for an outdated season). UI: Job detail writes them and reads a season list only for an older server's lines (6.9). | done (B2) |
| G38 | An odds provider's name (F11; FX-24 gap 5) | **Built** by B4 (#192): `GET /odds/providers` (`listOddsProviders`: `id`, `name`, `country`, `configured`) from the built-in table `sports.ODDS_PROVIDERS`, no SofaScore request; the Odds tab, the Data table and the Settings row name the bookmaker (6.6, 6.16). `Odds.provider_id` stays the only field of the record; a `provider_name` in schema v1 and a fetch of SofaScore's provider listing are open (`03` section 19). | B4 (#192) |
| G38 | An odds provider's name (F11; FX-24 gap 5) | **Built** by B4 (#192): `GET /odds/providers` (`listOddsProviders`: `id`, `name`, `country`, `configured`) from the built-in table `sports.ODDS_PROVIDERS`, no SofaScore request; the Odds tab, the Data table and the Settings row name the bookmaker (6.6, 6.16). A `provider_name` next to `Odds.provider_id` in schema v1 was added on 2026-11-21; a fetch of SofaScore's provider listing is open (`03` section 20). | B4 (#192) |
| G39 | Export by team or player: a participant field on `ExportFilter` (F13; FX-24 gap 6) | **Built** by B1 (#190): `ExportFilter.team_ids`, `player_ids` (one filter, ANDed with the others; a player's matches are those whose stored line-ups name the player), also `ssc export --team/--player`. UI: the export dialog sends teams and players as such (6.10). | done (B1) |
| G40 | Coverage per follow in `/status` (`summary.follows[]` or `FollowRecord.coverage`), and a way to count a player's matches (F23; FX-24 gap 7) | **Built** by B2 (#191): `/status.summary.follows[]` (`events`, `finished`, `finished_details`, `coverage`, `counted`) for every follow; a player's from the match ids of the player's last match list, kept in `state.db` (`follow_events:player:<id>`); `GET /events?follow=kind:id`. UI: the Follows list, a follow's facts and a player's Matches tab (6.2, 6.4); the `/events` counting stays only for an older server. | done (B2) |
| G41 | Request counters in job progress (requests sent, expected requests per match), for an ETA in requests (F17; FX-24 gap 8) | **Built** by B2 (#191): `progress.requests` and `result.requests` (`sent`, `budget_wait_seconds`, `backoff_seconds`); the league detail phase plans by need, so the server's request-based ETA covers league downloads (no expected-requests field). UI: Job detail (6.9); the recent-pace rule stays. | done (B2) |
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/api/v1/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,8 @@ export interface Odds {
key: string
/** SofaScore's id of the bookmaker the odds come from. Which bookmakers SofaScore offers depends on the country it sees the request from; the platform stores no address or location of the machine. */
provider_id: number | null
/** Name of the bookmaker of `provider_id`, as SofaScore writes it (the same names as `GET /api/v1/odds/providers`); null when the platform's built-in list of bookmakers does not know the id. */
provider_name: string | null
/** When the odds were read. A read is a snapshot: odds change until the event ends, and only a later read shows a later price. */
fetched_at_utc: string | null
/** The markets, in SofaScore's order. */
Expand Down
12 changes: 8 additions & 4 deletions sofascore_scraper/schema/mappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
Status,
Tournament,
)
from sofascore_scraper.sports import SPORTS, PeriodFormat, SetFormat, SportSpec, get_sport, score_family
from sofascore_scraper.sports import SPORTS, PeriodFormat, SetFormat, SportSpec, get_sport, odds_provider, score_family
from sofascore_scraper.status import StatusClass

if TYPE_CHECKING:
Expand Down Expand Up @@ -693,15 +693,19 @@ def odds_from_payload(event_id: int, key: str, payload: Any, *, provider_id: Opt
featured = payload.get("featured") if isinstance(payload.get("featured"), Mapping) else {}
markets = [market for market in (_odds_market(item, str(label)) for label, item in featured.items())
if market is not None]
return Odds(event_id=int(event_id), key=key, provider_id=_int(provider_id), fetched_at_utc=utc_text(fetched_at),
markets=tuple(markets))
provider = _int(provider_id)
# Sağlayıcının adı yerleşik tablodan (B4, sports.ODDS_PROVIDERS); tabloda olmayan kimlik adsız kalır (null).
known = odds_provider(provider) if provider is not None else None
return Odds(event_id=int(event_id), key=key, provider_id=provider, provider_name=known.name if known else None,
fetched_at_utc=utc_text(fetched_at), markets=tuple(markets))


def odds_lines(odds: Odds) -> List[OddsLine]:
"""Bir Odds kaydının düz satırları: pazar ve seçenek başına bir satır, yükün sırasıyla."""
return [
OddsLine(
event_id=odds.event_id, key=odds.key, provider_id=odds.provider_id, fetched_at_utc=odds.fetched_at_utc,
event_id=odds.event_id, key=odds.key, provider_id=odds.provider_id, provider_name=odds.provider_name,
fetched_at_utc=odds.fetched_at_utc,
market_id=market.market_id, market_name=market.name, market_group=market.group,
market_period=market.period, choice_group=market.choice_group, label=market.label,
is_live=market.is_live, suspended=market.suspended, choice=choice.name, fractional=choice.fractional,
Expand Down
Loading
Loading