utils package

Submodules

utils.common_types module

Types used for clearer documentation and type hinting

utils.config module

class utils.config.Config[source]

Bases: object

BASE_URL = 'https://api.sportmonks.com/v3/'

utils.errors module

exception utils.errors.ApiTokenMissingError[source]

Bases: Exception

Raised when API key is not provided.

exception utils.errors.BadRequestsError[source]

Bases: Exception

Raised when a bad request is made

exception utils.errors.BaseUrlMissingError[source]

Bases: Exception

Raised when base url is not provided.

exception utils.errors.ForbiddenError[source]

Bases: Exception

Raised when a forbidden request is made

exception utils.errors.IncompatibleDictionarySchema[source]

Bases: Exception

Raised when a dictionary cannot be unnested.

exception utils.errors.InternalServerError[source]

Bases: Exception

Raised when an internal server error occurs

exception utils.errors.InvalidDateFormat[source]

Bases: Exception

Raised when the date provided is in an incorrect or unsupported format

exception utils.errors.InvalidIncludes[source]

Bases: Exception

Raised when an invalid object is passed as an includes argument

exception utils.errors.InvalidTimezoneError[source]

Bases: Exception

Raised when an unrecognized or invalid timezone is provided

exception utils.errors.MalformedResponseError[source]

Bases: Exception

Raised when the response from the API does not contain ‘data’.

exception utils.errors.ParameterException[source]

Bases: Exception

Raised when an incorrect parameter type is provided

exception utils.errors.ParameterLengthException[source]

Bases: Exception

Raised when the number of parameters requested in a single API call exceeds the allow amount

exception utils.errors.SportMonksAPIError[source]

Bases: Exception

Raised when SportMonks returns an API error.

exception utils.errors.TooManyRequestsError[source]

Bases: Exception

Raised when too many requests are made

exception utils.errors.UnauthorizedError[source]

Bases: Exception

Raised when an unauthorized request is made

utils.helper module

utils.helper.validate_date_format(date_str: str) bool[source]

Validates if the provided date is in the format ‘YYYY-mm-dd’ that SportMonks requires.

Args:

date_str (str): The date string to validate.

Returns:

bool: True if the date is valid and in the correct format, False otherwise.

utils.helper.validate_date_order(date1: str, date2: str) bool[source]

Validates if the first date is not after the second date. A range of more than 100 days is also invalid.

Args:

date1 (str): The first date in ‘YYYY-mm-dd’ format. date2 (str): The second date in ‘YYYY-mm-dd’ format.

Returns:

bool: True if date1 <= date2, False if not, False if the range exeeds 100 days.

utils.helper.validate_positive_id(value: int, name: str) None[source]

Validates that a given value is a positive integer.

Parameters:
  • value – The value to validate.

  • name – The parameter name for error messages.

Module contents

Core endpoints common to all sports within SportMonks included in all subscriptions