
A Rust client library for the FACEIT Public API
Type-safe, async API client with comprehensive error handling, builder pattern configuration, and full Data API v4 support.
Documentation • Examples • Contributing • Code of Conduct
Key Features: Builder pattern • Ergonomic APIs • Comprehensive error handling • Full async/await support • Automatic JSON deserialization • API key and access token support • Feature flags for customization • Full Data API v4 coverage
Table of Contents
- Installation
- Feature Flags
- Quick Start
- API Methods
- Ergonomic APIs
- Error Handling
- Examples
- Development
- License
- Contributing
Installation
Add this to your Cargo.toml:
[]
= "0.1.0"
= { = "1", = ["full"] }
Note: This library requires an async runtime. Tokio is recommended, but any async runtime compatible with
reqwestwill work.
Feature Flags
Most features are optional to keep the core library lightweight. Enable only what you need.
Core Features:
default- Enables all default features (ergonomic,rustls-tls)ergonomic- Enables ergonomic API wrappers for Player, Match, Game, Hub, and Championshiprustls-tls- Usesrustlsas the TLS backend for reqwest (default, recommended)native-tls- Usesnative-tlsas the TLS backend for reqwest
Quick examples:
# Default (includes ergonomic APIs and rustls)
= "0.1.0"
# Minimal setup (without ergonomic APIs)
= { = "0.1.0", = false, = ["rustls-tls"] }
# With native-tls instead of rustls
= { = "0.1.0", = false, = ["ergonomic", "native-tls"] }
Quick Start
use HttpClient;
async
Output:
Player: PlayerName
Country: GB
For more examples and usage patterns, see the examples.
API Methods
Player Methods
Get Player by ID
use HttpClient;
let client = new;
let player = client.get_player.await?;
Get Player from Lookup
use HttpClient;
let client = new;
// By nickname
let player = client.get_player_from_lookup.await?;
// By nickname and game
let player = client.get_player_from_lookup.await?;
// By game_player_id
let player = client.get_player_from_lookup.await?;
Get Player Stats
use HttpClient;
let client = new;
let stats = client.get_player_stats.await?;
Get Player Match History
use HttpClient;
let client = new;
let history = client.get_player_history.await?;
Get Player Bans
use HttpClient;
let client = new;
let bans = client.get_player_bans.await?;
Match Methods
Get Match Details
use HttpClient;
let client = new;
let match_details = client.get_match.await?;
Get Match Statistics
use HttpClient;
let client = new;
let stats = client.get_match_stats.await?;
Game Methods
Get All Games
use HttpClient;
let client = new;
let games = client.get_all_games.await?;
Get Game Details
use HttpClient;
let client = new;
let game = client.get_game.await?;
Hub Methods
Get Hub Details
use HttpClient;
let client = new;
let hub = client.get_hub.await?;
// With expanded entities
let hub = client.get_hub.await?;
Get Hub Matches
use HttpClient;
let client = new;
let matches = client.get_hub_matches.await?;
Championship Methods
Get Championships
use HttpClient;
let client = new;
let championships = client.get_championships.await?;
Get Championship Details
use HttpClient;
let client = new;
let championship = client.get_championship.await?;
Search Methods
Search Players
use HttpClient;
let client = new;
let results = client.search_players.await?;
Search Teams
use HttpClient;
let client = new;
let results = client.search_teams.await?;
Search Hubs
use HttpClient;
let client = new;
let results = client.search_hubs.await?;
Ranking Methods
Get Global Ranking
use HttpClient;
let client = new;
let ranking = client.get_global_ranking.await?;
Get Player Ranking
use HttpClient;
let client = new;
let ranking = client.get_player_ranking.await?;
Using Authentication
FACEIT Data API supports two types of authentication:
- API Key - Server-side or client-side API keys obtained from the FACEIT Developer Portal
- Access Token - User access tokens obtained via OAuth2
Both are passed using the Authorization: Bearer {token} header format. Authentication provides higher rate limits.
use HttpClient;
// Using an API key
let client = builder
.api_key
.build?;
// Using an access token
let client = builder
.api_key
.build?;
Builder Pattern
For advanced configuration:
use HttpClient;
use Duration;
let client = builder
.api_key
.timeout
.base_url
.build?;
Ergonomic APIs
The ergonomic APIs provide a convenient way to work with resources without needing to pass IDs to each method call. Enable the
ergonomicfeature to use these APIs.
The ergonomic APIs wrap resources (Player, Match, Game, Hub, Championship) and store the ID, allowing you to call methods without passing it each time.
Player API
use ;
let client = new;
let player = new;
// No need to pass player ID each time
let player_data = player.get.await?;
let stats = player.stats.await?;
let history = player.history.await?;
let bans = player.bans.await?;
let hubs = player.hubs.await?;
let teams = player.teams.await?;
let tournaments = player.tournaments.await?;
Match API
use ;
let client = new;
let match_obj = new;
let match_data = match_obj.get.await?;
let stats = match_obj.stats.await?;
Game API
use ;
let client = new;
let game = new;
let game_data = game.get.await?;
let parent = game.parent.await?;
let matchmakings = game.matchmakings.await?;
Hub API
use ;
let client = new;
let hub = new;
let hub_data = hub.get.await?;
let matches = hub.matches.await?;
let members = hub.members.await?;
let stats = hub.stats.await?;
Championship API
use ;
let client = new;
let championship = new;
let championship_data = championship.get.await?;
let matches = championship.matches.await?;
Direct Instantiation
You can also create ergonomic API instances directly:
use ;
let client = new;
let player = new;
let match_obj = new;
let game = new;
let hub = new;
let championship = new;
Error Handling
The library provides comprehensive error types:
use Error;
match result
FACEIT API error codes:
400- Bad request401- Unauthorized (invalid API key or access token)403- Forbidden404- Not found429- Too many requests500- Server error503- Service temporarily unavailable
Examples
Run any example with:
cargo run --example <name>
Core Examples:
basic_usage- Basic API usage with all methodsergonomic_api- Ergonomic API usage (requiresergonomicfeature)
Basic Usage Example
use HttpClient;
async
Development
Format code:
Formats all Rust code according to the official style guide.
Lint code:
Runs Clippy linter with all targets and features enabled, treating warnings as errors.
Run tests:
Runs all tests with all features enabled to ensure comprehensive coverage.
Run doc tests:
Runs documentation tests to ensure all code examples compile and work correctly.
Editor setup: Recommended extensions are available in
.vscode/extensions.json. See CONTRIBUTING.md for development guidelines and pre-commit hooks.
Rate Limits
- Without authentication: Subject to standard rate limits
- With API key or access token: Higher rate limits (check FACEIT documentation for current limits)
For more information about authentication, see the FACEIT Developer Documentation.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.