Helper functions#
- twitchAPI.helper.TWITCH_API_BASE_URL = 'https://api.twitch.tv/helix/'#
The base url to the Twitch API endpoints
- twitchAPI.helper.TWITCH_AUTH_BASE_URL = 'https://id.twitch.tv/'#
The base url to the twitch authentication endpoints
- twitchAPI.helper.TWITCH_PUB_SUB_URL = 'wss://pubsub-edge.twitch.tv'#
The url to the Twitch PubSub websocket
- twitchAPI.helper.TWITCH_CHAT_URL = 'wss://irc-ws.chat.twitch.tv:443'#
The url to the Twitch Chat websocket
- twitchAPI.helper.build_url(url, params, remove_none=False, split_lists=False, enum_value=True)#
Build a valid url string
- Parameters:
url (
str
) – base URLparams (
dict
) – dictionary of URL parameterremove_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
- Returns:
URL
- Return type:
- twitchAPI.helper.build_scope(scopes)#
Builds a valid scope string from list
- twitchAPI.helper.fields_to_enum(data, fields, _enum, default)#
Itterates a dict or list and tries to replace every dict entry with key in fields with the correct Enum value
- twitchAPI.helper.enum_value_or_none(enum)#
- twitchAPI.helper.datetime_to_str(dt)#
- twitchAPI.helper.remove_none_values(d)#
Removes items where the value is None from the dict. This returns a new dict and does not manipulate the one given.
- Return type:
- enum twitchAPI.helper.ResultType(value)#
Bases:
Enum
An enumeration.
Valid values are as follows:
- RETURN_TYPE = <ResultType.RETURN_TYPE: 0>#
- STATUS_CODE = <ResultType.STATUS_CODE: 1>#
- TEXT = <ResultType.TEXT: 2>#
- async twitchAPI.helper.first(gen)#
Returns the first value of the given AsyncGenerator
- Parameters:
gen (AsyncGenerator) – The generator from which you want the first value
- Return type: