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.
- tikdataapi/__init__.py +8 -0
- tikdataapi/api/__init__.py +1 -0
- tikdataapi/api/account/__init__.py +1 -0
- tikdataapi/api/account/get_me.py +144 -0
- tikdataapi/api/billing/__init__.py +1 -0
- tikdataapi/api/billing/create_checkout.py +215 -0
- tikdataapi/api/billing/list_packs.py +144 -0
- tikdataapi/api/hashtags/__init__.py +1 -0
- tikdataapi/api/hashtags/get_hashtag.py +220 -0
- tikdataapi/api/hashtags/get_hashtag_videos.py +250 -0
- tikdataapi/api/music/__init__.py +1 -0
- tikdataapi/api/music/get_music.py +234 -0
- tikdataapi/api/music/get_music_videos.py +254 -0
- tikdataapi/api/playlists/__init__.py +1 -0
- tikdataapi/api/playlists/get_playlist_videos.py +258 -0
- tikdataapi/api/search/__init__.py +1 -0
- tikdataapi/api/search/search_hashtags.py +261 -0
- tikdataapi/api/search/search_live.py +258 -0
- tikdataapi/api/search/search_music.py +260 -0
- tikdataapi/api/search/search_users.py +276 -0
- tikdataapi/api/search/search_videos.py +260 -0
- tikdataapi/api/users/__init__.py +1 -0
- tikdataapi/api/users/get_user.py +222 -0
- tikdataapi/api/users/get_user_followers.py +266 -0
- tikdataapi/api/users/get_user_following.py +266 -0
- tikdataapi/api/users/get_user_live.py +236 -0
- tikdataapi/api/users/get_user_playlists.py +276 -0
- tikdataapi/api/users/get_user_reposts.py +266 -0
- tikdataapi/api/users/get_user_videos.py +254 -0
- tikdataapi/api/users/get_users.py +247 -0
- tikdataapi/api/users/get_users_videos.py +259 -0
- tikdataapi/api/videos/__init__.py +1 -0
- tikdataapi/api/videos/get_comment_replies.py +260 -0
- tikdataapi/api/videos/get_comments.py +258 -0
- tikdataapi/api/videos/get_related_videos.py +247 -0
- tikdataapi/api/videos/get_trending_videos.py +238 -0
- tikdataapi/api/videos/get_video.py +218 -0
- tikdataapi/api/videos/get_video_transcript.py +247 -0
- tikdataapi/api/videos/get_videos.py +235 -0
- tikdataapi/client.py +268 -0
- tikdataapi/errors.py +16 -0
- tikdataapi/models/__init__.py +117 -0
- tikdataapi/models/batch_error.py +104 -0
- tikdataapi/models/batch_error_code.py +15 -0
- tikdataapi/models/batch_meta.py +127 -0
- tikdataapi/models/batch_meta_cache.py +11 -0
- tikdataapi/models/comment.py +163 -0
- tikdataapi/models/comment_author.py +97 -0
- tikdataapi/models/comment_page.py +130 -0
- tikdataapi/models/create_checkout_body.py +63 -0
- tikdataapi/models/create_checkout_body_pack.py +11 -0
- tikdataapi/models/create_checkout_response_200.py +97 -0
- tikdataapi/models/error.py +78 -0
- tikdataapi/models/error_body.py +107 -0
- tikdataapi/models/error_body_code.py +22 -0
- tikdataapi/models/get_me_response_200.py +88 -0
- tikdataapi/models/get_users_body.py +61 -0
- tikdataapi/models/get_users_videos_body.py +72 -0
- tikdataapi/models/get_videos_body.py +61 -0
- tikdataapi/models/hashtag.py +124 -0
- tikdataapi/models/hashtag_response.py +122 -0
- tikdataapi/models/hashtag_summary.py +98 -0
- tikdataapi/models/hashtag_summary_page.py +130 -0
- tikdataapi/models/list_packs_response_200.py +103 -0
- tikdataapi/models/list_packs_response_200_data_item.py +88 -0
- tikdataapi/models/list_packs_response_200_rate_limits_item.py +70 -0
- tikdataapi/models/live_room.py +142 -0
- tikdataapi/models/live_room_author.py +90 -0
- tikdataapi/models/live_room_page.py +130 -0
- tikdataapi/models/live_room_response.py +124 -0
- tikdataapi/models/meta.py +108 -0
- tikdataapi/models/meta_cache.py +10 -0
- tikdataapi/models/music.py +107 -0
- tikdataapi/models/music_detail.py +172 -0
- tikdataapi/models/music_response.py +124 -0
- tikdataapi/models/music_summary.py +137 -0
- tikdataapi/models/music_summary_page.py +130 -0
- tikdataapi/models/not_found_reason.py +12 -0
- tikdataapi/models/playlist.py +114 -0
- tikdataapi/models/playlist_author.py +86 -0
- tikdataapi/models/playlist_page.py +130 -0
- tikdataapi/models/problem.py +131 -0
- tikdataapi/models/transcript.py +128 -0
- tikdataapi/models/transcript_response.py +124 -0
- tikdataapi/models/transcript_segment.py +77 -0
- tikdataapi/models/user.py +207 -0
- tikdataapi/models/user_batch.py +145 -0
- tikdataapi/models/user_page.py +130 -0
- tikdataapi/models/user_response.py +126 -0
- tikdataapi/models/user_summary.py +152 -0
- tikdataapi/models/user_summary_page.py +130 -0
- tikdataapi/models/user_videos.py +96 -0
- tikdataapi/models/user_videos_batch.py +145 -0
- tikdataapi/models/video.py +297 -0
- tikdataapi/models/video_batch.py +145 -0
- tikdataapi/models/video_page.py +130 -0
- tikdataapi/models/video_response.py +122 -0
- tikdataapi/models/video_type.py +9 -0
- tikdataapi/py.typed +1 -0
- tikdataapi/types.py +54 -0
- tikdataapi-0.1.0.dist-info/METADATA +148 -0
- tikdataapi-0.1.0.dist-info/RECORD +103 -0
- tikdataapi-0.1.0.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
from http import HTTPStatus
|
|
2
|
+
from typing import Any
|
|
3
|
+
from urllib.parse import quote
|
|
4
|
+
|
|
5
|
+
import httpx
|
|
6
|
+
|
|
7
|
+
from ... import errors
|
|
8
|
+
from ...client import AuthenticatedClient, Client
|
|
9
|
+
from ...models.error import Error
|
|
10
|
+
from ...models.video_page import VideoPage
|
|
11
|
+
from ...types import UNSET, Response, Unset
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def _get_kwargs(
|
|
15
|
+
id: str,
|
|
16
|
+
*,
|
|
17
|
+
count: int | Unset = 16,
|
|
18
|
+
fresh: bool | Unset = False,
|
|
19
|
+
) -> dict[str, Any]:
|
|
20
|
+
|
|
21
|
+
params: dict[str, Any] = {}
|
|
22
|
+
|
|
23
|
+
params["count"] = count
|
|
24
|
+
|
|
25
|
+
params["fresh"] = fresh
|
|
26
|
+
|
|
27
|
+
params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
|
|
28
|
+
|
|
29
|
+
_kwargs: dict[str, Any] = {
|
|
30
|
+
"method": "get",
|
|
31
|
+
"url": "/v1/videos/{id}/related".format(
|
|
32
|
+
id=quote(str(id), safe=""),
|
|
33
|
+
),
|
|
34
|
+
"params": params,
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return _kwargs
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Error | VideoPage | None:
|
|
41
|
+
if response.status_code == 200:
|
|
42
|
+
response_200 = VideoPage.from_dict(response.json())
|
|
43
|
+
|
|
44
|
+
return response_200
|
|
45
|
+
|
|
46
|
+
if response.status_code == 400:
|
|
47
|
+
response_400 = Error.from_dict(response.json())
|
|
48
|
+
|
|
49
|
+
return response_400
|
|
50
|
+
|
|
51
|
+
if response.status_code == 401:
|
|
52
|
+
response_401 = Error.from_dict(response.json())
|
|
53
|
+
|
|
54
|
+
return response_401
|
|
55
|
+
|
|
56
|
+
if response.status_code == 402:
|
|
57
|
+
response_402 = Error.from_dict(response.json())
|
|
58
|
+
|
|
59
|
+
return response_402
|
|
60
|
+
|
|
61
|
+
if response.status_code == 404:
|
|
62
|
+
response_404 = Error.from_dict(response.json())
|
|
63
|
+
|
|
64
|
+
return response_404
|
|
65
|
+
|
|
66
|
+
if response.status_code == 429:
|
|
67
|
+
response_429 = Error.from_dict(response.json())
|
|
68
|
+
|
|
69
|
+
return response_429
|
|
70
|
+
|
|
71
|
+
if response.status_code == 500:
|
|
72
|
+
response_500 = Error.from_dict(response.json())
|
|
73
|
+
|
|
74
|
+
return response_500
|
|
75
|
+
|
|
76
|
+
if response.status_code == 503:
|
|
77
|
+
response_503 = Error.from_dict(response.json())
|
|
78
|
+
|
|
79
|
+
return response_503
|
|
80
|
+
|
|
81
|
+
if client.raise_on_unexpected_status:
|
|
82
|
+
raise errors.UnexpectedStatus(response.status_code, response.content)
|
|
83
|
+
else:
|
|
84
|
+
return None
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Error | VideoPage]:
|
|
88
|
+
return Response(
|
|
89
|
+
status_code=HTTPStatus(response.status_code),
|
|
90
|
+
content=response.content,
|
|
91
|
+
headers=response.headers,
|
|
92
|
+
parsed=_parse_response(client=client, response=response),
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def sync_detailed(
|
|
97
|
+
id: str,
|
|
98
|
+
*,
|
|
99
|
+
client: AuthenticatedClient | Client,
|
|
100
|
+
count: int | Unset = 16,
|
|
101
|
+
fresh: bool | Unset = False,
|
|
102
|
+
) -> Response[Error | VideoPage]:
|
|
103
|
+
"""Related videos
|
|
104
|
+
|
|
105
|
+
The videos that TikTok shows next to a video ("You may like"), in the order of TikTok. 1 credit per
|
|
106
|
+
video. One page of at most 16 videos and no next page: there is no `cursor`, and the answer never
|
|
107
|
+
has
|
|
108
|
+
a `next_cursor`.
|
|
109
|
+
New on 2026-12-03; its limits at TikTok are not measured yet.
|
|
110
|
+
|
|
111
|
+
Args:
|
|
112
|
+
id (str):
|
|
113
|
+
count (int | Unset): Default: 16.
|
|
114
|
+
fresh (bool | Unset): Default: False.
|
|
115
|
+
|
|
116
|
+
Raises:
|
|
117
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
118
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
119
|
+
|
|
120
|
+
Returns:
|
|
121
|
+
Response[Error | VideoPage]
|
|
122
|
+
"""
|
|
123
|
+
|
|
124
|
+
kwargs = _get_kwargs(
|
|
125
|
+
id=id,
|
|
126
|
+
count=count,
|
|
127
|
+
fresh=fresh,
|
|
128
|
+
)
|
|
129
|
+
|
|
130
|
+
response = client.get_httpx_client().request(
|
|
131
|
+
**kwargs,
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
return _build_response(client=client, response=response)
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
def sync(
|
|
138
|
+
id: str,
|
|
139
|
+
*,
|
|
140
|
+
client: AuthenticatedClient | Client,
|
|
141
|
+
count: int | Unset = 16,
|
|
142
|
+
fresh: bool | Unset = False,
|
|
143
|
+
) -> Error | VideoPage | None:
|
|
144
|
+
"""Related videos
|
|
145
|
+
|
|
146
|
+
The videos that TikTok shows next to a video ("You may like"), in the order of TikTok. 1 credit per
|
|
147
|
+
video. One page of at most 16 videos and no next page: there is no `cursor`, and the answer never
|
|
148
|
+
has
|
|
149
|
+
a `next_cursor`.
|
|
150
|
+
New on 2026-12-03; its limits at TikTok are not measured yet.
|
|
151
|
+
|
|
152
|
+
Args:
|
|
153
|
+
id (str):
|
|
154
|
+
count (int | Unset): Default: 16.
|
|
155
|
+
fresh (bool | Unset): Default: False.
|
|
156
|
+
|
|
157
|
+
Raises:
|
|
158
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
159
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
160
|
+
|
|
161
|
+
Returns:
|
|
162
|
+
Error | VideoPage
|
|
163
|
+
"""
|
|
164
|
+
|
|
165
|
+
return sync_detailed(
|
|
166
|
+
id=id,
|
|
167
|
+
client=client,
|
|
168
|
+
count=count,
|
|
169
|
+
fresh=fresh,
|
|
170
|
+
).parsed
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
async def asyncio_detailed(
|
|
174
|
+
id: str,
|
|
175
|
+
*,
|
|
176
|
+
client: AuthenticatedClient | Client,
|
|
177
|
+
count: int | Unset = 16,
|
|
178
|
+
fresh: bool | Unset = False,
|
|
179
|
+
) -> Response[Error | VideoPage]:
|
|
180
|
+
"""Related videos
|
|
181
|
+
|
|
182
|
+
The videos that TikTok shows next to a video ("You may like"), in the order of TikTok. 1 credit per
|
|
183
|
+
video. One page of at most 16 videos and no next page: there is no `cursor`, and the answer never
|
|
184
|
+
has
|
|
185
|
+
a `next_cursor`.
|
|
186
|
+
New on 2026-12-03; its limits at TikTok are not measured yet.
|
|
187
|
+
|
|
188
|
+
Args:
|
|
189
|
+
id (str):
|
|
190
|
+
count (int | Unset): Default: 16.
|
|
191
|
+
fresh (bool | Unset): Default: False.
|
|
192
|
+
|
|
193
|
+
Raises:
|
|
194
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
195
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
196
|
+
|
|
197
|
+
Returns:
|
|
198
|
+
Response[Error | VideoPage]
|
|
199
|
+
"""
|
|
200
|
+
|
|
201
|
+
kwargs = _get_kwargs(
|
|
202
|
+
id=id,
|
|
203
|
+
count=count,
|
|
204
|
+
fresh=fresh,
|
|
205
|
+
)
|
|
206
|
+
|
|
207
|
+
response = await client.get_async_httpx_client().request(**kwargs)
|
|
208
|
+
|
|
209
|
+
return _build_response(client=client, response=response)
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
async def asyncio(
|
|
213
|
+
id: str,
|
|
214
|
+
*,
|
|
215
|
+
client: AuthenticatedClient | Client,
|
|
216
|
+
count: int | Unset = 16,
|
|
217
|
+
fresh: bool | Unset = False,
|
|
218
|
+
) -> Error | VideoPage | None:
|
|
219
|
+
"""Related videos
|
|
220
|
+
|
|
221
|
+
The videos that TikTok shows next to a video ("You may like"), in the order of TikTok. 1 credit per
|
|
222
|
+
video. One page of at most 16 videos and no next page: there is no `cursor`, and the answer never
|
|
223
|
+
has
|
|
224
|
+
a `next_cursor`.
|
|
225
|
+
New on 2026-12-03; its limits at TikTok are not measured yet.
|
|
226
|
+
|
|
227
|
+
Args:
|
|
228
|
+
id (str):
|
|
229
|
+
count (int | Unset): Default: 16.
|
|
230
|
+
fresh (bool | Unset): Default: False.
|
|
231
|
+
|
|
232
|
+
Raises:
|
|
233
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
234
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
235
|
+
|
|
236
|
+
Returns:
|
|
237
|
+
Error | VideoPage
|
|
238
|
+
"""
|
|
239
|
+
|
|
240
|
+
return (
|
|
241
|
+
await asyncio_detailed(
|
|
242
|
+
id=id,
|
|
243
|
+
client=client,
|
|
244
|
+
count=count,
|
|
245
|
+
fresh=fresh,
|
|
246
|
+
)
|
|
247
|
+
).parsed
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
from http import HTTPStatus
|
|
2
|
+
from typing import Any
|
|
3
|
+
|
|
4
|
+
import httpx
|
|
5
|
+
|
|
6
|
+
from ... import errors
|
|
7
|
+
from ...client import AuthenticatedClient, Client
|
|
8
|
+
from ...models.error import Error
|
|
9
|
+
from ...models.video_page import VideoPage
|
|
10
|
+
from ...types import UNSET, Response, Unset
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def _get_kwargs(
|
|
14
|
+
*,
|
|
15
|
+
count: int | Unset = 16,
|
|
16
|
+
fresh: bool | Unset = False,
|
|
17
|
+
) -> dict[str, Any]:
|
|
18
|
+
|
|
19
|
+
params: dict[str, Any] = {}
|
|
20
|
+
|
|
21
|
+
params["count"] = count
|
|
22
|
+
|
|
23
|
+
params["fresh"] = fresh
|
|
24
|
+
|
|
25
|
+
params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
|
|
26
|
+
|
|
27
|
+
_kwargs: dict[str, Any] = {
|
|
28
|
+
"method": "get",
|
|
29
|
+
"url": "/v1/trending/videos",
|
|
30
|
+
"params": params,
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return _kwargs
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Error | VideoPage | None:
|
|
37
|
+
if response.status_code == 200:
|
|
38
|
+
response_200 = VideoPage.from_dict(response.json())
|
|
39
|
+
|
|
40
|
+
return response_200
|
|
41
|
+
|
|
42
|
+
if response.status_code == 400:
|
|
43
|
+
response_400 = Error.from_dict(response.json())
|
|
44
|
+
|
|
45
|
+
return response_400
|
|
46
|
+
|
|
47
|
+
if response.status_code == 401:
|
|
48
|
+
response_401 = Error.from_dict(response.json())
|
|
49
|
+
|
|
50
|
+
return response_401
|
|
51
|
+
|
|
52
|
+
if response.status_code == 402:
|
|
53
|
+
response_402 = Error.from_dict(response.json())
|
|
54
|
+
|
|
55
|
+
return response_402
|
|
56
|
+
|
|
57
|
+
if response.status_code == 429:
|
|
58
|
+
response_429 = Error.from_dict(response.json())
|
|
59
|
+
|
|
60
|
+
return response_429
|
|
61
|
+
|
|
62
|
+
if response.status_code == 500:
|
|
63
|
+
response_500 = Error.from_dict(response.json())
|
|
64
|
+
|
|
65
|
+
return response_500
|
|
66
|
+
|
|
67
|
+
if response.status_code == 503:
|
|
68
|
+
response_503 = Error.from_dict(response.json())
|
|
69
|
+
|
|
70
|
+
return response_503
|
|
71
|
+
|
|
72
|
+
if client.raise_on_unexpected_status:
|
|
73
|
+
raise errors.UnexpectedStatus(response.status_code, response.content)
|
|
74
|
+
else:
|
|
75
|
+
return None
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Error | VideoPage]:
|
|
79
|
+
return Response(
|
|
80
|
+
status_code=HTTPStatus(response.status_code),
|
|
81
|
+
content=response.content,
|
|
82
|
+
headers=response.headers,
|
|
83
|
+
parsed=_parse_response(client=client, response=response),
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def sync_detailed(
|
|
88
|
+
*,
|
|
89
|
+
client: AuthenticatedClient | Client,
|
|
90
|
+
count: int | Unset = 16,
|
|
91
|
+
fresh: bool | Unset = False,
|
|
92
|
+
) -> Response[Error | VideoPage]:
|
|
93
|
+
"""Trending videos
|
|
94
|
+
|
|
95
|
+
The videos of the explore feed that TikTok shows a logged-out visitor, in the order of TikTok. 1
|
|
96
|
+
credit
|
|
97
|
+
per video. There is no `cursor` and no `next_cursor`: TikTok gives the feed in batches of about 16
|
|
98
|
+
with
|
|
99
|
+
no position, so one call reads as many batches as `count` needs and drops repeated videos. The
|
|
100
|
+
answer is
|
|
101
|
+
cached for 2 minutes; a call after that gives a new set, which can repeat videos of an earlier one.
|
|
102
|
+
New on 2026-12-03; its limits at TikTok are not measured yet.
|
|
103
|
+
|
|
104
|
+
Args:
|
|
105
|
+
count (int | Unset): Default: 16.
|
|
106
|
+
fresh (bool | Unset): Default: False.
|
|
107
|
+
|
|
108
|
+
Raises:
|
|
109
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
110
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
111
|
+
|
|
112
|
+
Returns:
|
|
113
|
+
Response[Error | VideoPage]
|
|
114
|
+
"""
|
|
115
|
+
|
|
116
|
+
kwargs = _get_kwargs(
|
|
117
|
+
count=count,
|
|
118
|
+
fresh=fresh,
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
response = client.get_httpx_client().request(
|
|
122
|
+
**kwargs,
|
|
123
|
+
)
|
|
124
|
+
|
|
125
|
+
return _build_response(client=client, response=response)
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
def sync(
|
|
129
|
+
*,
|
|
130
|
+
client: AuthenticatedClient | Client,
|
|
131
|
+
count: int | Unset = 16,
|
|
132
|
+
fresh: bool | Unset = False,
|
|
133
|
+
) -> Error | VideoPage | None:
|
|
134
|
+
"""Trending videos
|
|
135
|
+
|
|
136
|
+
The videos of the explore feed that TikTok shows a logged-out visitor, in the order of TikTok. 1
|
|
137
|
+
credit
|
|
138
|
+
per video. There is no `cursor` and no `next_cursor`: TikTok gives the feed in batches of about 16
|
|
139
|
+
with
|
|
140
|
+
no position, so one call reads as many batches as `count` needs and drops repeated videos. The
|
|
141
|
+
answer is
|
|
142
|
+
cached for 2 minutes; a call after that gives a new set, which can repeat videos of an earlier one.
|
|
143
|
+
New on 2026-12-03; its limits at TikTok are not measured yet.
|
|
144
|
+
|
|
145
|
+
Args:
|
|
146
|
+
count (int | Unset): Default: 16.
|
|
147
|
+
fresh (bool | Unset): Default: False.
|
|
148
|
+
|
|
149
|
+
Raises:
|
|
150
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
151
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
152
|
+
|
|
153
|
+
Returns:
|
|
154
|
+
Error | VideoPage
|
|
155
|
+
"""
|
|
156
|
+
|
|
157
|
+
return sync_detailed(
|
|
158
|
+
client=client,
|
|
159
|
+
count=count,
|
|
160
|
+
fresh=fresh,
|
|
161
|
+
).parsed
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
async def asyncio_detailed(
|
|
165
|
+
*,
|
|
166
|
+
client: AuthenticatedClient | Client,
|
|
167
|
+
count: int | Unset = 16,
|
|
168
|
+
fresh: bool | Unset = False,
|
|
169
|
+
) -> Response[Error | VideoPage]:
|
|
170
|
+
"""Trending videos
|
|
171
|
+
|
|
172
|
+
The videos of the explore feed that TikTok shows a logged-out visitor, in the order of TikTok. 1
|
|
173
|
+
credit
|
|
174
|
+
per video. There is no `cursor` and no `next_cursor`: TikTok gives the feed in batches of about 16
|
|
175
|
+
with
|
|
176
|
+
no position, so one call reads as many batches as `count` needs and drops repeated videos. The
|
|
177
|
+
answer is
|
|
178
|
+
cached for 2 minutes; a call after that gives a new set, which can repeat videos of an earlier one.
|
|
179
|
+
New on 2026-12-03; its limits at TikTok are not measured yet.
|
|
180
|
+
|
|
181
|
+
Args:
|
|
182
|
+
count (int | Unset): Default: 16.
|
|
183
|
+
fresh (bool | Unset): Default: False.
|
|
184
|
+
|
|
185
|
+
Raises:
|
|
186
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
187
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
188
|
+
|
|
189
|
+
Returns:
|
|
190
|
+
Response[Error | VideoPage]
|
|
191
|
+
"""
|
|
192
|
+
|
|
193
|
+
kwargs = _get_kwargs(
|
|
194
|
+
count=count,
|
|
195
|
+
fresh=fresh,
|
|
196
|
+
)
|
|
197
|
+
|
|
198
|
+
response = await client.get_async_httpx_client().request(**kwargs)
|
|
199
|
+
|
|
200
|
+
return _build_response(client=client, response=response)
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
async def asyncio(
|
|
204
|
+
*,
|
|
205
|
+
client: AuthenticatedClient | Client,
|
|
206
|
+
count: int | Unset = 16,
|
|
207
|
+
fresh: bool | Unset = False,
|
|
208
|
+
) -> Error | VideoPage | None:
|
|
209
|
+
"""Trending videos
|
|
210
|
+
|
|
211
|
+
The videos of the explore feed that TikTok shows a logged-out visitor, in the order of TikTok. 1
|
|
212
|
+
credit
|
|
213
|
+
per video. There is no `cursor` and no `next_cursor`: TikTok gives the feed in batches of about 16
|
|
214
|
+
with
|
|
215
|
+
no position, so one call reads as many batches as `count` needs and drops repeated videos. The
|
|
216
|
+
answer is
|
|
217
|
+
cached for 2 minutes; a call after that gives a new set, which can repeat videos of an earlier one.
|
|
218
|
+
New on 2026-12-03; its limits at TikTok are not measured yet.
|
|
219
|
+
|
|
220
|
+
Args:
|
|
221
|
+
count (int | Unset): Default: 16.
|
|
222
|
+
fresh (bool | Unset): Default: False.
|
|
223
|
+
|
|
224
|
+
Raises:
|
|
225
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
226
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
227
|
+
|
|
228
|
+
Returns:
|
|
229
|
+
Error | VideoPage
|
|
230
|
+
"""
|
|
231
|
+
|
|
232
|
+
return (
|
|
233
|
+
await asyncio_detailed(
|
|
234
|
+
client=client,
|
|
235
|
+
count=count,
|
|
236
|
+
fresh=fresh,
|
|
237
|
+
)
|
|
238
|
+
).parsed
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
from http import HTTPStatus
|
|
2
|
+
from typing import Any
|
|
3
|
+
from urllib.parse import quote
|
|
4
|
+
|
|
5
|
+
import httpx
|
|
6
|
+
|
|
7
|
+
from ... import errors
|
|
8
|
+
from ...client import AuthenticatedClient, Client
|
|
9
|
+
from ...models.error import Error
|
|
10
|
+
from ...models.video_response import VideoResponse
|
|
11
|
+
from ...types import UNSET, Response, Unset
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def _get_kwargs(
|
|
15
|
+
id: str,
|
|
16
|
+
*,
|
|
17
|
+
fresh: bool | Unset = False,
|
|
18
|
+
) -> dict[str, Any]:
|
|
19
|
+
|
|
20
|
+
params: dict[str, Any] = {}
|
|
21
|
+
|
|
22
|
+
params["fresh"] = fresh
|
|
23
|
+
|
|
24
|
+
params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
|
|
25
|
+
|
|
26
|
+
_kwargs: dict[str, Any] = {
|
|
27
|
+
"method": "get",
|
|
28
|
+
"url": "/v1/videos/{id}".format(
|
|
29
|
+
id=quote(str(id), safe=""),
|
|
30
|
+
),
|
|
31
|
+
"params": params,
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return _kwargs
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Error | VideoResponse | None:
|
|
38
|
+
if response.status_code == 200:
|
|
39
|
+
response_200 = VideoResponse.from_dict(response.json())
|
|
40
|
+
|
|
41
|
+
return response_200
|
|
42
|
+
|
|
43
|
+
if response.status_code == 400:
|
|
44
|
+
response_400 = Error.from_dict(response.json())
|
|
45
|
+
|
|
46
|
+
return response_400
|
|
47
|
+
|
|
48
|
+
if response.status_code == 401:
|
|
49
|
+
response_401 = Error.from_dict(response.json())
|
|
50
|
+
|
|
51
|
+
return response_401
|
|
52
|
+
|
|
53
|
+
if response.status_code == 402:
|
|
54
|
+
response_402 = Error.from_dict(response.json())
|
|
55
|
+
|
|
56
|
+
return response_402
|
|
57
|
+
|
|
58
|
+
if response.status_code == 404:
|
|
59
|
+
response_404 = Error.from_dict(response.json())
|
|
60
|
+
|
|
61
|
+
return response_404
|
|
62
|
+
|
|
63
|
+
if response.status_code == 429:
|
|
64
|
+
response_429 = Error.from_dict(response.json())
|
|
65
|
+
|
|
66
|
+
return response_429
|
|
67
|
+
|
|
68
|
+
if response.status_code == 500:
|
|
69
|
+
response_500 = Error.from_dict(response.json())
|
|
70
|
+
|
|
71
|
+
return response_500
|
|
72
|
+
|
|
73
|
+
if response.status_code == 503:
|
|
74
|
+
response_503 = Error.from_dict(response.json())
|
|
75
|
+
|
|
76
|
+
return response_503
|
|
77
|
+
|
|
78
|
+
if client.raise_on_unexpected_status:
|
|
79
|
+
raise errors.UnexpectedStatus(response.status_code, response.content)
|
|
80
|
+
else:
|
|
81
|
+
return None
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def _build_response(
|
|
85
|
+
*, client: AuthenticatedClient | Client, response: httpx.Response
|
|
86
|
+
) -> Response[Error | VideoResponse]:
|
|
87
|
+
return Response(
|
|
88
|
+
status_code=HTTPStatus(response.status_code),
|
|
89
|
+
content=response.content,
|
|
90
|
+
headers=response.headers,
|
|
91
|
+
parsed=_parse_response(client=client, response=response),
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def sync_detailed(
|
|
96
|
+
id: str,
|
|
97
|
+
*,
|
|
98
|
+
client: AuthenticatedClient | Client,
|
|
99
|
+
fresh: bool | Unset = False,
|
|
100
|
+
) -> Response[Error | VideoResponse]:
|
|
101
|
+
"""Video by id
|
|
102
|
+
|
|
103
|
+
1 credit. The id is the number at the end of the address of the video.
|
|
104
|
+
|
|
105
|
+
Args:
|
|
106
|
+
id (str):
|
|
107
|
+
fresh (bool | Unset): Default: False.
|
|
108
|
+
|
|
109
|
+
Raises:
|
|
110
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
111
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
112
|
+
|
|
113
|
+
Returns:
|
|
114
|
+
Response[Error | VideoResponse]
|
|
115
|
+
"""
|
|
116
|
+
|
|
117
|
+
kwargs = _get_kwargs(
|
|
118
|
+
id=id,
|
|
119
|
+
fresh=fresh,
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
response = client.get_httpx_client().request(
|
|
123
|
+
**kwargs,
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
return _build_response(client=client, response=response)
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
def sync(
|
|
130
|
+
id: str,
|
|
131
|
+
*,
|
|
132
|
+
client: AuthenticatedClient | Client,
|
|
133
|
+
fresh: bool | Unset = False,
|
|
134
|
+
) -> Error | VideoResponse | None:
|
|
135
|
+
"""Video by id
|
|
136
|
+
|
|
137
|
+
1 credit. The id is the number at the end of the address of the video.
|
|
138
|
+
|
|
139
|
+
Args:
|
|
140
|
+
id (str):
|
|
141
|
+
fresh (bool | Unset): Default: False.
|
|
142
|
+
|
|
143
|
+
Raises:
|
|
144
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
145
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
146
|
+
|
|
147
|
+
Returns:
|
|
148
|
+
Error | VideoResponse
|
|
149
|
+
"""
|
|
150
|
+
|
|
151
|
+
return sync_detailed(
|
|
152
|
+
id=id,
|
|
153
|
+
client=client,
|
|
154
|
+
fresh=fresh,
|
|
155
|
+
).parsed
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
async def asyncio_detailed(
|
|
159
|
+
id: str,
|
|
160
|
+
*,
|
|
161
|
+
client: AuthenticatedClient | Client,
|
|
162
|
+
fresh: bool | Unset = False,
|
|
163
|
+
) -> Response[Error | VideoResponse]:
|
|
164
|
+
"""Video by id
|
|
165
|
+
|
|
166
|
+
1 credit. The id is the number at the end of the address of the video.
|
|
167
|
+
|
|
168
|
+
Args:
|
|
169
|
+
id (str):
|
|
170
|
+
fresh (bool | Unset): Default: False.
|
|
171
|
+
|
|
172
|
+
Raises:
|
|
173
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
174
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
175
|
+
|
|
176
|
+
Returns:
|
|
177
|
+
Response[Error | VideoResponse]
|
|
178
|
+
"""
|
|
179
|
+
|
|
180
|
+
kwargs = _get_kwargs(
|
|
181
|
+
id=id,
|
|
182
|
+
fresh=fresh,
|
|
183
|
+
)
|
|
184
|
+
|
|
185
|
+
response = await client.get_async_httpx_client().request(**kwargs)
|
|
186
|
+
|
|
187
|
+
return _build_response(client=client, response=response)
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
async def asyncio(
|
|
191
|
+
id: str,
|
|
192
|
+
*,
|
|
193
|
+
client: AuthenticatedClient | Client,
|
|
194
|
+
fresh: bool | Unset = False,
|
|
195
|
+
) -> Error | VideoResponse | None:
|
|
196
|
+
"""Video by id
|
|
197
|
+
|
|
198
|
+
1 credit. The id is the number at the end of the address of the video.
|
|
199
|
+
|
|
200
|
+
Args:
|
|
201
|
+
id (str):
|
|
202
|
+
fresh (bool | Unset): Default: False.
|
|
203
|
+
|
|
204
|
+
Raises:
|
|
205
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
206
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
207
|
+
|
|
208
|
+
Returns:
|
|
209
|
+
Error | VideoResponse
|
|
210
|
+
"""
|
|
211
|
+
|
|
212
|
+
return (
|
|
213
|
+
await asyncio_detailed(
|
|
214
|
+
id=id,
|
|
215
|
+
client=client,
|
|
216
|
+
fresh=fresh,
|
|
217
|
+
)
|
|
218
|
+
).parsed
|