understatapi.endpoints.base module¶
Base endpoint
- class understatapi.endpoints.base.BaseEndpoint(primary_attr, session)[source]¶
Bases:
objectBase endpoint for understat API
- Attr base_url
str: The base url to use for requests,
https://understat.com/- Attr leagues
List[str]: The available leagues,
EPL,La_Liga,Bundesliga, optional``Serie_A``,Ligue_1,RFPL
- base_url = 'https://understat.com/'¶
- leagues = ['EPL', 'La_Liga', 'Bundesliga', 'Serie_A', 'Ligue_1', 'RFPL']¶
- parser: BaseParser¶
- _request_url(*args, **kwargs)[source]¶
Use the requests module to send a HTTP request to a url, and check that this request worked.
- Parameters
args (
Any) – Arguments to pass torequests.get()kwargs (
Any) – Keyword arguments to pass torequests.get()
- Return type
Response
- _request_ajax(endpoint, **kwargs)[source]¶
Make an AJAX request to Understat’s internal API endpoints.
Understat loads data dynamically via AJAX calls. This method handles the required headers and returns parsed JSON data.
- Parameters
endpoint (
str) – The AJAX endpoint path (e.g., ‘getLeagueData/EPL/2024’)kwargs (
Any) – Additional keyword arguments to pass torequests.get()
- Return type
Dict[str,Any]- Returns
Parsed JSON response as a dictionary