tikdataapi 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. tikdataapi/__init__.py +8 -0
  2. tikdataapi/api/__init__.py +1 -0
  3. tikdataapi/api/account/__init__.py +1 -0
  4. tikdataapi/api/account/get_me.py +144 -0
  5. tikdataapi/api/billing/__init__.py +1 -0
  6. tikdataapi/api/billing/create_checkout.py +215 -0
  7. tikdataapi/api/billing/list_packs.py +144 -0
  8. tikdataapi/api/hashtags/__init__.py +1 -0
  9. tikdataapi/api/hashtags/get_hashtag.py +220 -0
  10. tikdataapi/api/hashtags/get_hashtag_videos.py +250 -0
  11. tikdataapi/api/music/__init__.py +1 -0
  12. tikdataapi/api/music/get_music.py +234 -0
  13. tikdataapi/api/music/get_music_videos.py +254 -0
  14. tikdataapi/api/playlists/__init__.py +1 -0
  15. tikdataapi/api/playlists/get_playlist_videos.py +258 -0
  16. tikdataapi/api/search/__init__.py +1 -0
  17. tikdataapi/api/search/search_hashtags.py +261 -0
  18. tikdataapi/api/search/search_live.py +258 -0
  19. tikdataapi/api/search/search_music.py +260 -0
  20. tikdataapi/api/search/search_users.py +276 -0
  21. tikdataapi/api/search/search_videos.py +260 -0
  22. tikdataapi/api/users/__init__.py +1 -0
  23. tikdataapi/api/users/get_user.py +222 -0
  24. tikdataapi/api/users/get_user_followers.py +266 -0
  25. tikdataapi/api/users/get_user_following.py +266 -0
  26. tikdataapi/api/users/get_user_live.py +236 -0
  27. tikdataapi/api/users/get_user_playlists.py +276 -0
  28. tikdataapi/api/users/get_user_reposts.py +266 -0
  29. tikdataapi/api/users/get_user_videos.py +254 -0
  30. tikdataapi/api/users/get_users.py +247 -0
  31. tikdataapi/api/users/get_users_videos.py +259 -0
  32. tikdataapi/api/videos/__init__.py +1 -0
  33. tikdataapi/api/videos/get_comment_replies.py +260 -0
  34. tikdataapi/api/videos/get_comments.py +258 -0
  35. tikdataapi/api/videos/get_related_videos.py +247 -0
  36. tikdataapi/api/videos/get_trending_videos.py +238 -0
  37. tikdataapi/api/videos/get_video.py +218 -0
  38. tikdataapi/api/videos/get_video_transcript.py +247 -0
  39. tikdataapi/api/videos/get_videos.py +235 -0
  40. tikdataapi/client.py +268 -0
  41. tikdataapi/errors.py +16 -0
  42. tikdataapi/models/__init__.py +117 -0
  43. tikdataapi/models/batch_error.py +104 -0
  44. tikdataapi/models/batch_error_code.py +15 -0
  45. tikdataapi/models/batch_meta.py +127 -0
  46. tikdataapi/models/batch_meta_cache.py +11 -0
  47. tikdataapi/models/comment.py +163 -0
  48. tikdataapi/models/comment_author.py +97 -0
  49. tikdataapi/models/comment_page.py +130 -0
  50. tikdataapi/models/create_checkout_body.py +63 -0
  51. tikdataapi/models/create_checkout_body_pack.py +11 -0
  52. tikdataapi/models/create_checkout_response_200.py +97 -0
  53. tikdataapi/models/error.py +78 -0
  54. tikdataapi/models/error_body.py +107 -0
  55. tikdataapi/models/error_body_code.py +22 -0
  56. tikdataapi/models/get_me_response_200.py +88 -0
  57. tikdataapi/models/get_users_body.py +61 -0
  58. tikdataapi/models/get_users_videos_body.py +72 -0
  59. tikdataapi/models/get_videos_body.py +61 -0
  60. tikdataapi/models/hashtag.py +124 -0
  61. tikdataapi/models/hashtag_response.py +122 -0
  62. tikdataapi/models/hashtag_summary.py +98 -0
  63. tikdataapi/models/hashtag_summary_page.py +130 -0
  64. tikdataapi/models/list_packs_response_200.py +103 -0
  65. tikdataapi/models/list_packs_response_200_data_item.py +88 -0
  66. tikdataapi/models/list_packs_response_200_rate_limits_item.py +70 -0
  67. tikdataapi/models/live_room.py +142 -0
  68. tikdataapi/models/live_room_author.py +90 -0
  69. tikdataapi/models/live_room_page.py +130 -0
  70. tikdataapi/models/live_room_response.py +124 -0
  71. tikdataapi/models/meta.py +108 -0
  72. tikdataapi/models/meta_cache.py +10 -0
  73. tikdataapi/models/music.py +107 -0
  74. tikdataapi/models/music_detail.py +172 -0
  75. tikdataapi/models/music_response.py +124 -0
  76. tikdataapi/models/music_summary.py +137 -0
  77. tikdataapi/models/music_summary_page.py +130 -0
  78. tikdataapi/models/not_found_reason.py +12 -0
  79. tikdataapi/models/playlist.py +114 -0
  80. tikdataapi/models/playlist_author.py +86 -0
  81. tikdataapi/models/playlist_page.py +130 -0
  82. tikdataapi/models/problem.py +131 -0
  83. tikdataapi/models/transcript.py +128 -0
  84. tikdataapi/models/transcript_response.py +124 -0
  85. tikdataapi/models/transcript_segment.py +77 -0
  86. tikdataapi/models/user.py +207 -0
  87. tikdataapi/models/user_batch.py +145 -0
  88. tikdataapi/models/user_page.py +130 -0
  89. tikdataapi/models/user_response.py +126 -0
  90. tikdataapi/models/user_summary.py +152 -0
  91. tikdataapi/models/user_summary_page.py +130 -0
  92. tikdataapi/models/user_videos.py +96 -0
  93. tikdataapi/models/user_videos_batch.py +145 -0
  94. tikdataapi/models/video.py +297 -0
  95. tikdataapi/models/video_batch.py +145 -0
  96. tikdataapi/models/video_page.py +130 -0
  97. tikdataapi/models/video_response.py +122 -0
  98. tikdataapi/models/video_type.py +9 -0
  99. tikdataapi/py.typed +1 -0
  100. tikdataapi/types.py +54 -0
  101. tikdataapi-0.1.0.dist-info/METADATA +148 -0
  102. tikdataapi-0.1.0.dist-info/RECORD +103 -0
  103. tikdataapi-0.1.0.dist-info/WHEEL +4 -0
@@ -0,0 +1,152 @@
1
+ from __future__ import annotations
2
+
3
+ import datetime
4
+ from collections.abc import Mapping
5
+ from typing import Any, TypeVar
6
+
7
+ from attrs import define as _attrs_define
8
+ from attrs import field as _attrs_field
9
+
10
+ from ..types import UNSET, Unset
11
+
12
+ T = TypeVar("T", bound="UserSummary")
13
+
14
+
15
+ @_attrs_define
16
+ class UserSummary:
17
+ """An account in the results of an account search: a short profile, what the account search of TikTok
18
+ sends. It is not a `User`: it has no `following`, `videos`, `private`, `bio_link` or `language`. For
19
+ the full profile with exact counts, read `/v1/users/{user}`, or `/v1/users/batch` for up to 100
20
+ accounts in one call.
21
+
22
+ Attributes:
23
+ id (str): The numeric account id. It stays the same when the username changes. Example: 107955.
24
+ username (str): The name after the @ in the address of the profile. Example: tiktok.
25
+ sec_uid (str): The second, long account id of TikTok. It stays the same when the username changes. Every
26
+ endpoint
27
+ that takes a username also takes this id, and then needs no lookup of the profile.
28
+ Example: MS4wLjABAAAAv7iSuuXDJGDvJkmH_vz1qkDZYo1apxgzaxdBSeIuPiM.
29
+ nickname (str): The display name. Example: TikTok.
30
+ bio (str): Example: Your next discovery is waiting on TikTok..
31
+ verified (bool): `true` when TikTok marks the account as verified. This includes its "Popular creator" mark and
32
+ the
33
+ marks of institutions.
34
+ followers (int): Rounded by TikTok (for example 1100000). `/v1/users/{user}` gives the exact count. Example:
35
+ 97400000.
36
+ likes (int): The likes on all videos of the account. Not rounded. Example: 470139938.
37
+ collected_at (datetime.datetime): When we read this entry from TikTok: UTC, whole seconds. An entry from cache
38
+ (`"cache": "hit"`)
39
+ keeps the time of its own read.
40
+ Example: 2026-12-02T21:42:29Z.
41
+ avatar_url (str | Unset): The small avatar (100x100), on the TikTok image servers. The address carries a
42
+ signature and stops
43
+ working after some days: store the image, not the address. Absent when TikTok sends none.
44
+ """
45
+
46
+ id: str
47
+ username: str
48
+ sec_uid: str
49
+ nickname: str
50
+ bio: str
51
+ verified: bool
52
+ followers: int
53
+ likes: int
54
+ collected_at: datetime.datetime
55
+ avatar_url: str | Unset = UNSET
56
+ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
57
+
58
+ def to_dict(self) -> dict[str, Any]:
59
+ id = self.id
60
+
61
+ username = self.username
62
+
63
+ sec_uid = self.sec_uid
64
+
65
+ nickname = self.nickname
66
+
67
+ bio = self.bio
68
+
69
+ verified = self.verified
70
+
71
+ followers = self.followers
72
+
73
+ likes = self.likes
74
+
75
+ collected_at = self.collected_at.isoformat()
76
+
77
+ avatar_url = self.avatar_url
78
+
79
+ field_dict: dict[str, Any] = {}
80
+ field_dict.update(self.additional_properties)
81
+ field_dict.update(
82
+ {
83
+ "id": id,
84
+ "username": username,
85
+ "sec_uid": sec_uid,
86
+ "nickname": nickname,
87
+ "bio": bio,
88
+ "verified": verified,
89
+ "followers": followers,
90
+ "likes": likes,
91
+ "collected_at": collected_at,
92
+ }
93
+ )
94
+ if avatar_url is not UNSET:
95
+ field_dict["avatar_url"] = avatar_url
96
+
97
+ return field_dict
98
+
99
+ @classmethod
100
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
101
+ d = dict(src_dict)
102
+ id = d.pop("id")
103
+
104
+ username = d.pop("username")
105
+
106
+ sec_uid = d.pop("sec_uid")
107
+
108
+ nickname = d.pop("nickname")
109
+
110
+ bio = d.pop("bio")
111
+
112
+ verified = d.pop("verified")
113
+
114
+ followers = d.pop("followers")
115
+
116
+ likes = d.pop("likes")
117
+
118
+ collected_at = datetime.datetime.fromisoformat(d.pop("collected_at"))
119
+
120
+ avatar_url = d.pop("avatar_url", UNSET)
121
+
122
+ user_summary = cls(
123
+ id=id,
124
+ username=username,
125
+ sec_uid=sec_uid,
126
+ nickname=nickname,
127
+ bio=bio,
128
+ verified=verified,
129
+ followers=followers,
130
+ likes=likes,
131
+ collected_at=collected_at,
132
+ avatar_url=avatar_url,
133
+ )
134
+
135
+ user_summary.additional_properties = d
136
+ return user_summary
137
+
138
+ @property
139
+ def additional_keys(self) -> list[str]:
140
+ return list(self.additional_properties.keys())
141
+
142
+ def __getitem__(self, key: str) -> Any:
143
+ return self.additional_properties[key]
144
+
145
+ def __setitem__(self, key: str, value: Any) -> None:
146
+ self.additional_properties[key] = value
147
+
148
+ def __delitem__(self, key: str) -> None:
149
+ del self.additional_properties[key]
150
+
151
+ def __contains__(self, key: str) -> bool:
152
+ return key in self.additional_properties
@@ -0,0 +1,130 @@
1
+ from __future__ import annotations
2
+
3
+ from collections.abc import Mapping
4
+ from typing import TYPE_CHECKING, Any, TypeVar
5
+ from uuid import UUID
6
+
7
+ from attrs import define as _attrs_define
8
+ from attrs import field as _attrs_field
9
+
10
+ from ..models.meta_cache import MetaCache
11
+ from ..types import UNSET, Unset
12
+
13
+ if TYPE_CHECKING:
14
+ from ..models.user_summary import UserSummary
15
+
16
+
17
+ T = TypeVar("T", bound="UserSummaryPage")
18
+
19
+
20
+ @_attrs_define
21
+ class UserSummaryPage:
22
+ """
23
+ Attributes:
24
+ items (int): Objects returned.
25
+ credits_charged (float): Example: 16.
26
+ balance_remaining (float): Example: 79984.
27
+ cache (MetaCache): `miss`: read from TikTok, normal price. `hit`: from cache, half price. `bypass`: `fresh=true`
28
+ skipped a cached copy, 2x. A page that has cached and new items is `miss` (or `bypass`), and each item costs the
29
+ price of its own source; `hit` means all of it came from cache.
30
+ request_id (UUID):
31
+ data (list[UserSummary]):
32
+ next_cursor (str | Unset):
33
+ """
34
+
35
+ items: int
36
+ credits_charged: float
37
+ balance_remaining: float
38
+ cache: MetaCache
39
+ request_id: UUID
40
+ data: list[UserSummary]
41
+ next_cursor: str | Unset = UNSET
42
+ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
43
+
44
+ def to_dict(self) -> dict[str, Any]:
45
+ items = self.items
46
+
47
+ credits_charged = self.credits_charged
48
+
49
+ balance_remaining = self.balance_remaining
50
+
51
+ cache = self.cache.value
52
+
53
+ request_id = str(self.request_id)
54
+
55
+ data = []
56
+ for data_item_data in self.data:
57
+ data_item = data_item_data.to_dict()
58
+ data.append(data_item)
59
+
60
+ next_cursor = self.next_cursor
61
+
62
+ field_dict: dict[str, Any] = {}
63
+ field_dict.update(self.additional_properties)
64
+ field_dict.update(
65
+ {
66
+ "items": items,
67
+ "credits_charged": credits_charged,
68
+ "balance_remaining": balance_remaining,
69
+ "cache": cache,
70
+ "request_id": request_id,
71
+ "data": data,
72
+ }
73
+ )
74
+ if next_cursor is not UNSET:
75
+ field_dict["next_cursor"] = next_cursor
76
+
77
+ return field_dict
78
+
79
+ @classmethod
80
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
81
+ from ..models.user_summary import UserSummary # noqa: PLC0415
82
+
83
+ d = dict(src_dict)
84
+ items = d.pop("items")
85
+
86
+ credits_charged = d.pop("credits_charged")
87
+
88
+ balance_remaining = d.pop("balance_remaining")
89
+
90
+ cache = MetaCache(d.pop("cache"))
91
+
92
+ request_id = UUID(d.pop("request_id"))
93
+
94
+ data = []
95
+ _data = d.pop("data")
96
+ for data_item_data in _data:
97
+ data_item = UserSummary.from_dict(data_item_data)
98
+
99
+ data.append(data_item)
100
+
101
+ next_cursor = d.pop("next_cursor", UNSET)
102
+
103
+ user_summary_page = cls(
104
+ items=items,
105
+ credits_charged=credits_charged,
106
+ balance_remaining=balance_remaining,
107
+ cache=cache,
108
+ request_id=request_id,
109
+ data=data,
110
+ next_cursor=next_cursor,
111
+ )
112
+
113
+ user_summary_page.additional_properties = d
114
+ return user_summary_page
115
+
116
+ @property
117
+ def additional_keys(self) -> list[str]:
118
+ return list(self.additional_properties.keys())
119
+
120
+ def __getitem__(self, key: str) -> Any:
121
+ return self.additional_properties[key]
122
+
123
+ def __setitem__(self, key: str, value: Any) -> None:
124
+ self.additional_properties[key] = value
125
+
126
+ def __delitem__(self, key: str) -> None:
127
+ del self.additional_properties[key]
128
+
129
+ def __contains__(self, key: str) -> bool:
130
+ return key in self.additional_properties
@@ -0,0 +1,96 @@
1
+ from __future__ import annotations
2
+
3
+ from collections.abc import Mapping
4
+ from typing import TYPE_CHECKING, Any, TypeVar
5
+
6
+ from attrs import define as _attrs_define
7
+ from attrs import field as _attrs_field
8
+
9
+ from ..types import UNSET, Unset
10
+
11
+ if TYPE_CHECKING:
12
+ from ..models.video import Video
13
+
14
+
15
+ T = TypeVar("T", bound="UserVideos")
16
+
17
+
18
+ @_attrs_define
19
+ class UserVideos:
20
+ """
21
+ Attributes:
22
+ user (str): The username (without `@`, in lower case) or the sec_uid from the request.
23
+ videos (list[Video]): Pinned videos first, then newest first. Empty when the account has no public videos or is
24
+ private.
25
+ next_cursor (str | Unset): Send it to `/v1/users/{user}/videos` as `cursor` to read on. Not there on the last
26
+ page.
27
+ """
28
+
29
+ user: str
30
+ videos: list[Video]
31
+ next_cursor: str | Unset = UNSET
32
+ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
33
+
34
+ def to_dict(self) -> dict[str, Any]:
35
+ user = self.user
36
+
37
+ videos = []
38
+ for videos_item_data in self.videos:
39
+ videos_item = videos_item_data.to_dict()
40
+ videos.append(videos_item)
41
+
42
+ next_cursor = self.next_cursor
43
+
44
+ field_dict: dict[str, Any] = {}
45
+ field_dict.update(self.additional_properties)
46
+ field_dict.update(
47
+ {
48
+ "user": user,
49
+ "videos": videos,
50
+ }
51
+ )
52
+ if next_cursor is not UNSET:
53
+ field_dict["next_cursor"] = next_cursor
54
+
55
+ return field_dict
56
+
57
+ @classmethod
58
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
59
+ from ..models.video import Video # noqa: PLC0415
60
+
61
+ d = dict(src_dict)
62
+ user = d.pop("user")
63
+
64
+ videos = []
65
+ _videos = d.pop("videos")
66
+ for videos_item_data in _videos:
67
+ videos_item = Video.from_dict(videos_item_data)
68
+
69
+ videos.append(videos_item)
70
+
71
+ next_cursor = d.pop("next_cursor", UNSET)
72
+
73
+ user_videos = cls(
74
+ user=user,
75
+ videos=videos,
76
+ next_cursor=next_cursor,
77
+ )
78
+
79
+ user_videos.additional_properties = d
80
+ return user_videos
81
+
82
+ @property
83
+ def additional_keys(self) -> list[str]:
84
+ return list(self.additional_properties.keys())
85
+
86
+ def __getitem__(self, key: str) -> Any:
87
+ return self.additional_properties[key]
88
+
89
+ def __setitem__(self, key: str, value: Any) -> None:
90
+ self.additional_properties[key] = value
91
+
92
+ def __delitem__(self, key: str) -> None:
93
+ del self.additional_properties[key]
94
+
95
+ def __contains__(self, key: str) -> bool:
96
+ return key in self.additional_properties
@@ -0,0 +1,145 @@
1
+ from __future__ import annotations
2
+
3
+ from collections.abc import Mapping
4
+ from typing import TYPE_CHECKING, Any, TypeVar
5
+ from uuid import UUID
6
+
7
+ from attrs import define as _attrs_define
8
+ from attrs import field as _attrs_field
9
+
10
+ from ..models.batch_meta_cache import BatchMetaCache
11
+
12
+ if TYPE_CHECKING:
13
+ from ..models.batch_error import BatchError
14
+ from ..models.user_videos import UserVideos
15
+
16
+
17
+ T = TypeVar("T", bound="UserVideosBatch")
18
+
19
+
20
+ @_attrs_define
21
+ class UserVideosBatch:
22
+ """
23
+ Attributes:
24
+ errors (list[BatchError]): Inputs that returned nothing, with the reason. Never charged.
25
+ items (int): Objects returned. In the video lists batch: videos returned, for all accounts together.
26
+ credits_charged (float):
27
+ balance_remaining (float):
28
+ cache (BatchMetaCache): The mode of the found items when they all agree, else `mixed`.
29
+ cache_hits (int): Objects served from cache, at half price. In the video lists batch: accounts served from
30
+ cache.
31
+ request_id (UUID):
32
+ data (list[UserVideos]): One entry for each account that was read, in input order.
33
+ """
34
+
35
+ errors: list[BatchError]
36
+ items: int
37
+ credits_charged: float
38
+ balance_remaining: float
39
+ cache: BatchMetaCache
40
+ cache_hits: int
41
+ request_id: UUID
42
+ data: list[UserVideos]
43
+ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
44
+
45
+ def to_dict(self) -> dict[str, Any]:
46
+ errors = []
47
+ for errors_item_data in self.errors:
48
+ errors_item = errors_item_data.to_dict()
49
+ errors.append(errors_item)
50
+
51
+ items = self.items
52
+
53
+ credits_charged = self.credits_charged
54
+
55
+ balance_remaining = self.balance_remaining
56
+
57
+ cache = self.cache.value
58
+
59
+ cache_hits = self.cache_hits
60
+
61
+ request_id = str(self.request_id)
62
+
63
+ data = []
64
+ for data_item_data in self.data:
65
+ data_item = data_item_data.to_dict()
66
+ data.append(data_item)
67
+
68
+ field_dict: dict[str, Any] = {}
69
+ field_dict.update(self.additional_properties)
70
+ field_dict.update(
71
+ {
72
+ "errors": errors,
73
+ "items": items,
74
+ "credits_charged": credits_charged,
75
+ "balance_remaining": balance_remaining,
76
+ "cache": cache,
77
+ "cache_hits": cache_hits,
78
+ "request_id": request_id,
79
+ "data": data,
80
+ }
81
+ )
82
+
83
+ return field_dict
84
+
85
+ @classmethod
86
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
87
+ from ..models.batch_error import BatchError # noqa: PLC0415
88
+ from ..models.user_videos import UserVideos # noqa: PLC0415
89
+
90
+ d = dict(src_dict)
91
+ errors = []
92
+ _errors = d.pop("errors")
93
+ for errors_item_data in _errors:
94
+ errors_item = BatchError.from_dict(errors_item_data)
95
+
96
+ errors.append(errors_item)
97
+
98
+ items = d.pop("items")
99
+
100
+ credits_charged = d.pop("credits_charged")
101
+
102
+ balance_remaining = d.pop("balance_remaining")
103
+
104
+ cache = BatchMetaCache(d.pop("cache"))
105
+
106
+ cache_hits = d.pop("cache_hits")
107
+
108
+ request_id = UUID(d.pop("request_id"))
109
+
110
+ data = []
111
+ _data = d.pop("data")
112
+ for data_item_data in _data:
113
+ data_item = UserVideos.from_dict(data_item_data)
114
+
115
+ data.append(data_item)
116
+
117
+ user_videos_batch = cls(
118
+ errors=errors,
119
+ items=items,
120
+ credits_charged=credits_charged,
121
+ balance_remaining=balance_remaining,
122
+ cache=cache,
123
+ cache_hits=cache_hits,
124
+ request_id=request_id,
125
+ data=data,
126
+ )
127
+
128
+ user_videos_batch.additional_properties = d
129
+ return user_videos_batch
130
+
131
+ @property
132
+ def additional_keys(self) -> list[str]:
133
+ return list(self.additional_properties.keys())
134
+
135
+ def __getitem__(self, key: str) -> Any:
136
+ return self.additional_properties[key]
137
+
138
+ def __setitem__(self, key: str, value: Any) -> None:
139
+ self.additional_properties[key] = value
140
+
141
+ def __delitem__(self, key: str) -> None:
142
+ del self.additional_properties[key]
143
+
144
+ def __contains__(self, key: str) -> bool:
145
+ return key in self.additional_properties