Skip to main content

The Python wrapper for the FACEIT API

Project description

FACEIT Python API Library

Python PyPI License Downloads

FACEIT API

The easiest and most type-safe way to interact with the FACEIT API.


Features

  • High-level, idiomatic API — Interact with FACEIT as if it were a native Python service.
  • Full type safety — Compatible with mypy and other type checkers.
  • Sync & async support — Powered by httpx.
  • Pydantic models — All data models inherit from pydantic.BaseModel.
  • Advanced pagination — Supports both cursor-based and Unix timestamp pagination.
  • Flexible data access — Choose between raw data and parsed models (e.g., .raw_players vs .players).
  • Page collection utilities — Paginated responses in model mode are wrapped in an ItemPage collection with convenient methods, such as .map(), .filter(), .find(), and more.

Installation

Requires Python 3.10+.

pip install faceit

For automatic environment variable loading (see API Key Handling):

pip install faceit[env]

Quickstart

Get started in seconds. The following example demonstrates how to fetch a player's CS2 matches and perform a basic performance analysis using the synchronous API.

[!IMPORTANT] Currently, only the Data Resource is available.
Access to this resource requires a valid API key, which you can obtain via the official FACEIT Developer Portal.

import faceit

# 1. Initialize the Data Resource.
# If `FACEIT_API_KEY` is set in your environment, no arguments are needed.
data = faceit.SyncDataResource()  # or faceit.SyncDataResource("YOUR_API_KEY")

# 2. Fetch player data by nickname.
nickname = input("Enter the player's nickname: ")
player = data.players.get(nickname)

# 3. Get all CS2 matches for the player.
# Returns an `ItemPage` — a type-safe collection with built-in utility methods.
matches = data.players.all_matches_stats(player.id, faceit.GameID.CS2)

print(f"Total CS2 matches for {player.nickname}: {len(matches)}")

# 4. Perform data analysis.
# Filter for matches with a positive K/D ratio (1 or higher).
positive_kd_matches = matches.filter(lambda m: m.kd_ratio >= 1)

total_count = len(matches)
positive_count = len(positive_kd_matches)

kd_rate = (positive_count / total_count * 100) if total_count > 0 else 0

print(f"Matches with positive K/D: {positive_count}")
print(f"{player.nickname}'s positive K/D rate: {kd_rate:.2f}%")

See additional usage examples in the examples/ directory.

API Key Handling

You can provide your API key directly in the constructor or let the library automatically load it from your environment.

  • Automatic: Set the FACEIT_API_KEY environment variable.
    Requires faceit[env] extra dependency or manual python-decouple installation.
  • Manual: Pass the key string directly: SyncDataResource("YOUR_API_KEY").
  • Custom Variable: To use a different environment variable name, pass an instance of FromEnv: SyncDataResource(FromEnv("SECRET"))

Motivation

This project was born out of necessity while building a product that works closely with the FACEIT platform.
Existing solutions did not offer the level of type safety, convenience, or abstraction needed for strong, maintainable code.
The goal is to provide a solution approaching enterprise-level quality, while remaining accessible and useful for a wide range of users.

Project Status & Roadmap

[!WARNING] This library is currently in early development.

  • Many endpoints, models, and features are not yet implemented.
  • Webhooks, chat API, and some advanced features are not available yet.
  • In-code documentation is minimal, and the Sphinx-based documentation site is not yet ready.
  • Expect breaking changes and incomplete coverage.

Contributions and feedback are highly welcome!

Planned Improvements

  • Support for more endpoints and models.
  • Webhooks and chat API integration.
  • Full documentation and usage guides.

This project is licensed under the Apache License 2.0. See the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

faceit-0.3.1.tar.gz (42.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

faceit-0.3.1-py3-none-any.whl (56.7 kB view details)

Uploaded Python 3

File details

Details for the file faceit-0.3.1.tar.gz.

File metadata

  • Download URL: faceit-0.3.1.tar.gz
  • Upload date:
  • Size: 42.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.17 {"installer":{"name":"uv","version":"0.11.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for faceit-0.3.1.tar.gz
Algorithm Hash digest
SHA256 b3fe1c67c49980b7620001a4bbcc95204db78f80b941e695d95faf4ce24ecacb
MD5 d793bbfc22628c6fb6cdd5bbd212ddb9
BLAKE2b-256 e419cca97636f96019a5ca11f42a1de445432ef026ddbde79958e5df36a174ab

See more details on using hashes here.

File details

Details for the file faceit-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: faceit-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 56.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.17 {"installer":{"name":"uv","version":"0.11.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for faceit-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d6d2c998eaa269c596a76fbbca5678536e1e1ba9b8cc623d96ab91f86cc8d1e2
MD5 90d0c18f2958b8cf5af28980c3ae2350
BLAKE2b-256 c7c3d953b396f3cdd35b7b80bb0fccf2337f7f14d801851dfaf58bc1ef8f387d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page