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.
The package is avaliable on the Python Package Index.
Install the package with: pip install chess.com
Usage
Refer to package and api docs for information on the usage.
Retrieving Data
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
Configuring the Client object
The project uses requests package to interact with the API. The requests.Session object is available through the Client object. Official Chess.com documentation recommends adding a User-Agent header.
#optional
from chessdotcom import Client
Client.session.headers.update(**{"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.
The Chess.com API uses Cloudflare cookies __cf_bm and __cfuid. By default all cookies are blocked by the Client object. If you would like to enable them simply set Client.cookies = True.
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
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.6.0.tar.gz.
File metadata
- Download URL: chess.com-1.6.0.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d301675b63df7ba4cbaeb0b31a9c080543035c0feabfae3de3a668ad7ddab9b3
|
|
| MD5 |
e7b6203f1a0fe35ff62e11bfc5f582e8
|
|
| BLAKE2b-256 |
4998ec12540b03290647724a150612e3b81276e77f5ad004748f9e7af6ae1555
|
File details
Details for the file chess.com-1.6.0-py3-none-any.whl.
File metadata
- Download URL: chess.com-1.6.0-py3-none-any.whl
- Upload date:
- Size: 9.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8fc5c3d67cae490886756adb18bee5872da401635cfa0650657028517cf52a11
|
|
| MD5 |
fbc5b2186604265768df3a5cc72aee1e
|
|
| BLAKE2b-256 |
25189f4f334723c9e68baf985a9e84f04f34bd931b0c4e225ccd9cf110ae63ed
|