betbot.api package

Submodules

betbot.api.ApiConnection module

class betbot.api.ApiConnection.ApiConnection(username: str, password: str, url: str)

Bases: object

Class that handles API calls to the bundesliga-tippspiel instance

__init__(username: str, password: str, url: str)

Intitializes the API connection :param username: The username on bundesliga-tippspiel :param password: The password for that user :param url: The base url to the bundesliga-tippspiel instance

property auth_headers: Dict[str, str]
Returns

Authorization headers for API calls

authorized() bool

Checks if the stored API key is valid :return: True if valid, False if not (for example because it expired)

execute_api_call(endpoint: str, method: str, authorization_required: bool = False, json_data: Optional[Dict[str, Any]] = None) Dict[str, Any]

Executes an API call :param endpoint: The API endpoint :param method: The request method :param authorization_required: Whether authoirzation is required :param json_data: The JSON data to send :return: The response JSON

get_active_leagues() List[Tuple[str, int]]
Returns

A list of tuples of leagues and seasons of active leagues

get_current_matchday_matches(league: str, season: int) List[betbot.api.Match.Match]

Retrieves a list of matches for the current matchday :param league: The league to retrieve matches for :param season: The season to retrieve matches for :return: The list of matches

get_league_table(season: str, league: int) List[str]

Retrieves the current league table order :param season: The league for which to retrieve the league table :param league: The season for which to retrieve the league table :return: The team abbreviations in order of their league rankings

login() bool

Retrieves an API Key using a username and password if no key has been retrieved yet or if the existing key has expired :return: True if the login was successfulle

logout()

Logs out the bot by deleting the API key :return: None

place_bets(bets: List[betbot.api.Bet.Bet])

Places a list of bets :param bets: The bets to place :return: None

betbot.api.Bet module

class betbot.api.Bet.Bet(match: betbot.api.Match.Match, home_score: int, away_score: int)

Bases: object

Class that encapsulates Bet information

__init__(match: betbot.api.Match.Match, home_score: int, away_score: int)

Initializes the Bet :param match: The associated match :param home_score: The score bet on the home team :param away_score: The score bet on the away team

to_dict() Dict[str, Union[int, str]]
Returns

A dictionary that can be used to place the bet using the API

betbot.api.Match module

class betbot.api.Match.Match(league: str, season: str, matchday: int, home_team: str, away_team: str, finished: bool)

Bases: object

Class that encapsulates information about a Match

__init__(league: str, season: str, matchday: int, home_team: str, away_team: str, finished: bool)

Initializes the Match :param _id: The ID of the match :param matchday: The matchday of the match :param home_team: The name of the home team :param away_team: The name of the away team :param finished: Whether the match is already finished or not

classmethod from_json(json_data: Dict[str, Any])

Generates a Match object from JSON data :param json_data: The JSON data :return: The generated Match

Module contents