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,297 @@
1
+ from __future__ import annotations
2
+
3
+ import datetime
4
+ from collections.abc import Mapping
5
+ from typing import TYPE_CHECKING, Any, TypeVar, cast
6
+
7
+ from attrs import define as _attrs_define
8
+ from attrs import field as _attrs_field
9
+
10
+ from ..models.video_type import VideoType
11
+ from ..types import UNSET, Unset
12
+
13
+ if TYPE_CHECKING:
14
+ from ..models.music import Music
15
+ from ..models.user import User
16
+
17
+
18
+ T = TypeVar("T", bound="Video")
19
+
20
+
21
+ @_attrs_define
22
+ class Video:
23
+ """
24
+ Attributes:
25
+ id (str): Example: 7106594312292453675.
26
+ url (str): Example: https://www.tiktok.com/@tiktok/video/7106594312292453675.
27
+ description (str): The caption as written, with its hashtags and mentions.
28
+ created_at (datetime.datetime): When the video was posted.
29
+ collected_at (datetime.datetime): When we read this video from TikTok: UTC, whole seconds. The counts (`plays`,
30
+ `likes` ...) are those
31
+ of that moment, and the video was there at that moment. A video from cache (`"cache": "hit"`) keeps
32
+ the time of its own read, so the videos of one page can have different times; `fresh=true` gives
33
+ a new read and a new time.
34
+ Example: 2026-12-02T08:55:12Z.
35
+ author (User): An account. The counts (`followers`, `following`, `likes`, `videos`) are exact in a profile that
36
+ you
37
+ read with `/v1/users/{user}` or `/v1/users/batch`. In the `author` of a video, TikTok sends them
38
+ rounded, and in an entry of a follower or following list they may be rounded: read the profile for the
39
+ exact counts.
40
+ type_ (VideoType | Unset): `photo`: a photo post (a set of images with a sound). Then `duration` is the length
41
+ of the sound.
42
+ lang (str | Unset): The language of the caption, when TikTok sends it.
43
+ duration (int | Unset): Seconds.
44
+ width (int | Unset):
45
+ height (int | Unset):
46
+ cover_url (str | Unset): The still image. Signed address; it stops working after some days.
47
+ plays (int | Unset): TikTok rounds a count of 10,000 or more to hundreds. The same is true for `likes`,
48
+ `comments` and `shares`.
49
+ likes (int | Unset): Rounded to hundreds from 10,000, as `plays`.
50
+ comments (int | Unset): Rounded to hundreds from 10,000, as `plays`.
51
+ shares (int | Unset): Rounded to hundreds from 10,000, as `plays`.
52
+ saves (int | Unset): How many times the video was added to favorites. Exact: TikTok does not round it.
53
+ music (Music | Unset):
54
+ hashtags (list[str] | Unset): Hashtag names without `#`.
55
+ mentions (list[str] | Unset): Usernames without `@`.
56
+ location (str | Unset): The country where the video was posted, a two-letter code such as `US`, when TikTok
57
+ sends it.
58
+ is_ad (bool | Unset):
59
+ is_pinned (bool | Unset): On a video list of an account: `true` for a video the account pinned on top. TikTok
60
+ puts pinned videos first.
61
+ """
62
+
63
+ id: str
64
+ url: str
65
+ description: str
66
+ created_at: datetime.datetime
67
+ collected_at: datetime.datetime
68
+ author: User
69
+ type_: VideoType | Unset = UNSET
70
+ lang: str | Unset = UNSET
71
+ duration: int | Unset = UNSET
72
+ width: int | Unset = UNSET
73
+ height: int | Unset = UNSET
74
+ cover_url: str | Unset = UNSET
75
+ plays: int | Unset = UNSET
76
+ likes: int | Unset = UNSET
77
+ comments: int | Unset = UNSET
78
+ shares: int | Unset = UNSET
79
+ saves: int | Unset = UNSET
80
+ music: Music | Unset = UNSET
81
+ hashtags: list[str] | Unset = UNSET
82
+ mentions: list[str] | Unset = UNSET
83
+ location: str | Unset = UNSET
84
+ is_ad: bool | Unset = UNSET
85
+ is_pinned: bool | Unset = UNSET
86
+ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
87
+
88
+ def to_dict(self) -> dict[str, Any]:
89
+ id = self.id
90
+
91
+ url = self.url
92
+
93
+ description = self.description
94
+
95
+ created_at = self.created_at.isoformat()
96
+
97
+ collected_at = self.collected_at.isoformat()
98
+
99
+ author = self.author.to_dict()
100
+
101
+ type_: str | Unset = UNSET
102
+ if not isinstance(self.type_, Unset):
103
+ type_ = self.type_.value
104
+
105
+ lang = self.lang
106
+
107
+ duration = self.duration
108
+
109
+ width = self.width
110
+
111
+ height = self.height
112
+
113
+ cover_url = self.cover_url
114
+
115
+ plays = self.plays
116
+
117
+ likes = self.likes
118
+
119
+ comments = self.comments
120
+
121
+ shares = self.shares
122
+
123
+ saves = self.saves
124
+
125
+ music: dict[str, Any] | Unset = UNSET
126
+ if not isinstance(self.music, Unset):
127
+ music = self.music.to_dict()
128
+
129
+ hashtags: list[str] | Unset = UNSET
130
+ if not isinstance(self.hashtags, Unset):
131
+ hashtags = self.hashtags
132
+
133
+ mentions: list[str] | Unset = UNSET
134
+ if not isinstance(self.mentions, Unset):
135
+ mentions = self.mentions
136
+
137
+ location = self.location
138
+
139
+ is_ad = self.is_ad
140
+
141
+ is_pinned = self.is_pinned
142
+
143
+ field_dict: dict[str, Any] = {}
144
+ field_dict.update(self.additional_properties)
145
+ field_dict.update(
146
+ {
147
+ "id": id,
148
+ "url": url,
149
+ "description": description,
150
+ "created_at": created_at,
151
+ "collected_at": collected_at,
152
+ "author": author,
153
+ }
154
+ )
155
+ if type_ is not UNSET:
156
+ field_dict["type"] = type_
157
+ if lang is not UNSET:
158
+ field_dict["lang"] = lang
159
+ if duration is not UNSET:
160
+ field_dict["duration"] = duration
161
+ if width is not UNSET:
162
+ field_dict["width"] = width
163
+ if height is not UNSET:
164
+ field_dict["height"] = height
165
+ if cover_url is not UNSET:
166
+ field_dict["cover_url"] = cover_url
167
+ if plays is not UNSET:
168
+ field_dict["plays"] = plays
169
+ if likes is not UNSET:
170
+ field_dict["likes"] = likes
171
+ if comments is not UNSET:
172
+ field_dict["comments"] = comments
173
+ if shares is not UNSET:
174
+ field_dict["shares"] = shares
175
+ if saves is not UNSET:
176
+ field_dict["saves"] = saves
177
+ if music is not UNSET:
178
+ field_dict["music"] = music
179
+ if hashtags is not UNSET:
180
+ field_dict["hashtags"] = hashtags
181
+ if mentions is not UNSET:
182
+ field_dict["mentions"] = mentions
183
+ if location is not UNSET:
184
+ field_dict["location"] = location
185
+ if is_ad is not UNSET:
186
+ field_dict["is_ad"] = is_ad
187
+ if is_pinned is not UNSET:
188
+ field_dict["is_pinned"] = is_pinned
189
+
190
+ return field_dict
191
+
192
+ @classmethod
193
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
194
+ from ..models.music import Music # noqa: PLC0415
195
+ from ..models.user import User # noqa: PLC0415
196
+
197
+ d = dict(src_dict)
198
+ id = d.pop("id")
199
+
200
+ url = d.pop("url")
201
+
202
+ description = d.pop("description")
203
+
204
+ created_at = datetime.datetime.fromisoformat(d.pop("created_at"))
205
+
206
+ collected_at = datetime.datetime.fromisoformat(d.pop("collected_at"))
207
+
208
+ author = User.from_dict(d.pop("author"))
209
+
210
+ _type_ = d.pop("type", UNSET)
211
+ type_: VideoType | Unset
212
+ if isinstance(_type_, Unset):
213
+ type_ = UNSET
214
+ else:
215
+ type_ = VideoType(_type_)
216
+
217
+ lang = d.pop("lang", UNSET)
218
+
219
+ duration = d.pop("duration", UNSET)
220
+
221
+ width = d.pop("width", UNSET)
222
+
223
+ height = d.pop("height", UNSET)
224
+
225
+ cover_url = d.pop("cover_url", UNSET)
226
+
227
+ plays = d.pop("plays", UNSET)
228
+
229
+ likes = d.pop("likes", UNSET)
230
+
231
+ comments = d.pop("comments", UNSET)
232
+
233
+ shares = d.pop("shares", UNSET)
234
+
235
+ saves = d.pop("saves", UNSET)
236
+
237
+ _music = d.pop("music", UNSET)
238
+ music: Music | Unset
239
+ if isinstance(_music, Unset):
240
+ music = UNSET
241
+ else:
242
+ music = Music.from_dict(_music)
243
+
244
+ hashtags = cast(list[str], d.pop("hashtags", UNSET))
245
+
246
+ mentions = cast(list[str], d.pop("mentions", UNSET))
247
+
248
+ location = d.pop("location", UNSET)
249
+
250
+ is_ad = d.pop("is_ad", UNSET)
251
+
252
+ is_pinned = d.pop("is_pinned", UNSET)
253
+
254
+ video = cls(
255
+ id=id,
256
+ url=url,
257
+ description=description,
258
+ created_at=created_at,
259
+ collected_at=collected_at,
260
+ author=author,
261
+ type_=type_,
262
+ lang=lang,
263
+ duration=duration,
264
+ width=width,
265
+ height=height,
266
+ cover_url=cover_url,
267
+ plays=plays,
268
+ likes=likes,
269
+ comments=comments,
270
+ shares=shares,
271
+ saves=saves,
272
+ music=music,
273
+ hashtags=hashtags,
274
+ mentions=mentions,
275
+ location=location,
276
+ is_ad=is_ad,
277
+ is_pinned=is_pinned,
278
+ )
279
+
280
+ video.additional_properties = d
281
+ return video
282
+
283
+ @property
284
+ def additional_keys(self) -> list[str]:
285
+ return list(self.additional_properties.keys())
286
+
287
+ def __getitem__(self, key: str) -> Any:
288
+ return self.additional_properties[key]
289
+
290
+ def __setitem__(self, key: str, value: Any) -> None:
291
+ self.additional_properties[key] = value
292
+
293
+ def __delitem__(self, key: str) -> None:
294
+ del self.additional_properties[key]
295
+
296
+ def __contains__(self, key: str) -> bool:
297
+ 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.video import Video
15
+
16
+
17
+ T = TypeVar("T", bound="VideoBatch")
18
+
19
+
20
+ @_attrs_define
21
+ class VideoBatch:
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[Video]): Found videos, 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[Video]
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.video import Video # 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 = Video.from_dict(data_item_data)
114
+
115
+ data.append(data_item)
116
+
117
+ video_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
+ video_batch.additional_properties = d
129
+ return video_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
@@ -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.video import Video
15
+
16
+
17
+ T = TypeVar("T", bound="VideoPage")
18
+
19
+
20
+ @_attrs_define
21
+ class VideoPage:
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[Video]):
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[Video]
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.video import Video # 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 = Video.from_dict(data_item_data)
98
+
99
+ data.append(data_item)
100
+
101
+ next_cursor = d.pop("next_cursor", UNSET)
102
+
103
+ video_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
+ video_page.additional_properties = d
114
+ return video_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,122 @@
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.video import Video
15
+
16
+
17
+ T = TypeVar("T", bound="VideoResponse")
18
+
19
+
20
+ @_attrs_define
21
+ class VideoResponse:
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 (Video):
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: Video
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 = self.data.to_dict()
56
+
57
+ next_cursor = self.next_cursor
58
+
59
+ field_dict: dict[str, Any] = {}
60
+ field_dict.update(self.additional_properties)
61
+ field_dict.update(
62
+ {
63
+ "items": items,
64
+ "credits_charged": credits_charged,
65
+ "balance_remaining": balance_remaining,
66
+ "cache": cache,
67
+ "request_id": request_id,
68
+ "data": data,
69
+ }
70
+ )
71
+ if next_cursor is not UNSET:
72
+ field_dict["next_cursor"] = next_cursor
73
+
74
+ return field_dict
75
+
76
+ @classmethod
77
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
78
+ from ..models.video import Video # noqa: PLC0415
79
+
80
+ d = dict(src_dict)
81
+ items = d.pop("items")
82
+
83
+ credits_charged = d.pop("credits_charged")
84
+
85
+ balance_remaining = d.pop("balance_remaining")
86
+
87
+ cache = MetaCache(d.pop("cache"))
88
+
89
+ request_id = UUID(d.pop("request_id"))
90
+
91
+ data = Video.from_dict(d.pop("data"))
92
+
93
+ next_cursor = d.pop("next_cursor", UNSET)
94
+
95
+ video_response = cls(
96
+ items=items,
97
+ credits_charged=credits_charged,
98
+ balance_remaining=balance_remaining,
99
+ cache=cache,
100
+ request_id=request_id,
101
+ data=data,
102
+ next_cursor=next_cursor,
103
+ )
104
+
105
+ video_response.additional_properties = d
106
+ return video_response
107
+
108
+ @property
109
+ def additional_keys(self) -> list[str]:
110
+ return list(self.additional_properties.keys())
111
+
112
+ def __getitem__(self, key: str) -> Any:
113
+ return self.additional_properties[key]
114
+
115
+ def __setitem__(self, key: str, value: Any) -> None:
116
+ self.additional_properties[key] = value
117
+
118
+ def __delitem__(self, key: str) -> None:
119
+ del self.additional_properties[key]
120
+
121
+ def __contains__(self, key: str) -> bool:
122
+ return key in self.additional_properties
@@ -0,0 +1,9 @@
1
+ from enum import StrEnum
2
+
3
+
4
+ class VideoType(StrEnum):
5
+ PHOTO = "photo"
6
+ VIDEO = "video"
7
+
8
+ def __str__(self) -> str:
9
+ return str(self.value)
tikdataapi/py.typed ADDED
@@ -0,0 +1 @@
1
+ # Marker file for PEP 561