Python Wrapper for Chess.com API
Project description
Python wrapper for Chess.com Public API
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.
Installation
The package requires Python 3.7 or higher.
Install latest version from PyPI: pip install chess.com
Resources
- Documentation: readthedocs.org
- Published-Data API: chess.com
Usage
Retrieving Data
All the functions return a ChessDotComResponse object. The data can be accessed in dictionary format or via attributes.
All functions can be made asynchronous. The package uses aiohttp to send requests to the API.
Synchronous
from chessdotcom import get_player_profile
response = get_player_profile("fabianocaruana")
player_name = response.json['player']['name']
#or
player_name = response.player.name
Asynchronous
from asyncio import gather
from chessdotcom.aio import get_player_profile, Client
#or
from chessdotcom import get_player_profile, Client
Client.aio = True
usernames = ["fabianocaruana", "GMHikaruOnTwitch", "MagnusCarlsen", "GarryKasparov"]
cors = [get_player_profile(name) for name in usernames]
responses = Client.loop.run_until_complete(gather(*cors))
important: The API will begin to rate limit the client if too many requests are made at once.
Configuring the Client object
Headers and and other request parameters can be set through the Client object. Official Chess.com documentation recommends adding a User-Agent header.
#optional
from chessdotcom import Client
Client.config["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 a request to the API.
Contact
- Email me at sarartur.ruk@gmail.com or open a new Issue on Github.
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 chess.com-1.7.8.tar.gz.
File metadata
- Download URL: chess.com-1.7.8.tar.gz
- Upload date:
- Size: 8.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
705d4d5cb4b9e3c3d30bd069a718aed31f61ae66d1802a312614be987b104205
|
|
| MD5 |
f3cd8e6ad7b349e1caabf43df8a73f52
|
|
| BLAKE2b-256 |
57a8113ad57f0a2673554f13aa9982dafb0b4855e0fb10067fb2591b4f32d3db
|
File details
Details for the file chess.com-1.7.8-py3-none-any.whl.
File metadata
- Download URL: chess.com-1.7.8-py3-none-any.whl
- Upload date:
- Size: 10.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0a1354a2a5193e5699b6345926d6aeff22f4d122cd9dff484b45f47314b8b0d9
|
|
| MD5 |
d6de16f8a43ea0eeea6da7b0e4031e76
|
|
| BLAKE2b-256 |
6b45b8697a6a431f1002625202cf5e57a47f9ab7e79b432ab3ac54088c551adc
|