Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ __pycache__/
*.py[cod]
*$py.class

# Build tools
# we use `Taskfile`
Makefile

# C extensions
*.so

Expand Down Expand Up @@ -118,6 +114,7 @@ venv.bak/
dmypy.json
.pyre/
.pytype/
ty.toml

# Linting and formatting
.ruff_cache/
Expand Down
5 changes: 3 additions & 2 deletions .mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ exclude = (?x)(
| ^tests/
)
local_partial_types = True
no_implicit_reexport = True
python_version = 3.8
; We target Python 3.9+ for type checking because modern mypy releases
; have dropped support for Python 3.8, even though our library supports 3.8.
python_version = 3.9
strict = True
warn_unreachable = True

Expand Down
11 changes: 7 additions & 4 deletions .ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,30 +36,33 @@ ignore = [
[lint.flake8-bugbear]
extend-immutable-calls = [
"faceit.http.client.env",
"faceit.resources.pagination.MaxPages",
"faceit.resources.pagination.pages",
]

[lint.flake8-import-conventions]
banned-from = [
"asyncio",
"decouple",
"httpx",
"inspect",
"json",
"logging",
"math",
"os",
"re",
"reprlib",
"tenacity",
"typing",
"warnings",
]

[lint.pep8-naming]
classmethod-decorators = ["field_validator"]
classmethod-decorators = ["field_validator", "model_validator"]
ignore-names = ["env", "pages"]

[lint.per-file-ignores]
"__init__.py" = ["F401", "PLC041"]
"faceit.py" = ["S106"]
"types.py" = ["F401", "ICN003", "PLC041", "PYI018"]
"types.py" = ["E302", "F401", "ICN003", "PLC041", "PYI018"]
"scripts/*" = ["T201", "INP001"]
"docs/*" = ["ALL"]
"examples/*" = ["ALL"]
Expand Down
42 changes: 19 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,27 @@ This library makes it easy to access and use data from the FACEIT gaming platfor

## Requirements

- Python 3.8 or higher
- Python 3.8 or higher

## Features

- **High-level, idiomatic API** – Interact with FACEIT as if it were a native Python service.
- **Full type safety** – Compatible with [mypy](https://mypy-lang.org/) and other type checkers.
- **Sync & async support** – Powered by [httpx](https://www.python-httpx.org/).
- **Pydantic models** – All data models inherit from [`pydantic.BaseModel`](https://docs.pydantic.dev/latest/usage/models/).
- **Advanced pagination** – Supports both cursor-based and unix-time-based iterators.
- **Flexible data access** – Choose between raw data and parsed models (e.g., `.raw_players` / `.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.
- **High-level, idiomatic API** – Interact with FACEIT as if it were a native Python service.
- **Full type safety** – Compatible with [mypy](https://mypy-lang.org/) and other type checkers.
- **Sync & async support** – Powered by [httpx](https://www.python-httpx.org/).
- **Pydantic models** – All data models inherit from [`pydantic.BaseModel`](https://docs.pydantic.dev/latest/usage/models/).
- **Advanced pagination** – Supports both cursor-based and unix-time-based iterators.
- **Flexible data access** – Choose between raw data and parsed models (e.g., `.raw_players` / `.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

```console
```
pip install faceit
```

You can also install with the `env` extra to enable loading the API key from environment files (details below):

```console
```
pip install faceit[env]
```

Expand All @@ -51,9 +51,7 @@ By default, the key is read from the `FACEIT_API_KEY` variable.
To use a different variable, pass an instance of `EnvKey` to the constructor:

```py
from faceit import Faceit, EnvKey

data = Faceit.data(EnvKey("SECRET"))
data = faceit.SyncDataResource(faceit.EnvKey("SECRET"))
```

> [!NOTE]
Expand All @@ -62,23 +60,23 @@ data = Faceit.data(EnvKey("SECRET"))
### Minimal Example

```py
from faceit import Faceit, GameID
import faceit

# Initialize the API client.
# If FACEIT_API_KEY is set in your environment, you can omit the argument.
data = Faceit.data() # or Faceit.data("YOUR_API_KEY")
data = faceit.SyncDataResource() # or faceit.SyncDataResource("YOUR_API_KEY")

# Fetch player information by nickname.
player = data.players.get("s1mple")
player = data.players.get("m0NESY")

# Retrieve all CS2 match history for the player.
# Returns an ItemPage collection (fully-featured iterable).
matches = data.players.all_history(player.id, GameID.CS2)
matches = data.players.all_history(player.id, faceit.GameID.CS2)

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

# Example: Find a match by its ID.
match_id = "1-441ff69f-09e3-4c58-b5c4-a0a7424fe8e0"
match_id = "1-964ea204-03cf-4292-99f8-44da63968463"
some_match = matches.find("id", match_id)

if some_match:
Expand All @@ -87,8 +85,6 @@ else:
print(f"No match found with ID {match_id}")
```

### More Examples

See additional usage examples in the [examples/](examples/) directory.

## Motivation
Expand All @@ -109,9 +105,9 @@ The goal is to provide a solution approaching enterprise-level quality, while re

### Planned Improvements

- Support for more endpoints and models
- Webhooks and chat API integration
- Complete documentation and usage guides
- Support for more endpoints and models
- Webhooks and chat API integration
- Complete documentation and usage guides

---

Expand Down
107 changes: 0 additions & 107 deletions Taskfile.yml

This file was deleted.

27 changes: 0 additions & 27 deletions examples/async_championships_custom_client.py

This file was deleted.

10 changes: 0 additions & 10 deletions examples/sync_history.py

This file was deleted.

21 changes: 0 additions & 21 deletions examples/sync_top200_without_cm.py

This file was deleted.

10 changes: 5 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "faceit"
version = "0.1.5"
version = "0.2.0b1"
description = "The Python wrapper for the Faceit API"
readme = "README.md"
requires-python = ">=3.8"
Expand All @@ -20,6 +20,7 @@ classifiers = [
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Typing :: Typed",
]
dependencies = [
Expand All @@ -35,10 +36,6 @@ env = [
"python-decouple>=3.8",
]

[project.urls]
"Bug Tracker" = "https://github.com/zombyacoff/faceit-python/issues"
"Documentation" = "https://docs.faceit.com/docs"

[dependency-groups]
dev = [
"mypy>=1.14",
Expand All @@ -55,6 +52,9 @@ test = [
"pytest-asyncio>=0.21.1",
]

[project.urls]
"Documentation" = "https://docs.faceit.com/docs"

[tool.hatch.build.targets.wheel]
packages = ["src/faceit"]

Expand Down
3 changes: 2 additions & 1 deletion scripts/clean.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import shutil
import sys
from pathlib import Path

PYCACHE = "__pycache__"
Expand Down Expand Up @@ -29,6 +28,8 @@ def find_and_remove_pycache(root: Path = Path(), *, dry_run: bool = False) -> No


if __name__ == "__main__":
import sys

is_dry_run = "--dry-run" in sys.argv
for dir_ in DIRS:
remove_dir(Path(dir_), dry_run=is_dry_run)
Expand Down
Loading