TikTokLive.types package
Submodules
TikTokLive.types.errors module
- exception TikTokLive.types.errors.AlreadyConnected
Bases:
RuntimeError
Error that is raised when attempting to connect to a livestream whilst already connected.
- exception TikTokLive.types.errors.AlreadyConnecting
Bases:
RuntimeError
Error that is raised when attempting to connect to a livestream whilst already attempting to connect.
- exception TikTokLive.types.errors.FailedConnection
Bases:
RuntimeError
Error that is raised when the connection to a livestream fails (generic).
- exception TikTokLive.types.errors.LiveNotFound
Bases:
RuntimeError
Error that is raised when the livestream you are trying to connect to is offline/does-not-exist.
TikTokLive.types.events module
- class TikTokLive.types.events.AbstractEvent(data: dict = {})
Bases:
object
Abstract Event
- property as_dict: dict
Return a copy of the object as a dictionary
- Returns
A copy of the raw payload
- name: str = 'event'
- class TikTokLive.types.events.CommentEvent(user: Optional[TikTokLive.types.objects.User], comment: Optional[str], name: str = 'comment')
Bases:
TikTokLive.types.events.AbstractEvent
Event that fires when someone comments on the livestream
- comment: Optional[str]
The UTF-8 text comment that was sent
- name: str = 'comment'
- user: Optional[TikTokLive.types.objects.User]
The user that sent the comment
- class TikTokLive.types.events.ConnectEvent(name: str = 'connect')
Bases:
TikTokLive.types.events.AbstractEvent
Event that fires when the client connect to a livestream
- name: str = 'connect'
- class TikTokLive.types.events.DisconnectEvent(name: str = 'disconnect')
Bases:
TikTokLive.types.events.AbstractEvent
Event that fires when the client disconnects from a livestream
- name: str = 'disconnect'
- class TikTokLive.types.events.FollowEvent(user: Optional[TikTokLive.types.objects.User], displayType: Optional[str], label: Optional[str], name: str = 'follow')
Bases:
TikTokLive.types.events.AbstractEvent
Event that fires when a user follows the livestream
- displayType: Optional[str]
- label: Optional[str]
- name: str = 'follow'
- user: Optional[TikTokLive.types.objects.User]
The user that followed the streamer
- class TikTokLive.types.events.GiftEvent(user: Optional[TikTokLive.types.objects.User], gift: Optional[TikTokLive.types.objects.Gift], name: str = 'gift')
Bases:
TikTokLive.types.events.AbstractEvent
Event that fires when a gift is received
- gift: Optional[TikTokLive.types.objects.Gift]
Object containing gift data
- name: str = 'gift'
- user: Optional[TikTokLive.types.objects.User]
The user that sent the gift
- class TikTokLive.types.events.JoinEvent(user: Optional[TikTokLive.types.objects.User], displayType: Optional[str], label: Optional[str], name: str = 'join')
Bases:
TikTokLive.types.events.AbstractEvent
Event that fires when a user joins the livestream
- displayType: Optional[str]
- label: Optional[str]
- name: str = 'join'
- user: Optional[TikTokLive.types.objects.User]
The user that joined the stream
- class TikTokLive.types.events.LikeEvent(user: Optional[TikTokLive.types.objects.User], likeCount: Optional[int], totalLikeCount: Optional[int], displayType: Optional[str], label: Optional[str], name: str = 'like')
Bases:
TikTokLive.types.events.AbstractEvent
Event that fires when a user likes the livestream
- displayType: Optional[str]
- label: Optional[str]
- likeCount: Optional[int]
The number of likes they sent (I think?)
- name: str = 'like'
- totalLikeCount: Optional[int]
The total number of likes on the stream
- user: Optional[TikTokLive.types.objects.User]
The user that liked the stream
- class TikTokLive.types.events.LiveEndEvent(name: str = 'live_end')
Bases:
TikTokLive.types.events.AbstractEvent
Event that fires when the livestream ends
- name: str = 'live_end'
- class TikTokLive.types.events.QuestionEvent(questionText: Optional[str], user: Optional[TikTokLive.types.objects.User], name: str = 'question')
Bases:
TikTokLive.types.events.AbstractEvent
Event that fires when someone asks a Q&A question
- name: str = 'question'
- questionText: Optional[str]
The question that was asked
- user: Optional[TikTokLive.types.objects.User]
User who asked the question
Bases:
TikTokLive.types.events.AbstractEvent
Event that fires when a user shares the livestream
The user that shared the stream
- class TikTokLive.types.events.UnknownEvent(name: str = 'unknown')
Bases:
TikTokLive.types.events.AbstractEvent
Event that fires when an event is received that is not handled by other events in the library.
- name: str = 'unknown'
- class TikTokLive.types.events.ViewerCountUpdateEvent(viewerCount: Optional[int], name: str = 'viewer_count_update')
Bases:
TikTokLive.types.events.AbstractEvent
Event that fires when the viewer count for the livestream updates
- name: str = 'viewer_count_update'
- viewerCount: Optional[int]
The number of people viewing the stream currently
TikTokLive.types.objects module
- class TikTokLive.types.objects.AbstractObject
Bases:
object
Abstract Object
- class TikTokLive.types.objects.Avatar(urls: List[str])
Bases:
TikTokLive.types.objects.AbstractObject
The URLs to the avatar of a TikTok User
- property avatar_url
The last (highest quality) avatar URL supplied
- urls: List[str]
- class TikTokLive.types.objects.Badge(type: Optional[str], name: Optional[str])
Bases:
TikTokLive.types.objects.AbstractObject
User badges (e.g moderator)
- name: Optional[str]
The name for the badge
- type: Optional[str]
The type of badge
- class TikTokLive.types.objects.BadgeContainer(badges: typing.List[TikTokLive.types.objects.Badge] = <factory>)
Bases:
TikTokLive.types.objects.AbstractObject
Badge container housing a list of user badges
- badges: List[TikTokLive.types.objects.Badge]
Badges for the user (e.g. moderator)
- class TikTokLive.types.objects.ExtendedGift(id: Optional[int], name: Optional[str], type: Optional[int], describe: Optional[str], diamond_count: Optional[int], duration: Optional[int], event_name: Optional[str], icon: Optional[TikTokLive.types.objects.GiftIcon], image: Optional[TikTokLive.types.objects.GiftIcon], notify: Optional[bool], is_broadcast_gift: Optional[bool], is_displayed_on_panel: Optional[bool], is_effect_befview: Optional[bool], is_random_gift: Optional[bool], is_gray: Optional[bool])
Bases:
TikTokLive.types.objects.AbstractObject
Extended gift data for a gift including a whole lotta extra properties.
- describe: Optional[str]
- diamond_count: Optional[int]
- duration: Optional[int]
- event_name: Optional[str]
- icon: Optional[TikTokLive.types.objects.GiftIcon]
- id: Optional[int]
The ID of the gift
- image: Optional[TikTokLive.types.objects.GiftIcon]
- is_broadcast_gift: Optional[bool]
- is_displayed_on_panel: Optional[bool]
- is_effect_befview: Optional[bool]
- is_gray: Optional[bool]
- is_random_gift: Optional[bool]
- name: Optional[str]
The name of the gift
- notify: Optional[bool]
- type: Optional[int]
The type of gift
- class TikTokLive.types.objects.ExtraAttributes(followRole: typing.Optional[int] = <factory>)
Bases:
TikTokLive.types.objects.AbstractObject
Extra attributes on the User Object (e.g. following status)
- followRole: Optional[int]
- class TikTokLive.types.objects.Gift(from_user_id: Optional[int], to_user_id: Optional[int], gift_id: Optional[int], gift_type: Optional[int], repeat_count: Optional[int], room_id: Optional[int], repeat_end: Optional[int], log_id: Optional[str], msg_id: Optional[int], anchor_id: Optional[int], from_idc: Optional[str], extended_gift: Optional[TikTokLive.types.objects.ExtendedGift])
Bases:
TikTokLive.types.objects.AbstractObject
Gift object containing information about a given gift
- anchor_id: Optional[int]
- extended_gift: Optional[TikTokLive.types.objects.ExtendedGift]
Extended gift including important data like the gift’s image
- from_idc: Optional[str]
- from_user_id: Optional[int]
TikTok ID of the user that sent the gift
- gift_id: Optional[int]
ID of the gift
- gift_type: Optional[int]
The type of gift (type 1 are repeatable, other types are not)
- log_id: Optional[str]
- msg_id: Optional[int]
- repeat_count: Optional[int]
The number of times the gift has repeated
- repeat_end: Optional[int]
Values 1 or 0, dictates whether the gift repetition has ended, ONLY for Type 1
- room_id: Optional[int]
The room ID that the gift was sent to
- to_user_id: Optional[int]
TikTok ID of the user that received the gift (the streamer)
- class TikTokLive.types.objects.GiftIcon(avg_color: Optional[str], uri: Optional[str], is_animated: Optional[bool], url_list: Optional[List[str]])
Bases:
TikTokLive.types.objects.AbstractObject
Icon data for a given gift (such as its image URL)
- avg_color: Optional[str]
- is_animated: Optional[bool]
Whether or not it is an animated icon
- uri: Optional[str]
- url_list: Optional[List[str]]
A list of URLs containing various sizes of the gift’s icon
- class TikTokLive.types.objects.User(userId: typing.Optional[int], uniqueId: typing.Optional[str], nickname: typing.Optional[str], profilePicture: typing.Optional[TikTokLive.types.objects.Avatar], extraAttributes: TikTokLive.types.objects.ExtraAttributes = <factory>, badge: TikTokLive.types.objects.BadgeContainer = BadgeContainer(badges=[]))
Bases:
TikTokLive.types.objects.AbstractObject
User object containing information on a TikTok User
- badge: TikTokLive.types.objects.BadgeContainer = BadgeContainer(badges=[])
Badges for the user containing information such as if they are a stream moderator
- extraAttributes: TikTokLive.types.objects.ExtraAttributes
Extra attributes for the user such as if they are following the streamer
- property is_following: bool
Whether they are following the watched streamer
- property is_friend: bool
Whether they are a friend of the watched streamer
- property is_moderator: bool
Whether they are a moderator for the watched streamer
- nickname: Optional[str]
The user’s nickname (e.g Charlie d’Amelio)
- profilePicture: Optional[TikTokLive.types.objects.Avatar]
An object containing avatar url information
- uniqueId: Optional[str]
The user’s uniqueId (e.g @charlidamelio)
- userId: Optional[int]
The user’s user id