Methods to Facilitate Analysis of Fide Ratings
Project description
python-fide
🌍 Overview
python-fide is a Python package that provides an interface for retrieving detailed information about chess players from the FIDE API. This package allows users to access data such as player details, historical ratings, game statistics, and player opponents.
📦 Installation
You can install python-fide using pip:
pip install python-fide
📚 Usage
Importing the Client
To use the package, import the FidePlayerClient class and instantiate it:
from python_fide import FidePlayerClient
client = FidePlayerClient()
In addition, an asynchronous version of the client also exists and can be imported as follows:
from python_fide import AsyncFidePlayerClient
Retrieve Player Opponents
You can retrieve a list of opponents a player has faced using their FIDE ID:
from python_fide import FidePlayerID
fide_id = FidePlayerID(fide_id=123456)
opponents = client.get_opponents(fide_id)
print(opponents)
Example Output:
[
FidePlayer(fide_id=FidePlayerID(fide_id=123456), name="Opponent Name", country="USA"),
FidePlayer(fide_id=FidePlayerID(fide_id=123456), name="Another Opponent", country="UK")
]
Retrieve Rating Progress Chart
To get the rating progress chart of a player, use:
from python_fide import RatingPeriod
ratings = client.get_rating_progress_chart(fide_id, period=RatingPeriod.TWO_YEARS)
print(ratings)
Example Output:
[
FidePlayerRating(
month=Date(date_iso='2023-06-01', date_format='%Y-%b'),
fide_id=FidePlayerID(fide_id=123456),
standard=FideRating(games=10, rating=2500),
rapid=FideRating(games=5, rating=2450),
blitz=FideRating(games=8, rating=2400)
)
]
Retrieve Game Statistics
To get game statistics for a player, optionally filtering by an opponent:
stats = client.get_game_stats(fide_id)
To get statistics against a specific opponent:
opponent_id = FidePlayerID(fide_id=654321)
stats = client.get_game_stats(fide_id, fide_id_opponent=opponent_id)
print(stats)
Example Output:
FidePlayerGameStats(
fide_id=FidePlayerID(fide_id=123456),
opponent=FidePlayerID(fide_id=654321),
white=FideGamesSet(
standard=FideGames(games_total=30, games_won=15, games_draw=10, games_lost=5),
rapid=FideGames(games_total=20, games_won=10, games_draw=5, games_lost=5),
blitz=FideGames(games_total=25, games_won=12, games_draw=8, games_lost=5)
),
black=FideGamesSet(
standard=FideGames(games_total=28, games_won=14, games_draw=9, games_lost=5),
rapid=FideGames(games_total=18, games_won=9, games_draw=5, games_lost=4),
blitz=FideGames(games_total=22, games_won=11, games_draw=7, games_lost=4)
)
)
🔍 API Reference
| Method | Description | Arguments | Returns |
|---|---|---|---|
get_opponents(fide_player: FidePlayerID) -> List[FidePlayer] |
Retrieves a list of opponents a player has faced. | fide_player (FidePlayerID): The FIDE ID of the player. |
List[FidePlayer]: A list of FIDE players the given player has faced. |
get_rating_progress_chart(fide_id: FidePlayerID, period: Optional[RatingPeriod] = None) -> List[FidePlayerRating] |
Retrieves the rating progress chart for a player. | fide_id (FidePlayerID): The FIDE ID of the player. period (Optional[RatingPeriod]): The period to filter the rating history. |
List[FidePlayerRating]: A list of rating history data. |
get_game_stats(fide_id: FidePlayerID, fide_id_opponent: Optional[FidePlayerID] = None) -> FidePlayerGameStats |
Retrieves game statistics for a player. | fide_id (FidePlayerID): The FIDE ID of the player. fide_id_opponent (Optional[FidePlayerID]): The FIDE ID of an opponent to filter game statistics. |
FidePlayerGameStats: The game statistics for the given player. |
🤝 License
This project is licensed under the MIT License. See the LICENSE file for more details.
📞 Contact
If you have any questions or need support, feel free to reach out by opening an issue on the GitHub repository.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file python_fide-0.4.0.tar.gz.
File metadata
- Download URL: python_fide-0.4.0.tar.gz
- Upload date:
- Size: 11.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.0.1 CPython/3.12.1 Windows/11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4da95c7f31f4ed2b7fa0019856d7e7417506cdaa035306c8a6774503c93e9048
|
|
| MD5 |
a59eb7255fad1da4b6b89657f4f16287
|
|
| BLAKE2b-256 |
fec707a29785979a4293d665a95daff9550190c0c0d2c03186f47a2b975af898
|
File details
Details for the file python_fide-0.4.0-py3-none-any.whl.
File metadata
- Download URL: python_fide-0.4.0-py3-none-any.whl
- Upload date:
- Size: 17.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.0.1 CPython/3.12.1 Windows/11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d82685c5b5219252a08d4c6e48c5759341156a9e86895189c501425b2eb610e5
|
|
| MD5 |
551b6edc710f1827d3cd57e6e90619cf
|
|
| BLAKE2b-256 |
b8e102304690da77da1402e464e824ad60230269bcec2cc3781305f712d26be1
|