Skip to main content

Python Wrapper for API

Project description

Python wrapper for Public API

PyPI PyPI - Downloads GitHub Workflow Status (event)

Python wrapper for API which provides public data from the website. All endpoints provided by's API are available in the respectively named methods.


The package requires Python 3.7 or higher.

Install latest version from PyPI: pip install



Retrieving Data

All the functions return a ChessDotComResponse object. The data can be accessed in dictionary format or via attributes.

The package uses aiohttp for asynchronous requests and requests for synchronous requests to interact with the API.


from chessdotcom import get_player_profile

response = get_player_profile("fabianocaruana")

player_name = response.json['player']['name']
player_name =


import asyncio

from chessdotcom.aio import get_player_profile, Client
from chessdotcom import Client
Client.aio = True

usernames = ["fabianocaruana", "GMHikaruOnTwitch", "MagnusCarlsen", "GarryKasparov"]

cors = [get_player_profile(name) for name in usernames]

async def gather_cors(cors):
    return await asyncio.gather(*cors)

responses =

Managing Rate Limit

The package offers several ways to deal with the rate limit. Every function accepts a tts parameter which controls the number of seconds the Client will wait before making the request. This is useful if running a lot of coroutines at once.

cors = [get_player_profile(name, tts = i / 10) for i, name in enumerate(usernames)]

The second method is to adjust the rate_limit_handler attribute of the Client object.

Client.rate_limit_handler.tries = 2
Client.rate_limit_handler.tts = 4

If the initial request gets rate limited the client will automatically retry the request 2 more times with an interval of 4 seconds.

Configuring Headers

Headers and and other request parameters can be set through the Client object. Official documentation recommends adding a User-Agent header.

from chessdotcom import Client

Client.request_config["headers"]["User-Agent"] = (
    "My Python Application. "
    "Contact me at"

All the methods from the package will now include the header when making a request to the API.


Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution (9.5 kB view hashes)

Uploaded source

Built Distribution (11.4 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page