
A Rust client library for the Leetify Public CS API
Type-safe, async API client with comprehensive error handling, builder pattern configuration, and an ergonomic extended Player API.
Documentation • Examples • Contributing • Code of Conduct
Key Features: Type-safe IDs • Builder pattern • Extended Player API • Comprehensive error handling • Full async/await support • Automatic JSON deserialization • API key validation • Feature flags for customization
Table of Contents
- Installation
- Feature Flags
- Quick Start
- API Methods
- Extended API
- Type Safety
- 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 (player,rustls-tls)player- Enables the extendedPlayerAPI for a more ergonomic interfacerustls-tls- Usesrustlsas the TLS backend for reqwest (default, recommended)native-tls- Usesnative-tlsas the TLS backend for reqwest
Quick examples:
# Default (includes player API and rustls)
= "0.1.0"
# Minimal setup (without Player API)
= { = "0.1.0", = false, = ["rustls-tls"] }
# With native-tls instead of rustls
= { = "0.1.0", = false, = ["player", "native-tls"] }
# Custom feature combination
= { = "0.1.0", = false, = ["player", "rustls-tls"] }
Note: The
playerfeature enables the extendedPlayerAPI which provides a more ergonomic interface. The coreClientAPI is always available.
Quick Start
use ;
async
Output:
Player: PlayerName
Winrate: 52.34%
For more examples and usage patterns, see the examples.
API Methods
Get Player Profile
use ;
let client = new;
// By Steam64 ID
let profile = client
.get_profile
.await?;
// By Leetify ID (UUID format)
let profile = client
.get_profile
.await?;
// Using automatic conversion (UUID format -> Leetify, numeric strings -> Steam64)
let id: PlayerId = "76561198283431555".into;
let profile = client.get_profile.await?;
Get Match History
use ;
let client = new;
let matches = client
.get_profile_matches
.await?;
for match_details in matches
Get Match Details
use ;
let client = new;
// By game ID
let match_details = client
.get_match_by_game_id
.await?;
// By data source
let match_details = client
.get_match_by_data_source
.await?;
Validate API Key
use Client;
let client = with_api_key;
match client.validate_api_key.await
Using an API Key
API keys provide higher rate limits. You can obtain one at https://leetify.com/app/developer.
use Client;
let client = with_api_key;
Builder Pattern
For advanced configuration:
use Client;
use Duration;
let client = builder
.api_key
.timeout
.base_url
.build?;
Extended API
The extended
PlayerAPI provides a more ergonomic interface by storing the player ID, allowing you to call methods without passing it each time. Enable theplayerfeature to use this API.
For a more ergonomic API, use the Player struct which stores the id
and allows you to call methods without passing it each time:
use ;
let client = new;
let player = client.player;
// Get profile
let profile = player.profile.await?;
// Get matches
let matches = player.matches.await?;
Type Safety
The library provides type-safe wrappers to prevent mixing up different ID types:
PlayerId- Enum for player identification (eitherSteam64orLeetify)Steam64Id- For Steam 64-bit IDs (numeric strings, typically 17 digits)LeetifyId- For Leetify user IDs (UUID format:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)DataSource- Enum for data sources (FACEIT, Matchmaking, etc.)
The PlayerId enum can be created from strings with automatic detection:
- Strings matching UUID format (
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx) are treated as Leetify IDs - Numeric strings (15+ digits) are treated as Steam64 IDs
- You can also explicitly use the enum variants (
PlayerId::Steam64orPlayerId::Leetify) for clarity
Error Handling
The library provides comprehensive error types:
use Error;
match result
Examples
Run any example with:
cargo run --example <name>
Core Examples:
basic_usage- Basic API usage with all methodsplayer_api- Extended Player API usage
Basic Usage Example
use ;
async
Extended Player API Example
use ;
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 an API key: Subject to increased rate limits
- With an API key: Higher rate limits (check Leetify documentation for current limits)
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.