import requests
headers = {"User-Agent": "ChessApp/1.0 (+https://github.com/Gelberm)", "Accept": "application/json"}
CHESS_API_BASE_URL = "https://api.chess.com/pub"
def get_player_profile(username: str) -> str:
"""Fetches the profile of a chess.com player by username."""
url = f"{CHESS_API_BASE_URL}/player/{username.strip().lower()}"
response = requests.get(url, headers=headers)
response.raise_for_status()
return response.text
def get_player_stats(username: str) -> str:
"""Fetches the statistics of a chess.com player by username."""
url = f"{CHESS_API_BASE_URL}/player/{username.strip().lower()}/stats"
response = requests.get(url, headers=headers)
response.raise_for_status()
return response.text