Python Wrapper around Chess.com API
Project description
Python wrapper for Chess.com Public API
Description & Implementation
Python wrapper for Chess.com API which provides public data from the chess.com website. All endpoints provided by Chess.com's API are available in the respectively named methods.
Install the package with: pip install chess.com
https://pypi.org/project/chess.com/
Usage
Please refer to https://chesscom.readthedocs.io/ and https://www.chess.com/news/view/published-data-api for documentation. Below is a simple example of the usage.
All the functions return a ChessDotComResponse
object. The data can be accessed in dictionary format or via attributes:
from chessdotcom import get_player_profile
response = get_player_profile("fabianocaruana")
player_name = response.json['player']['name']
#or
player_name = response.player.name
Optional Headers can also be set. Official Chess.com documentation recommends adding a user-agent
header.
#optional
from chessdotcom import Client
Client.headers = {"User-Agent": "My Python Application. Contact me at email@example.com"}
All the methods from the module will now include the header when making the request to the API.
important: Starting with version 1.5.0 responses from some functions have been altered in order to maintain consistent response format across all functions. All ChessDotComResponse
objects now have 2 attributes: json
and {nested_object}
. The {nested_object}
attribute contains all the data in attributes and other nested objects and is named according to what makes sense based on the returning function's name. The json
attribute still contains the response in dictionary format, but now also has a top level key with the same name as the {nested_object}
attribute. All functions that already return data with a top level key are unchanged.
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
Hashes for chess.com-1.5.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ddbe3c5dd787ebf446ae0fe63e5ee4c436cbfc461434c00f5e9e73484a506796 |
|
MD5 | 10c72541fae3084e3873d7cedcd55c71 |
|
BLAKE2b-256 | e349433f376f60f5528338a96d5e9310a917050f09649ec0d6d45507e05a2ccd |