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.
Metadata
Release files for python-fide 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| python_fide-0.4.0.tar.gz | 11.0 kB | Without provenance | Details for python_fide-0.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| python_fide-0.4.0-py3-none-any.whl | Python 3 | none | any | Details for python_fide-0.4.0-py3-none-any.whl |
Total release size: 28.8 kB
Release files / python_fide-0.4.0.tar.gz
| Download URL | python_fide-0.4.0.tar.gz |
|---|---|
| Size | 11.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4da95c7f31f4ed2b7fa0019856d7e7417506cdaa035306c8a6774503c93e9048
|
|
BLAKE2b-256 checksum How to use checksums |
fec707a29785979a4293d665a95daff9550190c0c0d2c03186f47a2b975af898
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.0.1 CPython/3.12.1 Windows/11
|
Release files / python_fide-0.4.0-py3-none-any.whl
| Download URL | python_fide-0.4.0-py3-none-any.whl |
|---|---|
| Size | 17.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d82685c5b5219252a08d4c6e48c5759341156a9e86895189c501425b2eb610e5
|
|
BLAKE2b-256 checksum How to use checksums |
b8e102304690da77da1402e464e824ad60230269bcec2cc3781305f712d26be1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.0.1 CPython/3.12.1 Windows/11
|
Security for python-fide 0.4.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.