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,236 @@
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.live_room_response import LiveRoomResponse
11
+ from ...types import UNSET, Response, Unset
12
+
13
+
14
+ def _get_kwargs(
15
+ user: 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/users/{user}/live".format(
29
+ user=quote(str(user), safe=""),
30
+ ),
31
+ "params": params,
32
+ }
33
+
34
+ return _kwargs
35
+
36
+
37
+ def _parse_response(
38
+ *, client: AuthenticatedClient | Client, response: httpx.Response
39
+ ) -> Error | LiveRoomResponse | None:
40
+ if response.status_code == 200:
41
+ response_200 = LiveRoomResponse.from_dict(response.json())
42
+
43
+ return response_200
44
+
45
+ if response.status_code == 400:
46
+ response_400 = Error.from_dict(response.json())
47
+
48
+ return response_400
49
+
50
+ if response.status_code == 401:
51
+ response_401 = Error.from_dict(response.json())
52
+
53
+ return response_401
54
+
55
+ if response.status_code == 402:
56
+ response_402 = Error.from_dict(response.json())
57
+
58
+ return response_402
59
+
60
+ if response.status_code == 404:
61
+ response_404 = Error.from_dict(response.json())
62
+
63
+ return response_404
64
+
65
+ if response.status_code == 429:
66
+ response_429 = Error.from_dict(response.json())
67
+
68
+ return response_429
69
+
70
+ if response.status_code == 500:
71
+ response_500 = Error.from_dict(response.json())
72
+
73
+ return response_500
74
+
75
+ if response.status_code == 503:
76
+ response_503 = Error.from_dict(response.json())
77
+
78
+ return response_503
79
+
80
+ if client.raise_on_unexpected_status:
81
+ raise errors.UnexpectedStatus(response.status_code, response.content)
82
+ else:
83
+ return None
84
+
85
+
86
+ def _build_response(
87
+ *, client: AuthenticatedClient | Client, response: httpx.Response
88
+ ) -> Response[Error | LiveRoomResponse]:
89
+ return Response(
90
+ status_code=HTTPStatus(response.status_code),
91
+ content=response.content,
92
+ headers=response.headers,
93
+ parsed=_parse_response(client=client, response=response),
94
+ )
95
+
96
+
97
+ def sync_detailed(
98
+ user: str,
99
+ *,
100
+ client: AuthenticatedClient | Client,
101
+ fresh: bool | Unset = False,
102
+ ) -> Response[Error | LiveRoomResponse]:
103
+ """Live state of an account
104
+
105
+ Whether an account is live now, with its room when it is. 1 credit, live or not: the answer is a
106
+ `LiveRoom` with `live: false` and no room fields when the account is not live. `user` is a username
107
+ or a sec_uid; a sec_uid is changed to the username through the profile, free. No stream addresses.
108
+ The answer is cached for 1 minute.
109
+ New on 2026-12-03; its limits at TikTok are not measured yet.
110
+
111
+ Args:
112
+ user (str):
113
+ fresh (bool | Unset): Default: False.
114
+
115
+ Raises:
116
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
117
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
118
+
119
+ Returns:
120
+ Response[Error | LiveRoomResponse]
121
+ """
122
+
123
+ kwargs = _get_kwargs(
124
+ user=user,
125
+ fresh=fresh,
126
+ )
127
+
128
+ response = client.get_httpx_client().request(
129
+ **kwargs,
130
+ )
131
+
132
+ return _build_response(client=client, response=response)
133
+
134
+
135
+ def sync(
136
+ user: str,
137
+ *,
138
+ client: AuthenticatedClient | Client,
139
+ fresh: bool | Unset = False,
140
+ ) -> Error | LiveRoomResponse | None:
141
+ """Live state of an account
142
+
143
+ Whether an account is live now, with its room when it is. 1 credit, live or not: the answer is a
144
+ `LiveRoom` with `live: false` and no room fields when the account is not live. `user` is a username
145
+ or a sec_uid; a sec_uid is changed to the username through the profile, free. No stream addresses.
146
+ The answer is cached for 1 minute.
147
+ New on 2026-12-03; its limits at TikTok are not measured yet.
148
+
149
+ Args:
150
+ user (str):
151
+ fresh (bool | Unset): Default: False.
152
+
153
+ Raises:
154
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
155
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
156
+
157
+ Returns:
158
+ Error | LiveRoomResponse
159
+ """
160
+
161
+ return sync_detailed(
162
+ user=user,
163
+ client=client,
164
+ fresh=fresh,
165
+ ).parsed
166
+
167
+
168
+ async def asyncio_detailed(
169
+ user: str,
170
+ *,
171
+ client: AuthenticatedClient | Client,
172
+ fresh: bool | Unset = False,
173
+ ) -> Response[Error | LiveRoomResponse]:
174
+ """Live state of an account
175
+
176
+ Whether an account is live now, with its room when it is. 1 credit, live or not: the answer is a
177
+ `LiveRoom` with `live: false` and no room fields when the account is not live. `user` is a username
178
+ or a sec_uid; a sec_uid is changed to the username through the profile, free. No stream addresses.
179
+ The answer is cached for 1 minute.
180
+ New on 2026-12-03; its limits at TikTok are not measured yet.
181
+
182
+ Args:
183
+ user (str):
184
+ fresh (bool | Unset): Default: False.
185
+
186
+ Raises:
187
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
188
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
189
+
190
+ Returns:
191
+ Response[Error | LiveRoomResponse]
192
+ """
193
+
194
+ kwargs = _get_kwargs(
195
+ user=user,
196
+ fresh=fresh,
197
+ )
198
+
199
+ response = await client.get_async_httpx_client().request(**kwargs)
200
+
201
+ return _build_response(client=client, response=response)
202
+
203
+
204
+ async def asyncio(
205
+ user: str,
206
+ *,
207
+ client: AuthenticatedClient | Client,
208
+ fresh: bool | Unset = False,
209
+ ) -> Error | LiveRoomResponse | None:
210
+ """Live state of an account
211
+
212
+ Whether an account is live now, with its room when it is. 1 credit, live or not: the answer is a
213
+ `LiveRoom` with `live: false` and no room fields when the account is not live. `user` is a username
214
+ or a sec_uid; a sec_uid is changed to the username through the profile, free. No stream addresses.
215
+ The answer is cached for 1 minute.
216
+ New on 2026-12-03; its limits at TikTok are not measured yet.
217
+
218
+ Args:
219
+ user (str):
220
+ fresh (bool | Unset): Default: False.
221
+
222
+ Raises:
223
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
224
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
225
+
226
+ Returns:
227
+ Error | LiveRoomResponse
228
+ """
229
+
230
+ return (
231
+ await asyncio_detailed(
232
+ user=user,
233
+ client=client,
234
+ fresh=fresh,
235
+ )
236
+ ).parsed
@@ -0,0 +1,276 @@
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.playlist_page import PlaylistPage
11
+ from ...types import UNSET, Response, Unset
12
+
13
+
14
+ def _get_kwargs(
15
+ user: str,
16
+ *,
17
+ count: int | Unset = 20,
18
+ cursor: str | Unset = UNSET,
19
+ fresh: bool | Unset = False,
20
+ ) -> dict[str, Any]:
21
+
22
+ params: dict[str, Any] = {}
23
+
24
+ params["count"] = count
25
+
26
+ params["cursor"] = cursor
27
+
28
+ params["fresh"] = fresh
29
+
30
+ params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
31
+
32
+ _kwargs: dict[str, Any] = {
33
+ "method": "get",
34
+ "url": "/v1/users/{user}/playlists".format(
35
+ user=quote(str(user), safe=""),
36
+ ),
37
+ "params": params,
38
+ }
39
+
40
+ return _kwargs
41
+
42
+
43
+ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Error | PlaylistPage | None:
44
+ if response.status_code == 200:
45
+ response_200 = PlaylistPage.from_dict(response.json())
46
+
47
+ return response_200
48
+
49
+ if response.status_code == 400:
50
+ response_400 = Error.from_dict(response.json())
51
+
52
+ return response_400
53
+
54
+ if response.status_code == 401:
55
+ response_401 = Error.from_dict(response.json())
56
+
57
+ return response_401
58
+
59
+ if response.status_code == 402:
60
+ response_402 = Error.from_dict(response.json())
61
+
62
+ return response_402
63
+
64
+ if response.status_code == 404:
65
+ response_404 = Error.from_dict(response.json())
66
+
67
+ return response_404
68
+
69
+ if response.status_code == 429:
70
+ response_429 = Error.from_dict(response.json())
71
+
72
+ return response_429
73
+
74
+ if response.status_code == 500:
75
+ response_500 = Error.from_dict(response.json())
76
+
77
+ return response_500
78
+
79
+ if response.status_code == 503:
80
+ response_503 = Error.from_dict(response.json())
81
+
82
+ return response_503
83
+
84
+ if client.raise_on_unexpected_status:
85
+ raise errors.UnexpectedStatus(response.status_code, response.content)
86
+ else:
87
+ return None
88
+
89
+
90
+ def _build_response(
91
+ *, client: AuthenticatedClient | Client, response: httpx.Response
92
+ ) -> Response[Error | PlaylistPage]:
93
+ return Response(
94
+ status_code=HTTPStatus(response.status_code),
95
+ content=response.content,
96
+ headers=response.headers,
97
+ parsed=_parse_response(client=client, response=response),
98
+ )
99
+
100
+
101
+ def sync_detailed(
102
+ user: str,
103
+ *,
104
+ client: AuthenticatedClient | Client,
105
+ count: int | Unset = 20,
106
+ cursor: str | Unset = UNSET,
107
+ fresh: bool | Unset = False,
108
+ ) -> Response[Error | PlaylistPage]:
109
+ """Playlists of an account
110
+
111
+ The playlists that an account made, in the order of its profile. 1 credit per playlist. Read the
112
+ videos
113
+ of a playlist with `/v1/playlists/{id}/videos`. `user` is a username or a sec_uid; a username is
114
+ changed
115
+ to the sec_uid through the profile, free. An account with no playlist, or a private one, gives an
116
+ empty
117
+ list, free.
118
+ New on 2026-12-03; its limits at TikTok are not measured yet.
119
+
120
+ Args:
121
+ user (str):
122
+ count (int | Unset): Default: 20.
123
+ cursor (str | Unset):
124
+ fresh (bool | Unset): Default: False.
125
+
126
+ Raises:
127
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
128
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
129
+
130
+ Returns:
131
+ Response[Error | PlaylistPage]
132
+ """
133
+
134
+ kwargs = _get_kwargs(
135
+ user=user,
136
+ count=count,
137
+ cursor=cursor,
138
+ fresh=fresh,
139
+ )
140
+
141
+ response = client.get_httpx_client().request(
142
+ **kwargs,
143
+ )
144
+
145
+ return _build_response(client=client, response=response)
146
+
147
+
148
+ def sync(
149
+ user: str,
150
+ *,
151
+ client: AuthenticatedClient | Client,
152
+ count: int | Unset = 20,
153
+ cursor: str | Unset = UNSET,
154
+ fresh: bool | Unset = False,
155
+ ) -> Error | PlaylistPage | None:
156
+ """Playlists of an account
157
+
158
+ The playlists that an account made, in the order of its profile. 1 credit per playlist. Read the
159
+ videos
160
+ of a playlist with `/v1/playlists/{id}/videos`. `user` is a username or a sec_uid; a username is
161
+ changed
162
+ to the sec_uid through the profile, free. An account with no playlist, or a private one, gives an
163
+ empty
164
+ list, free.
165
+ New on 2026-12-03; its limits at TikTok are not measured yet.
166
+
167
+ Args:
168
+ user (str):
169
+ count (int | Unset): Default: 20.
170
+ cursor (str | Unset):
171
+ fresh (bool | Unset): Default: False.
172
+
173
+ Raises:
174
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
175
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
176
+
177
+ Returns:
178
+ Error | PlaylistPage
179
+ """
180
+
181
+ return sync_detailed(
182
+ user=user,
183
+ client=client,
184
+ count=count,
185
+ cursor=cursor,
186
+ fresh=fresh,
187
+ ).parsed
188
+
189
+
190
+ async def asyncio_detailed(
191
+ user: str,
192
+ *,
193
+ client: AuthenticatedClient | Client,
194
+ count: int | Unset = 20,
195
+ cursor: str | Unset = UNSET,
196
+ fresh: bool | Unset = False,
197
+ ) -> Response[Error | PlaylistPage]:
198
+ """Playlists of an account
199
+
200
+ The playlists that an account made, in the order of its profile. 1 credit per playlist. Read the
201
+ videos
202
+ of a playlist with `/v1/playlists/{id}/videos`. `user` is a username or a sec_uid; a username is
203
+ changed
204
+ to the sec_uid through the profile, free. An account with no playlist, or a private one, gives an
205
+ empty
206
+ list, free.
207
+ New on 2026-12-03; its limits at TikTok are not measured yet.
208
+
209
+ Args:
210
+ user (str):
211
+ count (int | Unset): Default: 20.
212
+ cursor (str | Unset):
213
+ fresh (bool | Unset): Default: False.
214
+
215
+ Raises:
216
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
217
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
218
+
219
+ Returns:
220
+ Response[Error | PlaylistPage]
221
+ """
222
+
223
+ kwargs = _get_kwargs(
224
+ user=user,
225
+ count=count,
226
+ cursor=cursor,
227
+ fresh=fresh,
228
+ )
229
+
230
+ response = await client.get_async_httpx_client().request(**kwargs)
231
+
232
+ return _build_response(client=client, response=response)
233
+
234
+
235
+ async def asyncio(
236
+ user: str,
237
+ *,
238
+ client: AuthenticatedClient | Client,
239
+ count: int | Unset = 20,
240
+ cursor: str | Unset = UNSET,
241
+ fresh: bool | Unset = False,
242
+ ) -> Error | PlaylistPage | None:
243
+ """Playlists of an account
244
+
245
+ The playlists that an account made, in the order of its profile. 1 credit per playlist. Read the
246
+ videos
247
+ of a playlist with `/v1/playlists/{id}/videos`. `user` is a username or a sec_uid; a username is
248
+ changed
249
+ to the sec_uid through the profile, free. An account with no playlist, or a private one, gives an
250
+ empty
251
+ list, free.
252
+ New on 2026-12-03; its limits at TikTok are not measured yet.
253
+
254
+ Args:
255
+ user (str):
256
+ count (int | Unset): Default: 20.
257
+ cursor (str | Unset):
258
+ fresh (bool | Unset): Default: False.
259
+
260
+ Raises:
261
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
262
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
263
+
264
+ Returns:
265
+ Error | PlaylistPage
266
+ """
267
+
268
+ return (
269
+ await asyncio_detailed(
270
+ user=user,
271
+ client=client,
272
+ count=count,
273
+ cursor=cursor,
274
+ fresh=fresh,
275
+ )
276
+ ).parsed