Beispiel #1
0
    async def get_round_group(self, url_id: str, round_id: int,
                              group_id: int) -> Response:
        """
        Get group details of a tournament round.

        Chess.com API: https://www.chess.com/news/view/published-data-api#pubapi-endpoint-tournament-round-group

        Args:
            url_id(str): The url_id of a tournament's web page on chess.com
            round_id(int): The round_id of a tournament
            group_id(int): The group_id of a tournament round

        Returns:
            Response: Response of API request

        Example:

        .. code-block:: python

            from pychesscom import ChessComClient
            client = ChessComClient()
            response = await client.tournament.get_round_group('-33rd-chesscom-quick-knockouts-1401-1600', 1, 1)
            print(response)
        """
        route = Route(f'tournament/{url_id}/{round_id}/{group_id}')
        response = await self._client.request(route)

        return response
Beispiel #2
0
    async def get_clubs(self, iso: str) -> Response:
        """
        Get clubs of a country.

        Chess.com API: https://www.chess.com/news/view/published-data-api#pubapi-endpoint-country-clubs

        Args:
            iso(str): 2-character ISO 3166 code of country

        Returns:
            Response: Response of API request

        Example:

        .. code-block:: python

            from pychesscom import ChessComClient
            client = ChessComClient()
            response = await client.country.get_clubs('IT')
            print(response)
        """
        iso = iso.upper()

        route = Route(f'country/{iso}/clubs')
        response = await self._client.request(route)

        return response
Beispiel #3
0
    async def get_details(self, url_id: str) -> Response:
        """
        Get profile details of a tournament.

        Chess.com API: https://www.chess.com/news/view/published-data-api#pubapi-endpoint-tournament-profile

        Args:
            url_id(str): The url_id of a tournament's web page on chess.com

        Returns:
            Response: Response of API request

        Example:

        .. code-block:: python

            from pychesscom import ChessComClient
            client = ChessComClient()
            response = await client.tournament.get_details('-33rd-chesscom-quick-knockouts-1401-1600')
            print(response)
        """
        route = Route(f'tournament/{url_id}')
        response = await self._client.request(route)

        return response
Beispiel #4
0
    async def get_titled_players(self, title: str) -> Response:
        """
        Get titled players..

        Chess.com API: https://www.chess.com/news/view/published-data-api#pubapi-endpoint-titled

        Args:
            title(str): The title abbreviation

        Returns:
            Response: Response of API request

        Example:

        .. code-block:: python

            from pychesscom import ChessComClient
            client = ChessComClient()
            response = await client.player.get_titled_players('GM')
            print(response)
        """
        route = Route(f'titled/{title}')
        response = await self._client.request(route)

        return response
Beispiel #5
0
    async def get_matches(self, url_id: str) -> Response:
        """
        Get team matches of a club.

        Chess.com API: https://www.chess.com/news/view/published-data-api#pubapi-endpoint-club-matches

        Args:
            url_id(str): The url_id of a club's web page on chess.com

        Returns:
            Response: Response of API request

        Example:

        .. code-block:: python

            from pychesscom import ChessComClient
            client = ChessComClient()
            response = await client.club.get_matches('chess-com-developer-community')
            print(response)
        """
        route = Route(f'club/{url_id}/matches')
        response = await self._client.request(route)

        return response
Beispiel #6
0
    async def get_clubs(self, username: str) -> Response:
        """
        Get clubs of a player.

        Chess.com API: https://www.chess.com/news/view/published-data-api#pubapi-endpoint-player-clubs

        Args:
            username(str): The username of a player on chess.com

        Returns:
            Response: Response of API request

        Example:

        .. code-block:: python

            from pychesscom import ChessComClient
            client = ChessComClient()
            response = await client.player.get_clubs('erik')
            print(response)
        """
        route = Route(f'player/{username}/clubs')
        response = await self._client.request(route)

        return response
Beispiel #7
0
    async def get_games(self, username: str, year: int,
                        month: int) -> Response:
        """
        Get games of a player in a particular month.

        Chess.com API: https://www.chess.com/news/view/published-data-api#pubapi-endpoint-games-archive

        Args:
            username(str): The username of a player on chess.com
            year(int): Year of archive
            month(int): Month of archive

        Returns:
            Response: Response of API request

        Example:

        .. code-block:: python

            from pychesscom import ChessComClient
            client = ChessComClient()
            response = await client.player.get_monthly_archive('erik', 2009, 10)
            print(response)
        """
        if month < 10:
            month = f'0{month}'

        route = Route(f'player/{username}/games/{year}/{month}')
        response = await self._client.request(route)

        return response
Beispiel #8
0
    async def get_current_games_to_move(self, username: str) -> Response:
        """
        Get current games of a player where it is the player's turn to move.

        Chess.com API: https://www.chess.com/news/view/published-data-api#pubapi-endpoint-games-tomove

        Args:
            username(str): The username of a player on chess.com

        Returns:
            Response: Response of API request

        Example:

        .. code-block:: python

            from pychesscom import ChessComClient
            client = ChessComClient()
            response = await client.player.get_current_games_to_move('erik')
            print(response)
        """
        route = Route(f'player/{username}/games/to-move')
        response = await self._client.request(route)

        return response
Beispiel #9
0
    async def get_live_board(self, match_id: int, board_id: int) -> Response:
        """
        Get board details of a live team match.

        Chess.com API: https://www.chess.com/news/view/published-data-api#pubapi-endpoint-match-live-board

        Args:
            match_id(int): The match_id of a live team match
            board_id(int): The board_id of a live team match

        Returns:
            Response: Response of API request

        Example:

        .. code-block:: python

            from pychesscom import ChessComClient
            client = ChessComClient()
            response = await client.match.get_live_board(5833, 1)
            print(response)
        """
        route = Route(f'match/live/{match_id}/{board_id}')
        response = await self._client.request(route)

        return response
Beispiel #10
0
    async def get_details(self, match_id: int) -> Response:
        """
        Get profile details of a team match.

        Chess.com API: https://www.chess.com/news/view/published-data-api#pubapi-endpoint-match-profile

        Args:
            match_id(int): The match_id of a team match

        Returns:
            Response: Response of API request

        Example:

        .. code-block:: python

            from pychesscom import ChessComClient
            client = ChessComClient()
            response = await client.match.get_details(12803)
            print(response)
        """
        route = Route(f'match/{match_id}')
        response = await self._client.request(route)

        return response
Beispiel #11
0
    async def get_streamers(self) -> Response:
        """
        Get streamers.

        Chess.com API: https://www.chess.com/news/view/published-data-api#pubapi-streamers

        Returns:
            Response: Response of API request

        Example:

        .. code-block:: python

            from pychesscom import ChessComClient
            client = ChessComClient()
            response = await client.streamer.get_streamers()
            print(response)
        """
        route = Route('streamers')
        response = await self._client.request(route)

        return response
Beispiel #12
0
    async def get_random(self) -> Response:
        """
        Get random puzzle.

        Chess.com API: https://www.chess.com/news/view/published-data-api#pubapi-random-daily-puzzle

        Returns:
            Response: Response of API request

        Example:

        .. code-block:: python

            from pychesscom import ChessComClient
            client = ChessComClient()
            response = await client.puzzle.get_random()
            print(response)
        """
        route = Route('puzzle/random')
        response = await self._client.request(route)

        return response