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,266 @@
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
+ user: str,
16
+ *,
17
+ count: int | Unset = 16,
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}/reposts".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 | VideoPage | None:
44
+ if response.status_code == 200:
45
+ response_200 = VideoPage.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(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Error | VideoPage]:
91
+ return Response(
92
+ status_code=HTTPStatus(response.status_code),
93
+ content=response.content,
94
+ headers=response.headers,
95
+ parsed=_parse_response(client=client, response=response),
96
+ )
97
+
98
+
99
+ def sync_detailed(
100
+ user: str,
101
+ *,
102
+ client: AuthenticatedClient | Client,
103
+ count: int | Unset = 16,
104
+ cursor: str | Unset = UNSET,
105
+ fresh: bool | Unset = False,
106
+ ) -> Response[Error | VideoPage]:
107
+ """Reposts of an account
108
+
109
+ The videos that an account reposted, in the order of TikTok. 1 credit per video. `user` is a
110
+ username
111
+ or a sec_uid; a username is changed to the sec_uid through the profile, free. A private account, or
112
+ an
113
+ account with no repost, gives an empty list, free.
114
+ New on 2026-12-03; its limits at TikTok are not measured yet.
115
+
116
+ Args:
117
+ user (str):
118
+ count (int | Unset): Default: 16.
119
+ cursor (str | Unset):
120
+ fresh (bool | Unset): Default: False.
121
+
122
+ Raises:
123
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
124
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
125
+
126
+ Returns:
127
+ Response[Error | VideoPage]
128
+ """
129
+
130
+ kwargs = _get_kwargs(
131
+ user=user,
132
+ count=count,
133
+ cursor=cursor,
134
+ fresh=fresh,
135
+ )
136
+
137
+ response = client.get_httpx_client().request(
138
+ **kwargs,
139
+ )
140
+
141
+ return _build_response(client=client, response=response)
142
+
143
+
144
+ def sync(
145
+ user: str,
146
+ *,
147
+ client: AuthenticatedClient | Client,
148
+ count: int | Unset = 16,
149
+ cursor: str | Unset = UNSET,
150
+ fresh: bool | Unset = False,
151
+ ) -> Error | VideoPage | None:
152
+ """Reposts of an account
153
+
154
+ The videos that an account reposted, in the order of TikTok. 1 credit per video. `user` is a
155
+ username
156
+ or a sec_uid; a username is changed to the sec_uid through the profile, free. A private account, or
157
+ an
158
+ account with no repost, gives an empty list, free.
159
+ New on 2026-12-03; its limits at TikTok are not measured yet.
160
+
161
+ Args:
162
+ user (str):
163
+ count (int | Unset): Default: 16.
164
+ cursor (str | Unset):
165
+ fresh (bool | Unset): Default: False.
166
+
167
+ Raises:
168
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
169
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
170
+
171
+ Returns:
172
+ Error | VideoPage
173
+ """
174
+
175
+ return sync_detailed(
176
+ user=user,
177
+ client=client,
178
+ count=count,
179
+ cursor=cursor,
180
+ fresh=fresh,
181
+ ).parsed
182
+
183
+
184
+ async def asyncio_detailed(
185
+ user: str,
186
+ *,
187
+ client: AuthenticatedClient | Client,
188
+ count: int | Unset = 16,
189
+ cursor: str | Unset = UNSET,
190
+ fresh: bool | Unset = False,
191
+ ) -> Response[Error | VideoPage]:
192
+ """Reposts of an account
193
+
194
+ The videos that an account reposted, in the order of TikTok. 1 credit per video. `user` is a
195
+ username
196
+ or a sec_uid; a username is changed to the sec_uid through the profile, free. A private account, or
197
+ an
198
+ account with no repost, gives an empty list, free.
199
+ New on 2026-12-03; its limits at TikTok are not measured yet.
200
+
201
+ Args:
202
+ user (str):
203
+ count (int | Unset): Default: 16.
204
+ cursor (str | Unset):
205
+ fresh (bool | Unset): Default: False.
206
+
207
+ Raises:
208
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
209
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
210
+
211
+ Returns:
212
+ Response[Error | VideoPage]
213
+ """
214
+
215
+ kwargs = _get_kwargs(
216
+ user=user,
217
+ count=count,
218
+ cursor=cursor,
219
+ fresh=fresh,
220
+ )
221
+
222
+ response = await client.get_async_httpx_client().request(**kwargs)
223
+
224
+ return _build_response(client=client, response=response)
225
+
226
+
227
+ async def asyncio(
228
+ user: str,
229
+ *,
230
+ client: AuthenticatedClient | Client,
231
+ count: int | Unset = 16,
232
+ cursor: str | Unset = UNSET,
233
+ fresh: bool | Unset = False,
234
+ ) -> Error | VideoPage | None:
235
+ """Reposts of an account
236
+
237
+ The videos that an account reposted, in the order of TikTok. 1 credit per video. `user` is a
238
+ username
239
+ or a sec_uid; a username is changed to the sec_uid through the profile, free. A private account, or
240
+ an
241
+ account with no repost, gives an empty list, free.
242
+ New on 2026-12-03; its limits at TikTok are not measured yet.
243
+
244
+ Args:
245
+ user (str):
246
+ count (int | Unset): Default: 16.
247
+ cursor (str | Unset):
248
+ fresh (bool | Unset): Default: False.
249
+
250
+ Raises:
251
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
252
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
253
+
254
+ Returns:
255
+ Error | VideoPage
256
+ """
257
+
258
+ return (
259
+ await asyncio_detailed(
260
+ user=user,
261
+ client=client,
262
+ count=count,
263
+ cursor=cursor,
264
+ fresh=fresh,
265
+ )
266
+ ).parsed
@@ -0,0 +1,254 @@
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
+ user: str,
16
+ *,
17
+ count: int | Unset = 16,
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}/videos".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 | VideoPage | None:
44
+ if response.status_code == 200:
45
+ response_200 = VideoPage.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(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Error | VideoPage]:
91
+ return Response(
92
+ status_code=HTTPStatus(response.status_code),
93
+ content=response.content,
94
+ headers=response.headers,
95
+ parsed=_parse_response(client=client, response=response),
96
+ )
97
+
98
+
99
+ def sync_detailed(
100
+ user: str,
101
+ *,
102
+ client: AuthenticatedClient | Client,
103
+ count: int | Unset = 16,
104
+ cursor: str | Unset = UNSET,
105
+ fresh: bool | Unset = False,
106
+ ) -> Response[Error | VideoPage]:
107
+ """Videos of an account
108
+
109
+ Pinned videos first, then newest first. 1 credit per video. `user` is a username or a sec_uid; a
110
+ username is changed to the sec_uid through the profile, free. A private account gives an empty list,
111
+ free.
112
+
113
+ Args:
114
+ user (str):
115
+ count (int | Unset): Default: 16.
116
+ cursor (str | Unset):
117
+ fresh (bool | Unset): Default: False.
118
+
119
+ Raises:
120
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
121
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
122
+
123
+ Returns:
124
+ Response[Error | VideoPage]
125
+ """
126
+
127
+ kwargs = _get_kwargs(
128
+ user=user,
129
+ count=count,
130
+ cursor=cursor,
131
+ fresh=fresh,
132
+ )
133
+
134
+ response = client.get_httpx_client().request(
135
+ **kwargs,
136
+ )
137
+
138
+ return _build_response(client=client, response=response)
139
+
140
+
141
+ def sync(
142
+ user: str,
143
+ *,
144
+ client: AuthenticatedClient | Client,
145
+ count: int | Unset = 16,
146
+ cursor: str | Unset = UNSET,
147
+ fresh: bool | Unset = False,
148
+ ) -> Error | VideoPage | None:
149
+ """Videos of an account
150
+
151
+ Pinned videos first, then newest first. 1 credit per video. `user` is a username or a sec_uid; a
152
+ username is changed to the sec_uid through the profile, free. A private account gives an empty list,
153
+ free.
154
+
155
+ Args:
156
+ user (str):
157
+ count (int | Unset): Default: 16.
158
+ cursor (str | Unset):
159
+ fresh (bool | Unset): Default: False.
160
+
161
+ Raises:
162
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
163
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
164
+
165
+ Returns:
166
+ Error | VideoPage
167
+ """
168
+
169
+ return sync_detailed(
170
+ user=user,
171
+ client=client,
172
+ count=count,
173
+ cursor=cursor,
174
+ fresh=fresh,
175
+ ).parsed
176
+
177
+
178
+ async def asyncio_detailed(
179
+ user: str,
180
+ *,
181
+ client: AuthenticatedClient | Client,
182
+ count: int | Unset = 16,
183
+ cursor: str | Unset = UNSET,
184
+ fresh: bool | Unset = False,
185
+ ) -> Response[Error | VideoPage]:
186
+ """Videos of an account
187
+
188
+ Pinned videos first, then newest first. 1 credit per video. `user` is a username or a sec_uid; a
189
+ username is changed to the sec_uid through the profile, free. A private account gives an empty list,
190
+ free.
191
+
192
+ Args:
193
+ user (str):
194
+ count (int | Unset): Default: 16.
195
+ cursor (str | Unset):
196
+ fresh (bool | Unset): Default: False.
197
+
198
+ Raises:
199
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
200
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
201
+
202
+ Returns:
203
+ Response[Error | VideoPage]
204
+ """
205
+
206
+ kwargs = _get_kwargs(
207
+ user=user,
208
+ count=count,
209
+ cursor=cursor,
210
+ fresh=fresh,
211
+ )
212
+
213
+ response = await client.get_async_httpx_client().request(**kwargs)
214
+
215
+ return _build_response(client=client, response=response)
216
+
217
+
218
+ async def asyncio(
219
+ user: str,
220
+ *,
221
+ client: AuthenticatedClient | Client,
222
+ count: int | Unset = 16,
223
+ cursor: str | Unset = UNSET,
224
+ fresh: bool | Unset = False,
225
+ ) -> Error | VideoPage | None:
226
+ """Videos of an account
227
+
228
+ Pinned videos first, then newest first. 1 credit per video. `user` is a username or a sec_uid; a
229
+ username is changed to the sec_uid through the profile, free. A private account gives an empty list,
230
+ free.
231
+
232
+ Args:
233
+ user (str):
234
+ count (int | Unset): Default: 16.
235
+ cursor (str | Unset):
236
+ fresh (bool | Unset): Default: False.
237
+
238
+ Raises:
239
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
240
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
241
+
242
+ Returns:
243
+ Error | VideoPage
244
+ """
245
+
246
+ return (
247
+ await asyncio_detailed(
248
+ user=user,
249
+ client=client,
250
+ count=count,
251
+ cursor=cursor,
252
+ fresh=fresh,
253
+ )
254
+ ).parsed