API Reference
This is the documentation for the core sport-index SDK.
Core Elements
sport-index: A unified Python SDK for sports data.
Provides the SportClient as a clean entry point to access a rich, object-oriented
domain model of sports data (competitions, seasons, events, competitors, etc.).
Designed for intuitive navigation of relational sports data without the hassle of
manual API routing.
Note: This library accesses unofficial APIs and may rely on web scraping. Use responsibly and comply with the respective providers' terms of service.
BaseEntity
Bases: ABC, Generic[T]
Base class for all domain entities.
Source code in src/sportindex/domain/base.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | |
source
property
Return the parsed data source for this entity.
__get_pydantic_core_schema__(source_type, handler)
classmethod
Tells Pydantic how to validate this class when used as a field type.
We simply tell it to enforce an isinstance check.
Source code in src/sportindex/domain/base.py
41 42 43 44 45 46 47 48 49 | |
Category
Bases: IdentifiableEntity[_CategoryData]
A category within a sport (e.g., 'France Amateur', 'Formula 1', 'International').
Provides access to its sport, country (if applicable), and competitions.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
int
|
Unique category ID. |
name |
str
|
Category name. |
slug |
str
|
URL-friendly identifier. |
sport |
Sport
|
The sport this category belongs to. |
country |
Country | None
|
The country this category belongs to, or None if international. |
competitions |
EntityCollection[Competition]
|
All competitions under this category. |
Source code in src/sportindex/domain/core.py
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 | |
competitions
cached
property
Fetch all competitions (unique tournaments / unique stages) for this category.
country
cached
property
The country this category belongs to, or None if it's an international category.
id
property
The unique ID of the category.
name
property
The name of the category.
slug
property
The slug of the category (used in URLs).
sport
cached
property
The sport this category belongs to.
Channel
Bases: IdentifiableEntity[_ChannelData]
A TV channel broadcasting sports events.
Provides access to the channel's name, ID, and scheduled events.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
int
|
Unique channel ID. |
name |
str
|
Channel name. |
events |
EventCollection
|
Scheduled events broadcast on this channel. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If initialized with invalid data type. |
EntityNotFoundError
|
If channel does not exist in the provider. |
DomainError
|
If a network or provider error occurs during fetch. |
Source code in src/sportindex/domain/channel.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | |
events
property
Fetch all scheduled events for this channel.
id
property
The unique ID of the channel.
name
property
The name of the channel.
from_id(channel_id, provider)
classmethod
Fetch a channel by its ID.
Source code in src/sportindex/domain/channel.py
62 63 64 65 66 67 68 69 70 71 | |
Competition
Bases: IdentifiableEntity[_UniqueTournamentData | _UniqueStageData]
A competition, e.g., 'Ligue 1', 'Rolland Garros'.
Can represent either a unique tournament or a unique stage. Provides access to its category, sport, and associated seasons.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
int
|
Unique ID, encoded from source ID and type. |
name |
str
|
Competition name. |
slug |
str
|
URL-friendly slug. |
sport |
Sport
|
Parent sport. |
category |
Category
|
Parent category (lazy-loaded). |
seasons |
EntityCollection[Season]
|
Seasons of this competition (lazy-loaded). |
Raises:
| Type | Description |
|---|---|
TypeError
|
If data is not UniqueTournament or UniqueStage. |
Source code in src/sportindex/domain/competition.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | |
category
cached
property
The category this competition belongs to.
id
property
The unique ID of the competition.
name
property
The name of the competition.
seasons
cached
property
Fetch all seasons for this competition.
slug
property
The slug of the competition.
sport
property
The sport this competition belongs to.
from_id(competition_id, provider)
classmethod
Fetch a competition by its ID.
Source code in src/sportindex/domain/competition.py
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | |
search(query, provider)
classmethod
Search for competitions matching the given query (up to the first 20 matches).
Source code in src/sportindex/domain/competition.py
154 155 156 157 158 159 160 161 162 163 164 165 166 167 | |
Competitor
Bases: IdentifiableEntity[_TeamData | _PlayerData], EventAwareMixin
A sports competitor, either an individual or a team.
Provides access to identity, affiliations, and related entities such as players, managers, and venues. Supports fetching fixtures and results, and distinguishing between player and team competitors.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
int
|
Unique competitor ID. |
name |
str
|
Official competitor name. |
slug |
str
|
URL-friendly slug. |
short_name |
str
|
Abbreviated name. |
full_name |
str
|
Full name or concatenation of first and last names for players. |
kind |
Literal['team', 'player']
|
Type of competitor. |
sport |
Sport | None
|
Sport this competitor belongs to. |
country |
Country | None
|
Competitor's country, if applicable. |
category |
Category | None
|
Competitor's category, if applicable. |
manager |
Manager | None
|
Manager, if applicable. |
venue |
Venue | None
|
Home venue, if applicable. |
players |
EntityCollection[Competitor] | None
|
Players of this team, if applicable. |
parent |
Competitor | None
|
Parent competitor for players or sub-teams. |
player_info |
PlayerInfo | None
|
Detailed player information, if applicable. |
Methods:
| Name | Description |
|---|---|
get_fixtures |
Fetch all scheduled events for the competitor. |
get_results |
Fetch all results for the competitor. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If initialized with invalid data type. |
EntityNotFoundError
|
If the competitor does not exist in the provider. |
DomainError
|
If a network or provider error occurs during fetch. |
Source code in src/sportindex/domain/competitor.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 | |
category
cached
property
The category this competitor belongs to, if applicable.
country
cached
property
The country this competitor belongs to, if applicable.
drivers
cached
property
The drivers belonging to this competitor, if this is a motorsport team.
full_name
property
The full name of the competitor.
gender
cached
property
The gender of the competitor, if applicable.
id
property
The unique ID of the competitor.
kind
cached
property
Whether this competitor is a team or a player.
manager
cached
property
The manager of this competitor, if applicable.
name
property
The name of the competitor.
name_code
property
The name code of the competitor, if applicable.
national
property
Whether this competitor is a national team.
parent
cached
property
The parent competitor, if this is a player belonging to a team.
player_info
cached
property
Additional player info, if this is a player.
players
cached
property
The players belonging to this competitor, if this is a team.
short_name
property
The short name of the competitor.
slug
property
The slug of the competitor.
sport
cached
property
The sport this competitor belongs to.
venue
cached
property
The venue this competitor plays at, if applicable.
from_id(competitor_id, provider)
classmethod
Fetch a competitor by its ID.
Source code in src/sportindex/domain/competitor.py
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 | |
get_fixtures(silent=False)
Fetch all fixtures for this competitor.
Source code in src/sportindex/domain/competitor.py
219 220 221 222 223 224 225 226 227 228 229 | |
get_results(silent=False)
Fetch all results for this competitor.
Source code in src/sportindex/domain/competitor.py
231 232 233 234 235 236 237 238 | |
search(query, provider)
classmethod
Search for competitors matching the given query (up to the first 20 matches).
Source code in src/sportindex/domain/competitor.py
304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 | |
Country
Bases: BaseEntity[_CountryData]
A country (e.g., France, England, Spain).
Provides standard identifiers (name, slug, alpha-2, alpha-3) and can be instantiated from a name or alpha code.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
Official country name. |
slug |
str
|
URL-friendly identifier. |
alpha2 |
str | None
|
ISO alpha-2 code. |
alpha3 |
str | None
|
ISO alpha-3 code. |
Methods:
| Name | Description |
|---|---|
from_alpha |
str, provider) -> Optional[Country]: Create from alpha code. |
from_name |
str, provider) -> Optional[Country]: Create from country name. |
Source code in src/sportindex/domain/core.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | |
alpha2
property
The alpha-2 code of the country (e.g. 'FR' for France).
alpha3
property
The alpha-3 code of the country (e.g. 'FRA' for France).
name
property
The name of the country.
slug
property
The slug of the country (used in URLs).
from_alpha(alpha, provider)
classmethod
Create a Country instance from an alpha-2 or alpha-3 code.
Source code in src/sportindex/domain/core.py
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | |
from_name(name, provider)
classmethod
Create a Country instance from a country name.
Source code in src/sportindex/domain/core.py
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | |
EntityCollection
Bases: Generic[E]
A generic collection of entities for any BaseEntity subclass.
Source code in src/sportindex/domain/base.py
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 | |
__and__(other)
Intersection (&): Returns a new collection with entities common to both collections.
Source code in src/sportindex/domain/base.py
209 210 211 212 213 214 215 216 217 218 219 | |
__or__(other)
Union (|): Returns a new collection with unique entities from both collections.
Source code in src/sportindex/domain/base.py
198 199 200 201 202 203 204 205 206 207 | |
__sub__(other)
Difference (-): Returns a new collection with entities in self but not in other.
Source code in src/sportindex/domain/base.py
221 222 223 224 225 226 227 228 229 230 231 232 233 | |
append(entity)
Add a single entity to the collection.
Source code in src/sportindex/domain/base.py
150 151 152 | |
copy()
Return a shallow copy of the collection.
Source code in src/sportindex/domain/base.py
194 195 196 | |
extend(collection)
Add all entities from another collection.
Source code in src/sportindex/domain/base.py
154 155 156 157 | |
get(**kwargs)
Get an entity by arbitrary attributes (e.g. id=1, name="Football").
Source code in src/sportindex/domain/base.py
170 171 172 173 174 175 | |
search(query, by='name')
Smart search that handles case-insensitivity, ignores extra spaces, and allows for partial matches on a specified string attribute. Returns a new collection.
Source code in src/sportindex/domain/base.py
177 178 179 180 181 182 183 184 185 186 187 188 | |
to_list()
Return the entities as a list.
Source code in src/sportindex/domain/base.py
190 191 192 | |
Event
Bases: IdentifiableEntity[_EventData | _StageData]
An event in a sport, such as a football match, tennis match, or motorsport race.
Provides access to event metadata, competitors, scores, lineups, incidents, statistics, and associated entities like venue, referee, season, and competition. Supports both match- and race-specific properties.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
int
|
Unique event ID. |
name |
str
|
Event name. |
slug |
str
|
URL-friendly identifier. |
start |
datetime
|
Start time of the event. |
end |
datetime | None
|
End time, if available. |
kind |
Literal['match', 'race']
|
Type of event. |
round |
Round | None
|
Event round, if applicable. |
sport |
Sport
|
Sport associated with this event. |
season |
Season
|
Season this event belongs to. |
competition |
Competition
|
Competition this event belongs to. |
referee |
Referee | None
|
Referee for the event, if available. |
venue |
Venue | None
|
Venue where the event takes place. |
channels |
EventChannels
|
TV or streaming channels broadcasting the event. |
Match-specific attributes
competitors (MatchCompetitors | None): Competitors in the event. score (Score | None): Score of the match. periods (list[MatchPeriod] | None): Periods of the match. lineups (MatchLineups | None): Player lineups. incidents (list[Incident] | None): Notable incidents. statistics (list[PeriodStats] | None): Event statistics. momentum_graph (list[MomentumPoint] | None): Momentum graph. h2h (EventCollection | None): Head-to-head history.
Race-specific attributes
substages (EventCollection | None): Substages of the race. standings (EntityCollection[Standings] | None): Standings of competitors and teams.
Post-event attributes
winner (Competitor | None): Winner of the event.
Methods:
| Name | Description |
|---|---|
from_id |
int, provider) -> Event: Fetch an event by its unique ID. |
_full_load |
Lazy-load full event details from the provider. |
Source code in src/sportindex/domain/event.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 | |
channels
property
Get the channels broadcasting this event, if match and available.
competition
property
The competition this event belongs to.
competitors
cached
property
The competitors in this event, if match and available.
end
property
The end time of the event, if available.
h2h
cached
property
Head-to-head history for the competitors in this event, if match and available.
id
property
The unique ID of the event.
incidents
property
The incidents for this event, if match and available.
kind
property
The kind of the event (match or race).
lineups
cached
property
The lineups for this event, if match and available.
momentum_graph
property
The momentum graph for this event, if match and available.
name
property
The name of the event.
periods
property
The periods for this event, if match and available.
referee
cached
property
The referee for this event, if available.
round
property
The round of the event, if available.
score
property
The score for this event, if match and available.
season
cached
property
The season this event belongs to.
slug
property
The slug of the event (used in URLs).
sport
property
The sport this event belongs to.
standings
property
The standings for this event, if race and available.
start
property
The start time of the event.
statistics
cached
property
The statistics for this event, if match and available.
substages
cached
property
The substages for this event, if race and available.
venue
cached
property
The venue where this event takes place, if available.
winner
cached
property
The winner of this event, if available.
from_id(event_id, provider)
classmethod
Fetch an event by its ID.
Source code in src/sportindex/domain/event.py
387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 | |
EventAwareMixin
Toolkit for entities that fetch fixtures and results. Provides shared pagination and unified date filtering.
Source code in src/sportindex/domain/base.py
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | |
get_events()
Fetch all events and apply filters.
Source code in src/sportindex/domain/base.py
99 100 101 102 | |
get_fixtures(silent=False)
Override in subclass if fixtures are supported.
Source code in src/sportindex/domain/base.py
91 92 93 | |
get_results(silent=False)
Override in subclass if results are supported.
Source code in src/sportindex/domain/base.py
95 96 97 | |
EventChannels
Bases: BaseEntity[_CountryChannelsResponse]
Channels broadcasting a specific event, organized by country.
Allows querying which channels broadcast the event in a given country.
Attributes:
| Name | Type | Description |
|---|---|---|
channels |
dict[str, list[int]]
|
Mapping from country alpha-2 codes to lists of channel IDs. |
Methods:
| Name | Description |
|---|---|
get_channels |
Return Channel entities broadcasting the event in a specific country. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If initialized with invalid data type. |
EntityNotFoundError
|
If a specified country cannot be found. |
Source code in src/sportindex/domain/channel.py
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | |
channels
property
A dictionary mapping country alpha-2 codes to lists of channel IDs broadcasting this event in that country.
get_channels(*, country=None, country_name=None, country_alpha=None)
Get the channels broadcasting this event in a specific country (by object, name or alpha code).
Source code in src/sportindex/domain/channel.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | |
EventCollection
Bases: EntityCollection[Event]
A specialized collection for handling lists of events with common filtering and sorting needs.
Source code in src/sportindex/domain/event.py
414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 | |
filter_by_competitors(competitor_ids)
Return a new EventCollection filtered by competitor IDs.
Source code in src/sportindex/domain/event.py
434 435 436 437 438 439 440 441 | |
filter_by_date(*, before=None, after=None)
Return a new EventCollection filtered by date.
Source code in src/sportindex/domain/event.py
417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 | |
sort_by_date(ascending=True)
Return a new EventCollection sorted by date.
Source code in src/sportindex/domain/event.py
443 444 445 | |
Gender
Bases: str, Enum
Standardized representation of gender for competitors.
Values
UNSPECIFIED ("X"): Unknown or not specified. MALE ("M"): Male. FEMALE ("F"): Female.
Source code in src/sportindex/domain/gender.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | |
IdentifiableEntity
Bases: BaseEntity[SingleT]
Base class for entities that have a unique identifier.
Source code in src/sportindex/domain/base.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | |
id
abstractmethod
property
The unique ID of the entity, encoded as a globally unique SDK ID.
decode_id(sdk_id)
classmethod
Splits an SDK ID back into its raw ID and type index components.
Source code in src/sportindex/domain/base.py
69 70 71 72 73 74 | |
encode_id(raw_id, type_idx)
classmethod
Creates a globally unique SDK ID by combining the raw ID with a type index.
Source code in src/sportindex/domain/base.py
64 65 66 67 | |
Manager
Bases: IdentifiableEntity[_ManagerData], EventAwareMixin
Represents a sports manager/coach (e.g., football manager, Formula 1 team principal).
This entity handles basic information, associated sport and country, team affiliations, career history, and provides access to fixtures and results. Supports lazy full-loading for properties that require more detailed API responses.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
int
|
Unique identifier of the manager. |
name |
str
|
Full name of the manager. |
slug |
str
|
URL-friendly slug of the manager. |
short_name |
str
|
Shortened name or abbreviation (e.g., "Z. Zidane"). |
sport |
Sport
|
Sport associated with the manager. |
country |
Country | None
|
Country associated with the manager, if available. |
team |
Competitor | None
|
Current primary team, if assigned. |
teams |
EntityCollection[Competitor]
|
All teams associated with the manager. |
performances |
list[ManagerTenure]
|
Career history and performance records of the manager. |
Methods:
| Name | Description |
|---|---|
get_fixtures |
bool = False) -> EventCollection: Returns fixtures for this manager. Currently returns empty, logs a warning. |
get_results |
bool = False) -> EventCollection: Returns results for this manager. |
from_id |
int, provider: SofascoreProvider) -> Manager: Fetch a manager by its unique ID. |
search |
str, provider: SofascoreProvider) -> EntityCollection[Manager]: Search for managers matching a query string (up to 20 results). |
Source code in src/sportindex/domain/manager.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | |
country
cached
property
The country this manager is associated with, if any.
id
property
The unique ID of the manager.
name
property
The full name of the manager.
short_name
property
The short name of the manager, e.g. "Z. Zidane".
slug
property
The slug of the manager (used in URLs).
sport
cached
property
The sport this manager is associated with.
from_id(manager_id, provider)
classmethod
Fetch a manager by its ID.
Source code in src/sportindex/domain/manager.py
158 159 160 161 162 163 164 165 166 167 | |
get_fixtures(silent=False)
Fetch all fixtures for this manager.
Source code in src/sportindex/domain/manager.py
116 117 118 119 120 121 | |
get_results(silent=False)
Fetch all results for this manager.
Source code in src/sportindex/domain/manager.py
123 124 125 | |
search(query, provider)
classmethod
Search for managers matching the given query (up to the first 20 matches).
Source code in src/sportindex/domain/manager.py
169 170 171 172 173 174 175 176 177 178 179 180 181 | |
PlayerInfo
Bases: BaseModel
Comprehensive details about an individual athlete.
Covers identity, physical attributes, career status, technical profile, and financial/contractual data.
Attributes:
| Name | Type | Description |
|---|---|---|
first_name |
str | None
|
Player's first name. |
last_name |
str | None
|
Player's last name. |
weight |
float | None
|
Player weight in kilograms. |
height |
int | None
|
Player height in centimeters. |
date_of_birth |
date | None
|
Birth date. |
place_of_birth |
str | None
|
Birthplace. |
retired |
bool | None
|
Whether the player is retired. |
deceased |
bool | None
|
Whether the player is deceased. |
number |
int | None
|
Shirt or squad number. |
preferred_foot |
str | None
|
Dominant foot (if applicable). |
preferred_hand |
str | None
|
Dominant hand (if applicable). |
positions |
list[str] | None
|
Positions played. |
total_prizes |
Amount | None
|
Career prize earnings. |
salary |
Amount | None
|
Current salary. |
market_value |
Amount | None
|
Market valuation. |
contract_expiry |
date | None
|
Contract end date. |
Methods:
| Name | Description |
|---|---|
_from_parsed_player |
_PlayerData) -> PlayerInfo: Create instance from _PlayerData data. |
_from_parsed_player_team_info |
_PlayerTeamInfoData) -> PlayerInfo: Create instance from _PlayerTeamInfoData data. |
Source code in src/sportindex/domain/competitor.py
324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 | |
Rankings
Bases: BaseEntity[_RankingsResponse]
Represents the rankings of a sport, e.g., FIFA, ATP, or Olympic rankings.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
int | None
|
Unique ID of the ranking type. |
name |
str | None
|
Name of the rankings. |
slug |
str | None
|
URL-friendly slug of the ranking. |
updated_at |
datetime | None
|
Last updated timestamp. |
gender |
Gender | None
|
Gender category of the ranking (M/F/X). |
sport |
Sport | None
|
Sport associated with the ranking. |
category |
Category | None
|
Category, if applicable. |
competition |
Competition | None
|
Competition associated, if applicable. |
entries |
list[RankingsEntry]
|
Ordered list of ranking entries. |
Source code in src/sportindex/domain/leaderboard.py
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 | |
category
cached
property
The category these rankings belong to, if any.
competition
cached
property
The competition these rankings belong to, if any.
entries
cached
property
The entries in the rankings.
gender
cached
property
The gender category of these rankings, e.g. "M", "F" or "X" (mixed/other).
id
property
The unique ID of these rankings.
name
property
The name of the rankings, e.g. "FIFA Rankings", "ATP Rankings", etc.
slug
property
The slug of the rankings, e.g. "fifa", "atp", etc.
sport
cached
property
The sport these rankings belong to.
updated_at
property
The date and time when the rankings were last updated.
RankingsEntry
Bases: BaseModel
A single entry in a Rankings table.
Attributes:
| Name | Type | Description |
|---|---|---|
position |
int
|
Current position. |
entity |
Competitor | Competition
|
Entity being ranked. |
points |
float
|
Points in the ranking. |
previous_position |
int | None
|
Previous ranking position. |
previous_points |
float | None
|
Previous points. |
best_position |
int | None
|
Best historical position. |
Source code in src/sportindex/domain/leaderboard.py
252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 | |
Referee
Bases: IdentifiableEntity[_RefereeData], EventAwareMixin
Represents a sports referee/officiator (e.g., football referee, Formula 1 race director).
Handles basic information, associated sport and country, games officiated, and cards issued. Supports lazy full-loading for properties requiring detailed API responses.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
int
|
Unique identifier of the referee. |
name |
str
|
Full name of the referee. |
slug |
str
|
URL-friendly slug of the referee. |
sport |
Sport
|
Sport associated with the referee. |
country |
Country | None
|
Country associated with the referee, if available. |
games |
int | None
|
Number of games officiated by the referee. |
cards |
Cards | None
|
Counts of yellow, red, and yellow-red cards issued. |
Methods:
| Name | Description |
|---|---|
get_fixtures |
bool = False) -> EventCollection: Returns fixtures for this referee. Currently returns empty, logs a warning. |
get_results |
bool = False) -> EventCollection: Returns results for this referee. |
from_id |
int, provider: SofascoreProvider) -> Referee: Fetch a referee by its unique ID. |
search |
str, provider: SofascoreProvider) -> EntityCollection[Referee]: Search for referees matching a query string (up to 20 results). |
Source code in src/sportindex/domain/referee.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | |
cards
cached
property
Get the number of cards this referee has given.
country
cached
property
The country this referee is associated with, if any.
games
cached
property
Get the number of games this referee has officiated.
id
property
The unique ID of the referee.
name
property
The full name of the referee.
slug
property
The slug of the referee (used in URLs).
sport
cached
property
The sport this referee is associated with.
from_id(referee_id, provider)
classmethod
Fetch a referee by its ID.
Source code in src/sportindex/domain/referee.py
146 147 148 149 150 151 152 153 154 155 | |
get_fixtures(silent=False)
Fetch all fixtures for this referee.
Source code in src/sportindex/domain/referee.py
105 106 107 108 109 110 | |
get_results(silent=False)
Fetch all results for this referee.
Source code in src/sportindex/domain/referee.py
112 113 114 | |
search(query, provider)
classmethod
Search for referees matching the given query (up to the first 20 matches).
Source code in src/sportindex/domain/referee.py
157 158 159 160 161 162 163 164 165 166 167 168 169 | |
Season
Bases: IdentifiableEntity[_SeasonData | _StageData], EventAwareMixin
A season of a competition, e.g., '2023/24', '2024'.
Provides access to parent competition, sport, standings, fixtures, and results.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
int
|
Unique ID, encoded from source ID and type. |
name |
str
|
Season name. |
year |
str
|
Season year. |
start |
Optional[datetime]
|
Start date of the season. |
sport |
Sport
|
Parent sport. |
competition |
Competition
|
Parent competition (lazy-loaded). |
standings |
EntityCollection[Standings]
|
Standings for this season. |
Raises:
| Type | Description |
|---|---|
InsufficientDataError
|
If season data lacks required competition info. |
Source code in src/sportindex/domain/competition.py
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 | |
competition
cached
property
The competition this season belongs to.
current_round
property
The current round of the season, if available.
id
property
The unique ID of the season.
name
property
The name of the season.
rounds
property
The list of rounds in the season, if available.
sport
property
The sport this season belongs to.
standings
property
Fetch all standings for this season (only available for current seasons).
start
property
The start date of the season, if available.
year
property
The year of the season.
get_fixtures(silent=False)
Fetch all fixtures for this season.
Source code in src/sportindex/domain/competition.py
289 290 291 292 293 294 295 296 297 298 299 300 301 | |
get_results(silent=False)
Fetch all results for this season.
Source code in src/sportindex/domain/competition.py
303 304 305 306 307 308 309 310 311 312 313 314 315 | |
get_round_events(round)
Fetch events for a specific round.
Source code in src/sportindex/domain/competition.py
317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 | |
Sport
Bases: IdentifiableEntity[_SportData]
A sport (e.g., football, tennis, motorsport).
Provides access to its categories and official rankings, and can be instantiated from minimal raw data without fetching full details.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
int
|
Unique sport ID. |
name |
str
|
Official sport name. |
slug |
str
|
URL-friendly identifier. |
categories |
EntityCollection[Category]
|
All categories associated with this sport. |
Methods:
| Name | Description |
|---|---|
get_rankings |
Optional[str] = None) -> list[Rankings]: Fetch official rankings for the sport. |
Source code in src/sportindex/domain/core.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | |
categories
cached
property
Fetch all categories for this sport.
id
property
The unique ID of the sport.
name
property
The name of the sport.
slug
property
The slug of the sport (used in URLs).
get_rankings(gender=None)
Fetch all rankings for this sport.
Source code in src/sportindex/domain/core.py
68 69 70 71 72 73 74 75 76 77 78 | |
SportClient
Main client for accessing sports data.
Provides methods to fetch sports, competitions, events, competitors, managers, referees, venues, etc. in a unified, object-oriented way. Caches entities in memory to minimize redundant API calls and improve performance. Cache can be cleared manually if needed.
Usage
client = SportClient() events = client.list_events(competition_id=123) sport = client.get_sport(id=1)
Raises:
| Type | Description |
|---|---|
EntityNotFoundError
|
If a requested entity does not exist. |
ProviderNotFoundError
|
If the data provider is unavailable. |
Source code in src/sportindex/client.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 | |
__init__()
Initialize the SportClient.
Initializes in-memory caches for all entity types.
Source code in src/sportindex/client.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | |
clear_cache(namespace=None)
Clear cached entities to free memory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
namespace
|
Optional[str]
|
Specific namespace to clear. If None, clears all caches. |
None
|
Raises:
| Type | Description |
|---|---|
KeyError
|
If the provided namespace does not exist. |
Source code in src/sportindex/client.py
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | |
get_competition(id)
Fetch a competition by ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
int
|
Competition ID. |
required |
Returns:
| Type | Description |
|---|---|
Optional[Competition]
|
Optional[Competition]: The competition if found, else None. |
Raises:
| Type | Description |
|---|---|
ProviderNotFoundError
|
If the data provider is unavailable. |
Source code in src/sportindex/client.py
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 | |
get_competitor(id)
Fetch a competitor by ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
int
|
Competitor ID. |
required |
Returns:
| Type | Description |
|---|---|
Optional[Competitor]
|
Optional[Competitor]: Competitor if found, else None. |
Raises:
| Type | Description |
|---|---|
ProviderNotFoundError
|
If the provider is unavailable. |
Source code in src/sportindex/client.py
282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 | |
get_event(id)
Fetch an event by ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
int
|
Event ID. |
required |
Returns:
| Type | Description |
|---|---|
Optional[Event]
|
Optional[Event]: Event object if found, else None. |
Raises:
| Type | Description |
|---|---|
ProviderNotFoundError
|
If the provider is unavailable. |
Source code in src/sportindex/client.py
260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 | |
get_manager(id)
Fetch a manager by ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
int
|
Manager ID. |
required |
Returns:
| Type | Description |
|---|---|
Optional[Manager]
|
Optional[Manager]: Manager if found, else None. |
Raises:
| Type | Description |
|---|---|
ProviderNotFoundError
|
If the provider is unavailable. |
Source code in src/sportindex/client.py
316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 | |
get_referee(id)
Fetch a referee by ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
int
|
Referee ID. |
required |
Returns:
| Type | Description |
|---|---|
Optional[Referee]
|
Optional[Referee]: Referee if found, else None. |
Raises:
| Type | Description |
|---|---|
ProviderNotFoundError
|
If the provider is unavailable. |
Source code in src/sportindex/client.py
350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 | |
get_sport(id)
Fetch a sport by its ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
int
|
The sport ID. |
required |
Returns:
| Type | Description |
|---|---|
Sport | None
|
Optional[Sport]: The sport object, or None if not found. |
Source code in src/sportindex/client.py
144 145 146 147 148 149 150 151 152 153 154 | |
get_venue(id)
Fetch a venue by ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
int
|
Venue ID. |
required |
Returns:
| Type | Description |
|---|---|
Optional[Venue]
|
Optional[Venue]: Venue if found, else None. |
Raises:
| Type | Description |
|---|---|
ProviderNotFoundError
|
If the provider is unavailable. |
Source code in src/sportindex/client.py
384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 | |
list_categories(sport_id)
Fetch categories for a given sport.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sport_id
|
int
|
The ID of the sport. |
required |
Returns:
| Type | Description |
|---|---|
EntityCollection[Category]
|
EntityCollection[Category]: Categories under the sport. |
Raises:
| Type | Description |
|---|---|
EntityNotFoundError
|
If the sport does not exist. |
Source code in src/sportindex/client.py
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | |
list_competitions(sport_id, category_id)
Fetch competitions for a sport and category.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sport_id
|
int
|
Sport ID. |
required |
category_id
|
int
|
Category ID. |
required |
Returns:
| Type | Description |
|---|---|
EntityCollection[Competition]
|
EntityCollection[Competition]: Competitions under the category. |
Raises:
| Type | Description |
|---|---|
EntityNotFoundError
|
If sport or category does not exist. |
Source code in src/sportindex/client.py
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 | |
list_seasons(competition_id)
Fetch seasons for a competition.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
competition_id
|
int
|
Competition ID. |
required |
Returns:
| Type | Description |
|---|---|
EntityCollection[Season]
|
EntityCollection[Season]: Seasons under the competition. |
Raises:
| Type | Description |
|---|---|
EntityNotFoundError
|
If the competition does not exist. |
Source code in src/sportindex/client.py
241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 | |
list_sports()
Return all known sports.
Returns:
| Type | Description |
|---|---|
EntityCollection[Sport]
|
EntityCollection[Sport]: All sports available. |
Source code in src/sportindex/client.py
156 157 158 159 160 161 162 163 | |
search_competitors(query)
Search for competitors by name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
Partial or full competitor name. |
required |
Returns:
| Type | Description |
|---|---|
EntityCollection[Competitor]
|
EntityCollection[Competitor]: Matching competitors. |
Source code in src/sportindex/client.py
302 303 304 305 306 307 308 309 310 311 312 | |
search_managers(query)
Search for managers by name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
Partial or full manager name. |
required |
Returns:
| Type | Description |
|---|---|
EntityCollection[Manager]
|
EntityCollection[Manager]: Matching managers. |
Source code in src/sportindex/client.py
336 337 338 339 340 341 342 343 344 345 346 | |
search_referees(query)
Search referees by name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
Partial or full referee name. |
required |
Returns:
| Type | Description |
|---|---|
EntityCollection[Referee]
|
EntityCollection[Referee]: Matching referees. |
Source code in src/sportindex/client.py
370 371 372 373 374 375 376 377 378 379 380 | |
search_sports(query)
Search for sports matching a query.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
Partial or full sport name. |
required |
Returns:
| Type | Description |
|---|---|
EntityCollection[Sport]
|
EntityCollection[Sport]: Sports that match the query. |
Source code in src/sportindex/client.py
165 166 167 168 169 170 171 172 173 174 175 | |
search_venues(query)
Search venues by name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
Partial or full venue name. |
required |
Returns:
| Type | Description |
|---|---|
EntityCollection[Venue]
|
EntityCollection[Venue]: Matching venues. |
Source code in src/sportindex/client.py
404 405 406 407 408 409 410 411 412 413 414 | |
Standings
Bases: BaseEntity[_TeamStandingsData | list[_RacingStandingsEntryData]]
Represents the standings (ranked table) of a competition or sport.
Can handle both team/match standings (e.g., football league tables) and racing/cycling standings (e.g., Formula 1 driver standings).
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str | None
|
Name of the standings, e.g., "Ligue 1 table". |
kind |
str | None
|
Type of standings, e.g., "home", "away", "competitors", "teams". |
updated_at |
datetime | None
|
Last update timestamp. |
sport |
Sport | None
|
Sport associated with these standings. |
entries |
list[StandingsEntry]
|
Ordered list of entries in the standings. |
Source code in src/sportindex/domain/leaderboard.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | |
entries
cached
property
The entries in the standings.
kind
property
The kind of standings, e.g. "home", "away", "total" (match standings) or "competitors", "teams" (racing standings).
name
property
The name of the standings, e.g. "Ligue 1 table", "Formula 1 driver standings", etc.
sport
cached
property
The sport these standings belong to.
updated_at
property
The date and time when the standings were last updated.
StandingsEntry
Bases: BaseModel
A single entry in a Standings table.
Attributes:
| Name | Type | Description |
|---|---|---|
competitor |
Competitor
|
Competitor (team, driver, or rider). |
position |
int
|
Rank/position in the standings. |
points |
float
|
Points accumulated. |
matches, |
(wins, draws, losses, scores_for, scores_against, score_formatted, games_behind, promotion)
|
Match-specific fields. |
victories, |
(podiums, races_with_points, races_started)
|
Racing-specific fields. |
time, |
gap_to_leader
|
Cycling-specific fields. |
Source code in src/sportindex/domain/leaderboard.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | |
Venue
Bases: IdentifiableEntity[_VenueData | _StageData], EventAwareMixin
Represents a sports venue or race stage, e.g., a stadium, tennis court, or race track.
Handles basic information, location, capacity, associated teams, and provides lazy full-loading for detailed API properties.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
int
|
Unique identifier of the venue. |
name |
str
|
Name of the venue. |
city |
str | None
|
City where the venue is located. |
capacity |
int | None
|
Seating or attendance capacity of the venue. |
country |
Country | None
|
Country where the venue is located. |
teams |
EntityCollection[Competitor]
|
Main teams associated with the venue. |
Methods:
| Name | Description |
|---|---|
get_fixtures |
Fetch all fixtures scheduled at this venue. |
get_results |
Fetch all results played at this venue. |
from_id |
int, provider: SofascoreProvider) -> Venue: Fetch a venue by its unique ID. |
search |
str, provider: SofascoreProvider) -> EntityCollection[Venue]: Search for venues by query string (up to 20 results). |
Source code in src/sportindex/domain/venue.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | |
capacity
property
The capacity of the venue, if available.
city
property
The city where the venue is located.
country
cached
property
The country where the venue is located, if available.
id
property
The unique ID of the venue.
name
property
The name of the venue.
from_id(venue_id, provider)
classmethod
Fetch a venue by its ID.
Source code in src/sportindex/domain/venue.py
142 143 144 145 146 147 148 149 150 151 | |
get_fixtures()
Fetch all fixtures for this venue.
Source code in src/sportindex/domain/venue.py
107 108 109 | |
get_results()
Fetch all results for this venue.
Source code in src/sportindex/domain/venue.py
111 112 113 | |
search(query, provider)
classmethod
Search for venues matching the given query (up to the first 20 matches).
Source code in src/sportindex/domain/venue.py
153 154 155 156 157 158 159 160 161 162 163 164 165 | |
Exceptions
Package-level exceptions for sportindex.
Provide a small, stable hierarchy users can import from sportindex.exceptions.
BusinessRuleViolation
Bases: DomainError
Raised when a domain/business rule is violated.
Source code in src/sportindex/exceptions.py
50 51 | |
ConflictError
Bases: DomainError
Raised when a business-logic conflict occurs (e.g. duplicate/unique constraint).
Source code in src/sportindex/exceptions.py
42 43 | |
DomainError
Bases: SportIndexError
Base class for domain/business-logic errors.
Source code in src/sportindex/exceptions.py
34 35 | |
EntityNotFoundError
Bases: DomainError
Raised when a requested domain entity cannot be found or constructed.
Source code in src/sportindex/exceptions.py
38 39 | |
FetchError
Bases: ProviderError
Raised for general fetch failures (non-404/429 HTTP responses or exhausted retries).
Source code in src/sportindex/exceptions.py
30 31 | |
InsufficientDataError
Bases: DomainError
Raised when required data is missing or incomplete for domain operations.
Source code in src/sportindex/exceptions.py
46 47 | |
NetworkError
Bases: ProviderError
Network-level errors (connection, DNS, timeouts).
Source code in src/sportindex/exceptions.py
18 19 | |
ParseError
Bases: SportIndexError
Raised when provider data cannot be parsed or mapped.
Source code in src/sportindex/exceptions.py
10 11 | |
ProviderError
Bases: SportIndexError
Base for errors coming from provider integration and network fetches.
Source code in src/sportindex/exceptions.py
14 15 | |
ProviderNotFoundError
Bases: ProviderError
Raised when a requested remote resource is not found (HTTP 404).
Source code in src/sportindex/exceptions.py
26 27 | |
RateLimitError
Bases: ProviderError
Raised when an upstream service rate-limits requests (e.g. HTTP 429).
Source code in src/sportindex/exceptions.py
22 23 | |
SportIndexError
Bases: Exception
Base class for all errors raised by sportindex.
Source code in src/sportindex/exceptions.py
6 7 | |