Helper functions

twitchAPI.helper.build_scope(scopes: List[twitchAPI.types.AuthScope]) → str

Builds a valid scope string from list

Parameters:scopes (list[AuthScope]) – list of AuthScope
Return type:str
Returns:the valid auth scope string
twitchAPI.helper.build_url(url: str, params: dict, remove_none=False, split_lists=False, enum_value=True) → str

Build a valid url string

  • url – base URL
  • params – dictionary of URL parameter
  • remove_none (bool) – if set all params that have a None value get removed
    Default: False
  • split_lists (bool) – if set all params that are a list will be split over multiple url parameter with the same name
    Default: False
  • enum_value (bool) – if true, automatically get value string from Enum values
    Default: True


Return type:


twitchAPI.helper.extract_uuid_str_from_url(url: str) → Optional[str]

Extracts a UUID string from a URL

Parameters:url (str) – The URL to parse
Returns:UUID string extracted from given URL or None if no UUID found
Return type:Union[str, None]
twitchAPI.helper.fields_to_enum(data: Union[dict, list], fields: List[str], _enum: Type[enum.Enum], default: Optional[enum.Enum]) → Union[dict, list]

Itterates a dict or list and tries to replace every dict entry with key in fields with the correct Enum value

  • list] data (Union[dict,) – dict or list
  • fields (list[str]) – list of keys to be replaced
  • _enum – Type of Enum to be replaced
  • default – The default value if _enum does not contain the field value
Return type:

dict or list

twitchAPI.helper.get_json(request: aiohttp.web_request.Request) → Union[list, dict, None]

Tries to retrieve the json object from the body

Parameters:request – the request
Returns:the object in the body or None

Returns a random UUID

Return type:UUID
twitchAPI.helper.make_fields_datetime(data: Union[dict, list], fields: List[str])

Itterates over dict or list recursivly to replace string fields with datetime

  • list] data (union[dict,) – dict or list
  • fields (list[str]) – list of keys to be replaced
Return type:

union[dict, list]