All Projects → sarartur → chess.com

sarartur / chess.com

Licence: MIT license
Python wrapper for Chess.com Published-Data API

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to chess.com

cv4pve-api-dotnet
Proxmox VE Client API .Net C#
Stars: ✭ 25 (-26.47%)
Mutual labels:  api-client, api-rest
Pyowm
A Python wrapper around the OpenWeatherMap web API
Stars: ✭ 654 (+1823.53%)
Mutual labels:  api-client, python-wrapper
WeConnect-python
Python API for the Volkswagen WeConnect Services
Stars: ✭ 27 (-20.59%)
Mutual labels:  api-client, api-rest
AutoMeter-API
AutoMeter-API是一款针对分布式服务,微服务API功能和性能一体的自动化测试平台,一站式解决应用,服务,API,环境管理,用例,条件,测试场景,计划,测试报告,功能/性能测试兼容支持的一体化工作平台
Stars: ✭ 105 (+208.82%)
Mutual labels:  api-client, api-rest
Js Client
A Open-API derived JS + Node.js API client for Netlify
Stars: ✭ 170 (+400%)
Mutual labels:  api-client, api-rest
Cv4pve Api Java
Proxmox VE Client API JAVA
Stars: ✭ 17 (-50%)
Mutual labels:  api-client, api-rest
Hubspot Php
HubSpot PHP API Client
Stars: ✭ 273 (+702.94%)
Mutual labels:  api-client, api-rest
cv4pve-api-php
Proxmox VE Client API for PHP
Stars: ✭ 45 (+32.35%)
Mutual labels:  api-client, api-rest
Mobx Rest
REST conventions for Mobx
Stars: ✭ 164 (+382.35%)
Mutual labels:  api-client, api-rest
Hoppscotch
👽 Open source API development ecosystem https://hoppscotch.io
Stars: ✭ 34,569 (+101573.53%)
Mutual labels:  api-client, api-rest
Coinapi Sdk
SDKs for CoinAPI
Stars: ✭ 238 (+600%)
Mutual labels:  api-client, api-rest
DummyJSON
DummyJSON provides different types of REST Endpoints filled with JSON data which you can use in developing the frontend with your favorite framework and library without worrying about writing a backend.
Stars: ✭ 213 (+526.47%)
Mutual labels:  api-client, api-rest
AlphaVantage.Net
.Net client library for Alpha Vantage API
Stars: ✭ 65 (+91.18%)
Mutual labels:  api-client
fs-pochta-api
Библиотека для работы с API Почты России
Stars: ✭ 15 (-55.88%)
Mutual labels:  api-client
clickupython
A client for working with the ClickUp API V2
Stars: ✭ 30 (-11.76%)
Mutual labels:  api-client
fb-messenger-bot-api
NodeJS Facebook Messenger API for bots to send messages and setup events to Facebook.
Stars: ✭ 29 (-14.71%)
Mutual labels:  api-client
adyen-python-api-library
Adyen API Library for Python
Stars: ✭ 41 (+20.59%)
Mutual labels:  api-client
Yandex.Music.Api
Client Yandex.Music.Api for Yandex.Music
Stars: ✭ 53 (+55.88%)
Mutual labels:  api-client
CoinGecko
A C++20 library for CoinGecko--a cryptocurrency data service.
Stars: ✭ 69 (+102.94%)
Mutual labels:  api-client
python-sonarqube-api
Python wrapper for the SonarQube (Community Edition and Enterprise Edition) and SonarCloud API.
Stars: ✭ 107 (+214.71%)
Mutual labels:  api-client

Python wrapper for Chess.com Public API

PyPI PyPI - Downloads GitHub Workflow Status (event)

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

Usage

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.

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

import asyncio

from chessdotcom.aio import get_player_profile, Client
#or
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 = asyncio.run(gather_cors(cors))

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 Chess.com documentation recommends adding a User-Agent header.

from chessdotcom import Client

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

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

Contact

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].