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.ChatMessageRepeat
Bases:
TikTokLive.types.errors.ChatMessageSendFailure
Error raised when someone repeats a chat message
- exception TikTokLive.types.errors.ChatMessageSendFailure
Bases:
RuntimeError
Error raised when a TikTok chat message fails to send
- exception TikTokLive.types.errors.FailedConnection
Bases:
RuntimeError
Error that is raised when the connection to a livestream fails (generic).
- exception TikTokLive.types.errors.FailedFetchGifts
Bases:
TikTokLive.types.errors.FailedHTTPRequest
Error raised when fetching gifts encounters an exception
- exception TikTokLive.types.errors.FailedFetchRoomInfo
Bases:
TikTokLive.types.errors.FailedHTTPRequest
Error raised when failing to fetch room info
- exception TikTokLive.types.errors.FailedHTTPRequest
Bases:
RuntimeError
Error raised whenever a request fails to HTTP [Generic]
- exception TikTokLive.types.errors.FailedRoomPolling
Bases:
TikTokLive.types.errors.FailedHTTPRequest
Error raised when room polling encounters an exception
- exception TikTokLive.types.errors.InvalidSessionId
Bases:
RuntimeError
Error raised when a session ID is expired or missing
- 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], diamond_count: Optional[int], describe: Optional[str], 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]
The currency (Diamond) value of the item
- 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(giftId: Optional[int], repeatCount: Optional[int], repeatEnd: Optional[int], giftDetails: Optional[TikTokLive.types.objects.GiftDetails], giftExtra: Optional[TikTokLive.types.objects.GiftExtra], extended_gift: Optional[TikTokLive.types.objects.ExtendedGift])
Bases:
TikTokLive.types.objects.AbstractObject
Gift object containing information about a given gift
- extended_gift: Optional[TikTokLive.types.objects.ExtendedGift]
Extended gift including extra data (not very important as of april 2022)
- giftDetails: Optional[TikTokLive.types.objects.GiftDetails]
Details about the specific Gift sent
- giftExtra: Optional[TikTokLive.types.objects.GiftExtra]
Details like who the gift was sent to (multi-user streams)
- giftId: Optional[int]
The Internal TikTok ID of the gift
- property gift_type: int
Alias for the giftDetails.giftType for backwards compatibility
- Returns
giftType Value
- repeatCount: Optional[int]
Number of times the gift has repeated
- repeatEnd: Optional[int]
Whether or not the repetition is over
- property repeat_count: int
Alias for repeatCount for backwards compatibility
- Returns
repeatCount Value
- property repeat_end: int
Alias for repeatEnd for backwards compatibility
- Returns
repeatEnd Value
- property streakable: bool
Whether a given gift can have a streak
- Returns
True if it is type 1, otherwise False
- property streaking: bool
Whether the streak is over
- Returns
True if currently streaking, False if not
- class TikTokLive.types.objects.GiftDetailImage(giftPictureUrl: Optional[str])
Bases:
TikTokLive.types.objects.AbstractObject
Gift image
- giftPictureUrl: Optional[str]
Icon URL for the Gift
- class TikTokLive.types.objects.GiftDetails(giftImage: Optional[TikTokLive.types.objects.GiftDetailImage], describe: Optional[str], giftType: Optional[int], diamondCount: Optional[int], giftName: Optional[str])
Bases:
TikTokLive.types.objects.AbstractObject
Details about a given gift
- describe: Optional[str]
Describes the gift
- diamondCount: Optional[int]
Diamond value of 1 of the gift
- giftImage: Optional[TikTokLive.types.objects.GiftDetailImage]
Image container for the Gift
- giftName: Optional[str]
Name of the gift
- giftType: Optional[int]
The type of gift. Type 1 are repeatable, any other type are not.
- class TikTokLive.types.objects.GiftExtra(timestamp: Optional[int], receiverUserId: Optional[int])
Bases:
object
Gift object containing information about the gift recipient
- receiverUserId: Optional[int]
The user that received the gift
- timestamp: Optional[int]
The time the gift was sent
- 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