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
+
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
+ query: str,
16
+ count: int | Unset = 12,
17
+ cursor: str | Unset = UNSET,
18
+ fresh: bool | Unset = False,
19
+ ) -> dict[str, Any]:
20
+
21
+ params: dict[str, Any] = {}
22
+
23
+ params["query"] = query
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/search/videos",
36
+ "params": params,
37
+ }
38
+
39
+ return _kwargs
40
+
41
+
42
+ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Error | VideoPage | None:
43
+ if response.status_code == 200:
44
+ response_200 = VideoPage.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 == 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(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Error | VideoPage]:
85
+ return Response(
86
+ status_code=HTTPStatus(response.status_code),
87
+ content=response.content,
88
+ headers=response.headers,
89
+ parsed=_parse_response(client=client, response=response),
90
+ )
91
+
92
+
93
+ def sync_detailed(
94
+ *,
95
+ client: AuthenticatedClient | Client,
96
+ query: str,
97
+ count: int | Unset = 12,
98
+ cursor: str | Unset = UNSET,
99
+ fresh: bool | Unset = False,
100
+ ) -> Response[Error | VideoPage]:
101
+ """Search videos
102
+
103
+ The videos that the general search of TikTok (the "Top" tab) finds for a query, in the order of
104
+ TikTok. 1 credit per video. A query with no result gives an empty list, free.
105
+ Videos only: for accounts, use `/v1/search/users`; for sounds, `/v1/search/music`; for live rooms,
106
+ `/v1/search/live`; for hashtags, `/v1/search/hashtags`. None of the filters or the sorting of the
107
+ Videos tab of search (TikTok ignores them for a logged-out visitor).
108
+ New on 2026-12-02. Not known yet: how many pages of one search TikTok gives.
109
+
110
+ Args:
111
+ query (str):
112
+ count (int | Unset): Default: 12.
113
+ cursor (str | Unset):
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
+ query=query,
126
+ count=count,
127
+ cursor=cursor,
128
+ fresh=fresh,
129
+ )
130
+
131
+ response = client.get_httpx_client().request(
132
+ **kwargs,
133
+ )
134
+
135
+ return _build_response(client=client, response=response)
136
+
137
+
138
+ def sync(
139
+ *,
140
+ client: AuthenticatedClient | Client,
141
+ query: str,
142
+ count: int | Unset = 12,
143
+ cursor: str | Unset = UNSET,
144
+ fresh: bool | Unset = False,
145
+ ) -> Error | VideoPage | None:
146
+ """Search videos
147
+
148
+ The videos that the general search of TikTok (the "Top" tab) finds for a query, in the order of
149
+ TikTok. 1 credit per video. A query with no result gives an empty list, free.
150
+ Videos only: for accounts, use `/v1/search/users`; for sounds, `/v1/search/music`; for live rooms,
151
+ `/v1/search/live`; for hashtags, `/v1/search/hashtags`. None of the filters or the sorting of the
152
+ Videos tab of search (TikTok ignores them for a logged-out visitor).
153
+ New on 2026-12-02. Not known yet: how many pages of one search TikTok gives.
154
+
155
+ Args:
156
+ query (str):
157
+ count (int | Unset): Default: 12.
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
+ client=client,
171
+ query=query,
172
+ count=count,
173
+ cursor=cursor,
174
+ fresh=fresh,
175
+ ).parsed
176
+
177
+
178
+ async def asyncio_detailed(
179
+ *,
180
+ client: AuthenticatedClient | Client,
181
+ query: str,
182
+ count: int | Unset = 12,
183
+ cursor: str | Unset = UNSET,
184
+ fresh: bool | Unset = False,
185
+ ) -> Response[Error | VideoPage]:
186
+ """Search videos
187
+
188
+ The videos that the general search of TikTok (the "Top" tab) finds for a query, in the order of
189
+ TikTok. 1 credit per video. A query with no result gives an empty list, free.
190
+ Videos only: for accounts, use `/v1/search/users`; for sounds, `/v1/search/music`; for live rooms,
191
+ `/v1/search/live`; for hashtags, `/v1/search/hashtags`. None of the filters or the sorting of the
192
+ Videos tab of search (TikTok ignores them for a logged-out visitor).
193
+ New on 2026-12-02. Not known yet: how many pages of one search TikTok gives.
194
+
195
+ Args:
196
+ query (str):
197
+ count (int | Unset): Default: 12.
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[Error | VideoPage]
207
+ """
208
+
209
+ kwargs = _get_kwargs(
210
+ query=query,
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
+ *,
223
+ client: AuthenticatedClient | Client,
224
+ query: str,
225
+ count: int | Unset = 12,
226
+ cursor: str | Unset = UNSET,
227
+ fresh: bool | Unset = False,
228
+ ) -> Error | VideoPage | None:
229
+ """Search videos
230
+
231
+ The videos that the general search of TikTok (the "Top" tab) finds for a query, in the order of
232
+ TikTok. 1 credit per video. A query with no result gives an empty list, free.
233
+ Videos only: for accounts, use `/v1/search/users`; for sounds, `/v1/search/music`; for live rooms,
234
+ `/v1/search/live`; for hashtags, `/v1/search/hashtags`. None of the filters or the sorting of the
235
+ Videos tab of search (TikTok ignores them for a logged-out visitor).
236
+ New on 2026-12-02. Not known yet: how many pages of one search TikTok gives.
237
+
238
+ Args:
239
+ query (str):
240
+ count (int | Unset): Default: 12.
241
+ cursor (str | Unset):
242
+ fresh (bool | Unset): Default: False.
243
+
244
+ Raises:
245
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
246
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
247
+
248
+ Returns:
249
+ Error | VideoPage
250
+ """
251
+
252
+ return (
253
+ await asyncio_detailed(
254
+ client=client,
255
+ query=query,
256
+ count=count,
257
+ cursor=cursor,
258
+ fresh=fresh,
259
+ )
260
+ ).parsed
@@ -0,0 +1 @@
1
+ """Contains endpoint functions for accessing the API"""
@@ -0,0 +1,222 @@
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.user_response import UserResponse
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}".format(
29
+ user=quote(str(user), safe=""),
30
+ ),
31
+ "params": params,
32
+ }
33
+
34
+ return _kwargs
35
+
36
+
37
+ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Error | UserResponse | None:
38
+ if response.status_code == 200:
39
+ response_200 = UserResponse.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 | UserResponse]:
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
+ user: str,
97
+ *,
98
+ client: AuthenticatedClient | Client,
99
+ fresh: bool | Unset = False,
100
+ ) -> Response[Error | UserResponse]:
101
+ """Profile by username
102
+
103
+ 1 credit per profile. `user` is a username (with or without `@`) or a sec_uid. The account whose
104
+ username is `batch` is at `/v1/users/@batch`.
105
+
106
+ Args:
107
+ user (str):
108
+ fresh (bool | Unset): Default: False.
109
+
110
+ Raises:
111
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
112
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
113
+
114
+ Returns:
115
+ Response[Error | UserResponse]
116
+ """
117
+
118
+ kwargs = _get_kwargs(
119
+ user=user,
120
+ fresh=fresh,
121
+ )
122
+
123
+ response = client.get_httpx_client().request(
124
+ **kwargs,
125
+ )
126
+
127
+ return _build_response(client=client, response=response)
128
+
129
+
130
+ def sync(
131
+ user: str,
132
+ *,
133
+ client: AuthenticatedClient | Client,
134
+ fresh: bool | Unset = False,
135
+ ) -> Error | UserResponse | None:
136
+ """Profile by username
137
+
138
+ 1 credit per profile. `user` is a username (with or without `@`) or a sec_uid. The account whose
139
+ username is `batch` is at `/v1/users/@batch`.
140
+
141
+ Args:
142
+ user (str):
143
+ fresh (bool | Unset): Default: False.
144
+
145
+ Raises:
146
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
147
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
148
+
149
+ Returns:
150
+ Error | UserResponse
151
+ """
152
+
153
+ return sync_detailed(
154
+ user=user,
155
+ client=client,
156
+ fresh=fresh,
157
+ ).parsed
158
+
159
+
160
+ async def asyncio_detailed(
161
+ user: str,
162
+ *,
163
+ client: AuthenticatedClient | Client,
164
+ fresh: bool | Unset = False,
165
+ ) -> Response[Error | UserResponse]:
166
+ """Profile by username
167
+
168
+ 1 credit per profile. `user` is a username (with or without `@`) or a sec_uid. The account whose
169
+ username is `batch` is at `/v1/users/@batch`.
170
+
171
+ Args:
172
+ user (str):
173
+ fresh (bool | Unset): Default: False.
174
+
175
+ Raises:
176
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
177
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
178
+
179
+ Returns:
180
+ Response[Error | UserResponse]
181
+ """
182
+
183
+ kwargs = _get_kwargs(
184
+ user=user,
185
+ fresh=fresh,
186
+ )
187
+
188
+ response = await client.get_async_httpx_client().request(**kwargs)
189
+
190
+ return _build_response(client=client, response=response)
191
+
192
+
193
+ async def asyncio(
194
+ user: str,
195
+ *,
196
+ client: AuthenticatedClient | Client,
197
+ fresh: bool | Unset = False,
198
+ ) -> Error | UserResponse | None:
199
+ """Profile by username
200
+
201
+ 1 credit per profile. `user` is a username (with or without `@`) or a sec_uid. The account whose
202
+ username is `batch` is at `/v1/users/@batch`.
203
+
204
+ Args:
205
+ user (str):
206
+ fresh (bool | Unset): Default: False.
207
+
208
+ Raises:
209
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
210
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
211
+
212
+ Returns:
213
+ Error | UserResponse
214
+ """
215
+
216
+ return (
217
+ await asyncio_detailed(
218
+ user=user,
219
+ client=client,
220
+ fresh=fresh,
221
+ )
222
+ ).parsed