Teams API Resource
Relevant source files
The following files were used as context for generating this wiki page:The Teams API Resource provides interfaces to interact with FACEIT team data. It allows you to retrieve team profiles, statistics for specific games, and tournament participation history. This resource is part of the Data Resource Aggregator and supports both synchronous and asynchronous execution modes.
The resource implementation ensures type safety through Pydantic models and supports dual response formats: raw dictionaries or parsed model objects.
Sources: src/faceit/api/data/teams.py:1-10, src/faceit/api/data/init.py:80-81
Architecture Overview
The Teams resource follows the standard project pattern of separating logic into a base class with specialized synchronous and asynchronous implementations.
Class Hierarchy
The BaseTeams class defines the resource path as teams. SyncTeams and AsyncTeams inherit from this base and utilize SyncClient or AsyncClient respectively to perform HTTP operations.
Aggregation Architecture
The SyncDataResource and AsyncDataResource classes aggregate the Teams resource. Users access it via the .teams property for model-parsed data or .raw_teams for raw dictionary responses.
Resource Methods
The Teams resource exposes four primary methods for data retrieval. All methods validate input parameters using pydantic.validate_call.
Retrieval Methods Summary
| Method | Endpoint Path | Description |
|---|---|---|
get | /teams/{team_id} | Retrieves the main profile details for a specific team. |
stats | /teams/{team_id}/stats/{game} | Fetches performance statistics for a team in a specific game. |
tournaments | /teams/{team_id}/tournaments | Returns a paginated list of tournaments the team has joined. |
all_tournaments | /teams/{team_id}/tournaments | Automatically iterates through all pages to collect tournament data. |
Sources: src/faceit/api/data/teams.py:43-118
Team Details and Statistics
The get method serves as the primary entry point for team information. You can call the instance directly (e.g., resource(team_id)) because __call__ is aliased to get. The stats method requires a GameID constant to filter performance data.
Pagination and Collections
Tournament endpoints utilize the internal pagination system to handle large datasets.
Offset-Based Pagination
The tournaments method accepts offset and limit parameters. It returns an ItemPage object when in model mode, providing utility methods like .filter() and .map().
- Default Limit: 20 items.
- Max Limit: 100 items.
- Minimum Offset: 0.
Sources: src/faceit/api/data/teams.py:75-98, src/faceit/models/item_page.py:79-85
Automated Iteration
The all_tournaments method uses SyncPageIterator or AsyncPageIterator to exhaust paginated results. It defaults to a maximum of 30 pages to prevent excessive API consumption.
Data Models
The Teams resource interacts with several data structures. While some team-specific models are currently marked as ModelPlaceholder or ModelNotImplemented in the source, the GeneralTeam model defines the expected structure for team data retrieved via other resources (like player team lists).
GeneralTeam Model Structure
| Field | Type | Description |
|---|---|---|
id | FaceitID | Unique identifier for the team. |
nickname | str | Short display name. |
name | str | Full team name. |
game | GameID | The primary game associated with the team. |
leader_id | FaceitID | The player ID of the team leader. |
faceit_url | Url | Link to the team profile on FACEIT. |
Sources: src/faceit/models/players/general.py:109-120
Implementation Details
The resource methods use _validate_response from the BaseResource class. This method checks if the resource was initialized in raw mode. If not, it attempts to parse the response using Pydantic. If strict_validation is enabled and parsing fails, the library raises a ValidationError.
Sources: src/faceit/api/base.py:136-159
# Usage Example derived from Resource methods
# Sync get request
team = data.teams.get("team-uuid-here")
# Paginated tournament retrieval
tournaments = data.teams.tournaments("team-uuid-here", limit=50)
Sources: src/faceit/api/data/teams.py:55-58, src/faceit/api/data/teams.py:88-91
The Teams API Resource ensures that interactions with team-related endpoints are consistent with the library's overall architecture, providing a type-safe and efficient way to access FACEIT's competitive team data.