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,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.transcript_response import TranscriptResponse
11
+ from ...types import UNSET, Response, Unset
12
+
13
+
14
+ def _get_kwargs(
15
+ id: str,
16
+ *,
17
+ lang: str | Unset = UNSET,
18
+ fresh: bool | Unset = False,
19
+ ) -> dict[str, Any]:
20
+
21
+ params: dict[str, Any] = {}
22
+
23
+ params["lang"] = lang
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}/transcript".format(
32
+ id=quote(str(id), safe=""),
33
+ ),
34
+ "params": params,
35
+ }
36
+
37
+ return _kwargs
38
+
39
+
40
+ def _parse_response(
41
+ *, client: AuthenticatedClient | Client, response: httpx.Response
42
+ ) -> Error | TranscriptResponse | None:
43
+ if response.status_code == 200:
44
+ response_200 = TranscriptResponse.from_dict(response.json())
45
+
46
+ return response_200
47
+
48
+ if response.status_code == 400:
49
+ response_400 = Error.from_dict(response.json())
50
+
51
+ return response_400
52
+
53
+ if response.status_code == 401:
54
+ response_401 = Error.from_dict(response.json())
55
+
56
+ return response_401
57
+
58
+ if response.status_code == 402:
59
+ response_402 = Error.from_dict(response.json())
60
+
61
+ return response_402
62
+
63
+ if response.status_code == 404:
64
+ response_404 = Error.from_dict(response.json())
65
+
66
+ return response_404
67
+
68
+ if response.status_code == 429:
69
+ response_429 = Error.from_dict(response.json())
70
+
71
+ return response_429
72
+
73
+ if response.status_code == 500:
74
+ response_500 = Error.from_dict(response.json())
75
+
76
+ return response_500
77
+
78
+ if response.status_code == 503:
79
+ response_503 = Error.from_dict(response.json())
80
+
81
+ return response_503
82
+
83
+ if client.raise_on_unexpected_status:
84
+ raise errors.UnexpectedStatus(response.status_code, response.content)
85
+ else:
86
+ return None
87
+
88
+
89
+ def _build_response(
90
+ *, client: AuthenticatedClient | Client, response: httpx.Response
91
+ ) -> Response[Error | TranscriptResponse]:
92
+ return Response(
93
+ status_code=HTTPStatus(response.status_code),
94
+ content=response.content,
95
+ headers=response.headers,
96
+ parsed=_parse_response(client=client, response=response),
97
+ )
98
+
99
+
100
+ def sync_detailed(
101
+ id: str,
102
+ *,
103
+ client: AuthenticatedClient | Client,
104
+ lang: str | Unset = UNSET,
105
+ fresh: bool | Unset = False,
106
+ ) -> Response[Error | TranscriptResponse]:
107
+ """Transcript of a video
108
+
109
+ The transcript of a video, from its subtitles on TikTok (most are made by the speech recognition of
110
+ TikTok): timed segments and the whole text. 1 credit. A video with no subtitles gives
111
+ `404 not_found` with reason `unavailable`, free.
112
+ New on 2026-12-03; its limits at TikTok are not measured yet.
113
+
114
+ Args:
115
+ id (str):
116
+ lang (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 | TranscriptResponse]
125
+ """
126
+
127
+ kwargs = _get_kwargs(
128
+ id=id,
129
+ lang=lang,
130
+ fresh=fresh,
131
+ )
132
+
133
+ response = client.get_httpx_client().request(
134
+ **kwargs,
135
+ )
136
+
137
+ return _build_response(client=client, response=response)
138
+
139
+
140
+ def sync(
141
+ id: str,
142
+ *,
143
+ client: AuthenticatedClient | Client,
144
+ lang: str | Unset = UNSET,
145
+ fresh: bool | Unset = False,
146
+ ) -> Error | TranscriptResponse | None:
147
+ """Transcript of a video
148
+
149
+ The transcript of a video, from its subtitles on TikTok (most are made by the speech recognition of
150
+ TikTok): timed segments and the whole text. 1 credit. A video with no subtitles gives
151
+ `404 not_found` with reason `unavailable`, free.
152
+ New on 2026-12-03; its limits at TikTok are not measured yet.
153
+
154
+ Args:
155
+ id (str):
156
+ lang (str | Unset):
157
+ fresh (bool | Unset): Default: False.
158
+
159
+ Raises:
160
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
161
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
162
+
163
+ Returns:
164
+ Error | TranscriptResponse
165
+ """
166
+
167
+ return sync_detailed(
168
+ id=id,
169
+ client=client,
170
+ lang=lang,
171
+ fresh=fresh,
172
+ ).parsed
173
+
174
+
175
+ async def asyncio_detailed(
176
+ id: str,
177
+ *,
178
+ client: AuthenticatedClient | Client,
179
+ lang: str | Unset = UNSET,
180
+ fresh: bool | Unset = False,
181
+ ) -> Response[Error | TranscriptResponse]:
182
+ """Transcript of a video
183
+
184
+ The transcript of a video, from its subtitles on TikTok (most are made by the speech recognition of
185
+ TikTok): timed segments and the whole text. 1 credit. A video with no subtitles gives
186
+ `404 not_found` with reason `unavailable`, free.
187
+ New on 2026-12-03; its limits at TikTok are not measured yet.
188
+
189
+ Args:
190
+ id (str):
191
+ lang (str | Unset):
192
+ fresh (bool | Unset): Default: False.
193
+
194
+ Raises:
195
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
196
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
197
+
198
+ Returns:
199
+ Response[Error | TranscriptResponse]
200
+ """
201
+
202
+ kwargs = _get_kwargs(
203
+ id=id,
204
+ lang=lang,
205
+ fresh=fresh,
206
+ )
207
+
208
+ response = await client.get_async_httpx_client().request(**kwargs)
209
+
210
+ return _build_response(client=client, response=response)
211
+
212
+
213
+ async def asyncio(
214
+ id: str,
215
+ *,
216
+ client: AuthenticatedClient | Client,
217
+ lang: str | Unset = UNSET,
218
+ fresh: bool | Unset = False,
219
+ ) -> Error | TranscriptResponse | None:
220
+ """Transcript of a video
221
+
222
+ The transcript of a video, from its subtitles on TikTok (most are made by the speech recognition of
223
+ TikTok): timed segments and the whole text. 1 credit. A video with no subtitles gives
224
+ `404 not_found` with reason `unavailable`, free.
225
+ New on 2026-12-03; its limits at TikTok are not measured yet.
226
+
227
+ Args:
228
+ id (str):
229
+ lang (str | Unset):
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 | TranscriptResponse
238
+ """
239
+
240
+ return (
241
+ await asyncio_detailed(
242
+ id=id,
243
+ client=client,
244
+ lang=lang,
245
+ fresh=fresh,
246
+ )
247
+ ).parsed
@@ -0,0 +1,235 @@
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.get_videos_body import GetVideosBody
10
+ from ...models.video_batch import VideoBatch
11
+ from ...types import UNSET, Response, Unset
12
+
13
+
14
+ def _get_kwargs(
15
+ *,
16
+ body: GetVideosBody,
17
+ fresh: bool | Unset = False,
18
+ ) -> dict[str, Any]:
19
+ headers: dict[str, Any] = {}
20
+
21
+ params: dict[str, Any] = {}
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": "post",
29
+ "url": "/v1/videos/batch",
30
+ "params": params,
31
+ }
32
+
33
+ _kwargs["json"] = body.to_dict()
34
+
35
+ headers["Content-Type"] = "application/json"
36
+
37
+ _kwargs["headers"] = headers
38
+ return _kwargs
39
+
40
+
41
+ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Error | VideoBatch | None:
42
+ if response.status_code == 200:
43
+ response_200 = VideoBatch.from_dict(response.json())
44
+
45
+ return response_200
46
+
47
+ if response.status_code == 400:
48
+ response_400 = Error.from_dict(response.json())
49
+
50
+ return response_400
51
+
52
+ if response.status_code == 401:
53
+ response_401 = Error.from_dict(response.json())
54
+
55
+ return response_401
56
+
57
+ if response.status_code == 402:
58
+ response_402 = Error.from_dict(response.json())
59
+
60
+ return response_402
61
+
62
+ if response.status_code == 429:
63
+ response_429 = Error.from_dict(response.json())
64
+
65
+ return response_429
66
+
67
+ if response.status_code == 500:
68
+ response_500 = Error.from_dict(response.json())
69
+
70
+ return response_500
71
+
72
+ if response.status_code == 503:
73
+ response_503 = Error.from_dict(response.json())
74
+
75
+ return response_503
76
+
77
+ if client.raise_on_unexpected_status:
78
+ raise errors.UnexpectedStatus(response.status_code, response.content)
79
+ else:
80
+ return None
81
+
82
+
83
+ def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Error | VideoBatch]:
84
+ return Response(
85
+ status_code=HTTPStatus(response.status_code),
86
+ content=response.content,
87
+ headers=response.headers,
88
+ parsed=_parse_response(client=client, response=response),
89
+ )
90
+
91
+
92
+ def sync_detailed(
93
+ *,
94
+ client: AuthenticatedClient | Client,
95
+ body: GetVideosBody,
96
+ fresh: bool | Unset = False,
97
+ ) -> Response[Error | VideoBatch]:
98
+ """Videos by id, batch
99
+
100
+ Up to 100 videos in one call. 1 credit per video found; deleted, private or removed videos are
101
+ listed in
102
+ `errors` with a `reason` and cost nothing. Results in input order. Also `GET
103
+ /v1/videos/batch?ids=1,2`.
104
+ When the balance covers only part of the list, the tail comes back as `no_credits` and is not
105
+ fetched.
106
+
107
+ Args:
108
+ fresh (bool | Unset): Default: False.
109
+ body (GetVideosBody):
110
+
111
+ Raises:
112
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
113
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
114
+
115
+ Returns:
116
+ Response[Error | VideoBatch]
117
+ """
118
+
119
+ kwargs = _get_kwargs(
120
+ body=body,
121
+ fresh=fresh,
122
+ )
123
+
124
+ response = client.get_httpx_client().request(
125
+ **kwargs,
126
+ )
127
+
128
+ return _build_response(client=client, response=response)
129
+
130
+
131
+ def sync(
132
+ *,
133
+ client: AuthenticatedClient | Client,
134
+ body: GetVideosBody,
135
+ fresh: bool | Unset = False,
136
+ ) -> Error | VideoBatch | None:
137
+ """Videos by id, batch
138
+
139
+ Up to 100 videos in one call. 1 credit per video found; deleted, private or removed videos are
140
+ listed in
141
+ `errors` with a `reason` and cost nothing. Results in input order. Also `GET
142
+ /v1/videos/batch?ids=1,2`.
143
+ When the balance covers only part of the list, the tail comes back as `no_credits` and is not
144
+ fetched.
145
+
146
+ Args:
147
+ fresh (bool | Unset): Default: False.
148
+ body (GetVideosBody):
149
+
150
+ Raises:
151
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
152
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
153
+
154
+ Returns:
155
+ Error | VideoBatch
156
+ """
157
+
158
+ return sync_detailed(
159
+ client=client,
160
+ body=body,
161
+ fresh=fresh,
162
+ ).parsed
163
+
164
+
165
+ async def asyncio_detailed(
166
+ *,
167
+ client: AuthenticatedClient | Client,
168
+ body: GetVideosBody,
169
+ fresh: bool | Unset = False,
170
+ ) -> Response[Error | VideoBatch]:
171
+ """Videos by id, batch
172
+
173
+ Up to 100 videos in one call. 1 credit per video found; deleted, private or removed videos are
174
+ listed in
175
+ `errors` with a `reason` and cost nothing. Results in input order. Also `GET
176
+ /v1/videos/batch?ids=1,2`.
177
+ When the balance covers only part of the list, the tail comes back as `no_credits` and is not
178
+ fetched.
179
+
180
+ Args:
181
+ fresh (bool | Unset): Default: False.
182
+ body (GetVideosBody):
183
+
184
+ Raises:
185
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
186
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
187
+
188
+ Returns:
189
+ Response[Error | VideoBatch]
190
+ """
191
+
192
+ kwargs = _get_kwargs(
193
+ body=body,
194
+ fresh=fresh,
195
+ )
196
+
197
+ response = await client.get_async_httpx_client().request(**kwargs)
198
+
199
+ return _build_response(client=client, response=response)
200
+
201
+
202
+ async def asyncio(
203
+ *,
204
+ client: AuthenticatedClient | Client,
205
+ body: GetVideosBody,
206
+ fresh: bool | Unset = False,
207
+ ) -> Error | VideoBatch | None:
208
+ """Videos by id, batch
209
+
210
+ Up to 100 videos in one call. 1 credit per video found; deleted, private or removed videos are
211
+ listed in
212
+ `errors` with a `reason` and cost nothing. Results in input order. Also `GET
213
+ /v1/videos/batch?ids=1,2`.
214
+ When the balance covers only part of the list, the tail comes back as `no_credits` and is not
215
+ fetched.
216
+
217
+ Args:
218
+ fresh (bool | Unset): Default: False.
219
+ body (GetVideosBody):
220
+
221
+ Raises:
222
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
223
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
224
+
225
+ Returns:
226
+ Error | VideoBatch
227
+ """
228
+
229
+ return (
230
+ await asyncio_detailed(
231
+ client=client,
232
+ body=body,
233
+ fresh=fresh,
234
+ )
235
+ ).parsed