Leagues API Resource
Relevant source files
The following files were used as context for generating this wiki page:
The Leagues API Resource provides methods to interact with FACEIT league data. It allows you to retrieve details about specific leagues, specific seasons within those leagues, and player-specific information relative to a league season. This resource is part of the faceit.api.data module and supports both synchronous and asynchronous operations.
Sources: src/faceit/api/data/leagues.py:27-33, src/faceit/api/data/init.py:81-82
Resource Architecture
The Leagues resource follows the project's standard resource pattern, inheriting from BaseResource. It uses a split implementation for synchronous (SyncLeagues) and asynchronous (AsyncLeagues) clients. Both implementations are aggregated under the SyncDataResource and AsyncDataResource classes.
Sources: src/faceit/api/data/leagues.py:27-36, src/faceit/api/data/init.py:76-118, src/faceit/api/aggregator.py:65-79
Class Hierarchy
The following diagram illustrates the relationship between the base resource classes and the league-specific implementations.
API Methods and Endpoints
The resource interacts with the /leagues base path. Each method supports two response formats: Raw (returning a dict) and Model (returning a Pydantic model). Currently, model parsing for leagues is represented by ModelNotImplemented, which defaults to returning raw data with a warning.
Sources: src/faceit/api/data/leagues.py:27-31, src/faceit/api/base.py:34-36, src/faceit/types.py:55-57
League Detail Retrieval
You retrieve general information about a league by providing its unique identifier.
- Endpoint:
GET /leagues/{league_id} - Method:
get(matchmaking_id)(or calling the instance directly)
Season Information
You fetch data for a specific season belonging to a league.
- Endpoint:
GET /leagues/{league_id}/seasons/{season_id} - Method:
season(matchmaking_id, season_id)
Player League Stats
You retrieve information about a specific player's participation in a league season.
- Endpoint:
GET /leagues/{league_id}/seasons/{season_id}/players/{player_id} - Method:
player(matchmaking_id, season_id, player_id)
Sources: src/faceit/api/data/leagues.py:42-142
Method Parameters
| Parameter | Type | Validation | Description |
|---|---|---|---|
matchmaking_id | UUID | create_uuid_validator | The unique ID of the league/matchmaking entity. |
season_id | int | Field(ge=1) | The numeric ID of the season (must be greater than or equal to 1). |
player_id | UUID | validate_player_id | The unique ID of the FACEIT player. |
Sources: src/faceit/api/data/leagues.py:20-25, src/faceit/api/data/players.py:50
Data Flow and Validation
When you call a method, the library validates inputs using Pydantic's @validate_call. The request is then passed to the BaseAPIClient, which handles authentication and retries. Upon receiving a response, BaseResource._validate_response checks if the output should be parsed into a model or returned as raw JSON.
Sources: src/faceit/api/data/leagues.py:51-53, src/faceit/api/base.py:126-150, src/faceit/http/client.py:214-225
Integration with Data Resources
The Leagues resource is accessed through the main resource aggregators. If you use SyncDataResource.leagues, you receive parsed models (when implemented). If you use SyncDataResource.raw_leagues, you receive raw dict objects.
# Synchronous example
from faceit import SyncDataResource
data = SyncDataResource(api_key="your-api-key")
league_info = data.leagues.get("league-uuid")
season_info = data.leagues.season("league-uuid", season_id=1)
Sources: src/faceit/api/data/init.py:76-94, src/faceit/api/aggregator.py:91-105
The Leagues API Resource provides a type-safe interface for accessing league-related data on the FACEIT platform. By utilizing the library's shared HTTP client and validation logic, it ensures consistent error handling and data integrity across both synchronous and asynchronous workflows.
Sources: src/faceit/api/data/leagues.py, src/faceit/http/client.py:56-61