Base Objects used by the Library#
- class twitchAPI.object.base.TwitchObject#
Bases:
object
A lot of API calls return a child of this in some way (either directly or via generator). You can always use the
to_dict()
method to turn that object to a dictionary.Example:
blocked_term = await twitch.add_blocked_term('broadcaster_id', 'moderator_id', 'bad_word') print(blocked_term.id)
- to_dict(include_none_values=False)#
build dict based on annotation types
- __init__(**kwargs)#
- class twitchAPI.object.base.IterTwitchObject#
Bases:
TwitchObject
Special type of
TwitchObject
. These usually have some list inside that you may want to directly iterate over in your API usage but that also contain other useful data outside of that List.Example:
lb = await twitch.get_bits_leaderboard() print(lb.total) for e in lb: print(f'#{e.rank:02d} - {e.user_name}: {e.score}')
- __init__(**kwargs)#
- class twitchAPI.object.base.AsyncIterTwitchObject#
Bases:
TwitchObject
,Generic
[T
]A few API calls will have useful data outside the list the pagination iterates over. For those cases, this object exist.
Example:
schedule = await twitch.get_channel_stream_schedule('user_id') print(schedule.broadcaster_name) async for segment in schedule: print(segment.title)
- __init__(_data, **kwargs)#