Match Data Models
Relevant source files
The following files were used as context for generating this wiki page:
Match Data Models define the structure and validation logic for competitive match information retrieved from the FACEIT API. These models handle general match metadata, team compositions, scoring results, and granular player-specific statistics.
The system utilizes Pydantic for data validation and type safety. It separates high-level match objects from game-specific statistical models, such as those used for Counter-Strike 2 (CS2).
Sources: src/faceit/models/players/match.py:1-20, README.md:20-25
Core Match Structure
The Match model represents a completed or ongoing competitive instance. It aggregates information regarding the game being played, the participating teams, and the final results.
Match Metadata
Each match contains identifiers for the game, region, and competition. It tracks time using TimestampSec for the start and finish times.
| Field | Type | Description |
|---|---|---|
id | str | Unique identifier for the match. |
game_id | GameID | The specific game (e.g., CS2, CSGO). |
region | RegionIdentifier | Geographic region of the match. |
status | str | Current state of the match. |
competition_id | FaceitID | ID of the tournament or hub. |
Sources: src/faceit/models/players/match.py:86-105
Team and Participant Composition
Matches consist of two factions, typically labeled "first" and "second". Each faction contains a list of PlayerSummary objects representing the individual participants.
The diagram shows the hierarchical relationship from a Match to individual participants.
Sources: src/faceit/models/players/match.py:33-83
Match Results and Scoring
The Results model determines the winner and encapsulates the final score. The API provides winner information using "faction1" or "faction2" strings, which the Results model converts to "first" or "second" internally for consistency.
Results Mapping
The library uses a internal map to normalize API winner values:
faction1->firstfaction2->second
Sources: src/faceit/models/players/match.py:23-27, src/faceit/models/players/match.py:73-83
Game-Specific Player Statistics
Player performance within a match is captured through statistics models. While AbstractMatchPlayerStats defines the base interface, game-specific implementations provide granular metrics.
Counter-Strike 2 (CS2) Statistics
The CS2MatchPlayerStats model includes specific metrics relevant to tactical shooters, such as K/D ratio, headshots, and Average Damage per Round (ADR).
| Statistic | Field Name | Type |
|---|---|---|
| Kill/Death Ratio | kd_ratio | float |
| Headshot Percentage | headshots_percentage | float |
| Average Damage | adr | float |
| Triple/Penta Kills | triple_kills, penta_kills | int |
| Map Name | map | str |
Sources: src/faceit/models/players/match.py:121-155
Statistics Data Flow
When fetching match history, the SyncPlayers or AsyncPlayers resource validates the response against the appropriate model based on the GameID provided in the request.
The flowchart illustrates how the library selects the validation model based on the game context.
Sources: src/faceit/api/data/players.py:59-70, src/faceit/api/data/players.py:165-200
Pagination and Collections
Paginated match data is returned inside an ItemPage wrapper. This collection provides utility methods to interact with the underlying match list.
- Filtering: Use
.filter(predicate)to select specific matches (e.g.,matches.filter(lambda m: m.kd_ratio >= 1)). - Metadata: Access
offset,limit, andtime_rangevia the.metadataproperty. - Accessors: Provides
get_first(),get_last(), andget_random()methods for convenience.
Sources: src/faceit/models/item_page.py:53-120, README.md:43-52
Match Result Enumeration
The library defines a MatchResult enum to handle win/loss states in statistical models.
LOSE= 0WIN= 1
Sources: src/faceit/models/players/general.py:35-37
Summary
Match Data Models provide a structured approach to consuming FACEIT match data. By combining general match metadata with specialized game statistics like CS2MatchPlayerStats, the library ensures that developers have type-safe access to both high-level outcomes and granular performance metrics. The use of ItemPage further simplifies the management of large match histories through built-in collection utilities.