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,260 @@
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.comment_page import CommentPage
10
+ from ...models.error import Error
11
+ from ...types import UNSET, Response, Unset
12
+
13
+
14
+ def _get_kwargs(
15
+ id: str,
16
+ comment_id: str,
17
+ *,
18
+ count: int | Unset = 20,
19
+ cursor: str | Unset = UNSET,
20
+ fresh: bool | Unset = False,
21
+ ) -> dict[str, Any]:
22
+
23
+ params: dict[str, Any] = {}
24
+
25
+ params["count"] = count
26
+
27
+ params["cursor"] = cursor
28
+
29
+ params["fresh"] = fresh
30
+
31
+ params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
32
+
33
+ _kwargs: dict[str, Any] = {
34
+ "method": "get",
35
+ "url": "/v1/videos/{id}/comments/{comment_id}/replies".format(
36
+ id=quote(str(id), safe=""),
37
+ comment_id=quote(str(comment_id), safe=""),
38
+ ),
39
+ "params": params,
40
+ }
41
+
42
+ return _kwargs
43
+
44
+
45
+ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> CommentPage | Error | None:
46
+ if response.status_code == 200:
47
+ response_200 = CommentPage.from_dict(response.json())
48
+
49
+ return response_200
50
+
51
+ if response.status_code == 400:
52
+ response_400 = Error.from_dict(response.json())
53
+
54
+ return response_400
55
+
56
+ if response.status_code == 401:
57
+ response_401 = Error.from_dict(response.json())
58
+
59
+ return response_401
60
+
61
+ if response.status_code == 402:
62
+ response_402 = Error.from_dict(response.json())
63
+
64
+ return response_402
65
+
66
+ if response.status_code == 404:
67
+ response_404 = Error.from_dict(response.json())
68
+
69
+ return response_404
70
+
71
+ if response.status_code == 429:
72
+ response_429 = Error.from_dict(response.json())
73
+
74
+ return response_429
75
+
76
+ if response.status_code == 500:
77
+ response_500 = Error.from_dict(response.json())
78
+
79
+ return response_500
80
+
81
+ if response.status_code == 503:
82
+ response_503 = Error.from_dict(response.json())
83
+
84
+ return response_503
85
+
86
+ if client.raise_on_unexpected_status:
87
+ raise errors.UnexpectedStatus(response.status_code, response.content)
88
+ else:
89
+ return None
90
+
91
+
92
+ def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[CommentPage | Error]:
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
+ id: str,
103
+ comment_id: str,
104
+ *,
105
+ client: AuthenticatedClient | Client,
106
+ count: int | Unset = 20,
107
+ cursor: str | Unset = UNSET,
108
+ fresh: bool | Unset = False,
109
+ ) -> Response[CommentPage | Error]:
110
+ """Replies to a comment
111
+
112
+ 1 credit per reply, oldest first, as TikTok shows them under the comment.
113
+
114
+ Args:
115
+ id (str):
116
+ comment_id (str):
117
+ count (int | Unset): Default: 20.
118
+ cursor (str | Unset):
119
+ fresh (bool | Unset): Default: False.
120
+
121
+ Raises:
122
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
123
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
124
+
125
+ Returns:
126
+ Response[CommentPage | Error]
127
+ """
128
+
129
+ kwargs = _get_kwargs(
130
+ id=id,
131
+ comment_id=comment_id,
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
+ id: str,
146
+ comment_id: str,
147
+ *,
148
+ client: AuthenticatedClient | Client,
149
+ count: int | Unset = 20,
150
+ cursor: str | Unset = UNSET,
151
+ fresh: bool | Unset = False,
152
+ ) -> CommentPage | Error | None:
153
+ """Replies to a comment
154
+
155
+ 1 credit per reply, oldest first, as TikTok shows them under the comment.
156
+
157
+ Args:
158
+ id (str):
159
+ comment_id (str):
160
+ count (int | Unset): Default: 20.
161
+ cursor (str | Unset):
162
+ fresh (bool | Unset): Default: False.
163
+
164
+ Raises:
165
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
166
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
167
+
168
+ Returns:
169
+ CommentPage | Error
170
+ """
171
+
172
+ return sync_detailed(
173
+ id=id,
174
+ comment_id=comment_id,
175
+ client=client,
176
+ count=count,
177
+ cursor=cursor,
178
+ fresh=fresh,
179
+ ).parsed
180
+
181
+
182
+ async def asyncio_detailed(
183
+ id: str,
184
+ comment_id: str,
185
+ *,
186
+ client: AuthenticatedClient | Client,
187
+ count: int | Unset = 20,
188
+ cursor: str | Unset = UNSET,
189
+ fresh: bool | Unset = False,
190
+ ) -> Response[CommentPage | Error]:
191
+ """Replies to a comment
192
+
193
+ 1 credit per reply, oldest first, as TikTok shows them under the comment.
194
+
195
+ Args:
196
+ id (str):
197
+ comment_id (str):
198
+ count (int | Unset): Default: 20.
199
+ cursor (str | Unset):
200
+ fresh (bool | Unset): Default: False.
201
+
202
+ Raises:
203
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
204
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
205
+
206
+ Returns:
207
+ Response[CommentPage | Error]
208
+ """
209
+
210
+ kwargs = _get_kwargs(
211
+ id=id,
212
+ comment_id=comment_id,
213
+ count=count,
214
+ cursor=cursor,
215
+ fresh=fresh,
216
+ )
217
+
218
+ response = await client.get_async_httpx_client().request(**kwargs)
219
+
220
+ return _build_response(client=client, response=response)
221
+
222
+
223
+ async def asyncio(
224
+ id: str,
225
+ comment_id: str,
226
+ *,
227
+ client: AuthenticatedClient | Client,
228
+ count: int | Unset = 20,
229
+ cursor: str | Unset = UNSET,
230
+ fresh: bool | Unset = False,
231
+ ) -> CommentPage | Error | None:
232
+ """Replies to a comment
233
+
234
+ 1 credit per reply, oldest first, as TikTok shows them under the comment.
235
+
236
+ Args:
237
+ id (str):
238
+ comment_id (str):
239
+ count (int | Unset): Default: 20.
240
+ cursor (str | Unset):
241
+ fresh (bool | Unset): Default: False.
242
+
243
+ Raises:
244
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
245
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
246
+
247
+ Returns:
248
+ CommentPage | Error
249
+ """
250
+
251
+ return (
252
+ await asyncio_detailed(
253
+ id=id,
254
+ comment_id=comment_id,
255
+ client=client,
256
+ count=count,
257
+ cursor=cursor,
258
+ fresh=fresh,
259
+ )
260
+ ).parsed
@@ -0,0 +1,258 @@
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.comment_page import CommentPage
10
+ from ...models.error import Error
11
+ from ...types import UNSET, Response, Unset
12
+
13
+
14
+ def _get_kwargs(
15
+ id: 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/videos/{id}/comments".format(
35
+ id=quote(str(id), safe=""),
36
+ ),
37
+ "params": params,
38
+ }
39
+
40
+ return _kwargs
41
+
42
+
43
+ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> CommentPage | Error | None:
44
+ if response.status_code == 200:
45
+ response_200 = CommentPage.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[CommentPage | Error]:
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
+ id: str,
101
+ *,
102
+ client: AuthenticatedClient | Client,
103
+ count: int | Unset = 20,
104
+ cursor: str | Unset = UNSET,
105
+ fresh: bool | Unset = False,
106
+ ) -> Response[CommentPage | Error]:
107
+ """Comments of a video
108
+
109
+ 1 credit per comment, in the order of TikTok (pinned first, then the most relevant). Only the
110
+ comments
111
+ of the video; their replies are at `/v1/videos/{id}/comments/{comment_id}/replies`. A video with
112
+ comments turned off gives an empty list, free.
113
+
114
+ Args:
115
+ id (str):
116
+ count (int | Unset): Default: 20.
117
+ cursor (str | Unset):
118
+ fresh (bool | Unset): Default: False.
119
+
120
+ Raises:
121
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
122
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
123
+
124
+ Returns:
125
+ Response[CommentPage | Error]
126
+ """
127
+
128
+ kwargs = _get_kwargs(
129
+ id=id,
130
+ count=count,
131
+ cursor=cursor,
132
+ fresh=fresh,
133
+ )
134
+
135
+ response = client.get_httpx_client().request(
136
+ **kwargs,
137
+ )
138
+
139
+ return _build_response(client=client, response=response)
140
+
141
+
142
+ def sync(
143
+ id: str,
144
+ *,
145
+ client: AuthenticatedClient | Client,
146
+ count: int | Unset = 20,
147
+ cursor: str | Unset = UNSET,
148
+ fresh: bool | Unset = False,
149
+ ) -> CommentPage | Error | None:
150
+ """Comments of a video
151
+
152
+ 1 credit per comment, in the order of TikTok (pinned first, then the most relevant). Only the
153
+ comments
154
+ of the video; their replies are at `/v1/videos/{id}/comments/{comment_id}/replies`. A video with
155
+ comments turned off gives an empty list, free.
156
+
157
+ Args:
158
+ id (str):
159
+ count (int | Unset): Default: 20.
160
+ cursor (str | Unset):
161
+ fresh (bool | Unset): Default: False.
162
+
163
+ Raises:
164
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
165
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
166
+
167
+ Returns:
168
+ CommentPage | Error
169
+ """
170
+
171
+ return sync_detailed(
172
+ id=id,
173
+ client=client,
174
+ count=count,
175
+ cursor=cursor,
176
+ fresh=fresh,
177
+ ).parsed
178
+
179
+
180
+ async def asyncio_detailed(
181
+ id: str,
182
+ *,
183
+ client: AuthenticatedClient | Client,
184
+ count: int | Unset = 20,
185
+ cursor: str | Unset = UNSET,
186
+ fresh: bool | Unset = False,
187
+ ) -> Response[CommentPage | Error]:
188
+ """Comments of a video
189
+
190
+ 1 credit per comment, in the order of TikTok (pinned first, then the most relevant). Only the
191
+ comments
192
+ of the video; their replies are at `/v1/videos/{id}/comments/{comment_id}/replies`. A video with
193
+ comments turned off gives an empty list, free.
194
+
195
+ Args:
196
+ id (str):
197
+ count (int | Unset): Default: 20.
198
+ cursor (str | Unset):
199
+ fresh (bool | Unset): Default: False.
200
+
201
+ Raises:
202
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
203
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
204
+
205
+ Returns:
206
+ Response[CommentPage | Error]
207
+ """
208
+
209
+ kwargs = _get_kwargs(
210
+ id=id,
211
+ count=count,
212
+ cursor=cursor,
213
+ fresh=fresh,
214
+ )
215
+
216
+ response = await client.get_async_httpx_client().request(**kwargs)
217
+
218
+ return _build_response(client=client, response=response)
219
+
220
+
221
+ async def asyncio(
222
+ id: str,
223
+ *,
224
+ client: AuthenticatedClient | Client,
225
+ count: int | Unset = 20,
226
+ cursor: str | Unset = UNSET,
227
+ fresh: bool | Unset = False,
228
+ ) -> CommentPage | Error | None:
229
+ """Comments of a video
230
+
231
+ 1 credit per comment, in the order of TikTok (pinned first, then the most relevant). Only the
232
+ comments
233
+ of the video; their replies are at `/v1/videos/{id}/comments/{comment_id}/replies`. A video with
234
+ comments turned off gives an empty list, free.
235
+
236
+ Args:
237
+ id (str):
238
+ count (int | Unset): Default: 20.
239
+ cursor (str | Unset):
240
+ fresh (bool | Unset): Default: False.
241
+
242
+ Raises:
243
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
244
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
245
+
246
+ Returns:
247
+ CommentPage | Error
248
+ """
249
+
250
+ return (
251
+ await asyncio_detailed(
252
+ id=id,
253
+ client=client,
254
+ count=count,
255
+ cursor=cursor,
256
+ fresh=fresh,
257
+ )
258
+ ).parsed