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,107 @@
1
+ from __future__ import annotations
2
+
3
+ from collections.abc import Mapping
4
+ from typing import Any, TypeVar
5
+
6
+ from attrs import define as _attrs_define
7
+ from attrs import field as _attrs_field
8
+
9
+ from ..models.error_body_code import ErrorBodyCode
10
+ from ..models.not_found_reason import NotFoundReason
11
+ from ..types import UNSET, Unset
12
+
13
+ T = TypeVar("T", bound="ErrorBody")
14
+
15
+
16
+ @_attrs_define
17
+ class ErrorBody:
18
+ """The failure itself. `code` is stable; match on it, never on `message`.
19
+
20
+ Attributes:
21
+ code (ErrorBodyCode):
22
+ message (str):
23
+ top_up_url (str | Unset): Only on `no_credits`. The page where a pack is bought. Example:
24
+ https://tikdataapi.com/dashboard/billing.
25
+ reason (NotFoundReason | Unset): On each `not_found`, and only there: why the object is not there.
26
+ `nonexistent`: no such account,
27
+ video, comment, hashtag or sound, or it was deleted; TikTok does not tell those two apart. `banned`: TikTok
28
+ banned the account. `private`: a video that only some accounts may see. `removed`: TikTok removed
29
+ the video for a rule of TikTok. `unavailable`: any other reason, for example a video that TikTok does
30
+ not show in the country of our reader, or a video with no transcript. A private account is not a `not_found`:
31
+ its profile comes back
32
+ with `private: true`.
33
+ """
34
+
35
+ code: ErrorBodyCode
36
+ message: str
37
+ top_up_url: str | Unset = UNSET
38
+ reason: NotFoundReason | Unset = UNSET
39
+ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
40
+
41
+ def to_dict(self) -> dict[str, Any]:
42
+ code = self.code.value
43
+
44
+ message = self.message
45
+
46
+ top_up_url = self.top_up_url
47
+
48
+ reason: str | Unset = UNSET
49
+ if not isinstance(self.reason, Unset):
50
+ reason = self.reason.value
51
+
52
+ field_dict: dict[str, Any] = {}
53
+ field_dict.update(self.additional_properties)
54
+ field_dict.update(
55
+ {
56
+ "code": code,
57
+ "message": message,
58
+ }
59
+ )
60
+ if top_up_url is not UNSET:
61
+ field_dict["top_up_url"] = top_up_url
62
+ if reason is not UNSET:
63
+ field_dict["reason"] = reason
64
+
65
+ return field_dict
66
+
67
+ @classmethod
68
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
69
+ d = dict(src_dict)
70
+ code = ErrorBodyCode(d.pop("code"))
71
+
72
+ message = d.pop("message")
73
+
74
+ top_up_url = d.pop("top_up_url", UNSET)
75
+
76
+ _reason = d.pop("reason", UNSET)
77
+ reason: NotFoundReason | Unset
78
+ if isinstance(_reason, Unset):
79
+ reason = UNSET
80
+ else:
81
+ reason = NotFoundReason(_reason)
82
+
83
+ error_body = cls(
84
+ code=code,
85
+ message=message,
86
+ top_up_url=top_up_url,
87
+ reason=reason,
88
+ )
89
+
90
+ error_body.additional_properties = d
91
+ return error_body
92
+
93
+ @property
94
+ def additional_keys(self) -> list[str]:
95
+ return list(self.additional_properties.keys())
96
+
97
+ def __getitem__(self, key: str) -> Any:
98
+ return self.additional_properties[key]
99
+
100
+ def __setitem__(self, key: str, value: Any) -> None:
101
+ self.additional_properties[key] = value
102
+
103
+ def __delitem__(self, key: str) -> None:
104
+ del self.additional_properties[key]
105
+
106
+ def __contains__(self, key: str) -> bool:
107
+ return key in self.additional_properties
@@ -0,0 +1,22 @@
1
+ from enum import StrEnum
2
+
3
+
4
+ class ErrorBodyCode(StrEnum):
5
+ ACCESS_DENIED = "access_denied"
6
+ BAD_REQUEST = "bad_request"
7
+ BILLING_DISABLED = "billing_disabled"
8
+ BUSY = "busy"
9
+ EMAIL_NOT_ALLOWED = "email_not_allowed"
10
+ INTERNAL = "internal"
11
+ INVALID_KEY = "invalid_key"
12
+ MISSING_KEY = "missing_key"
13
+ NOT_FOUND = "not_found"
14
+ NO_CREDITS = "no_credits"
15
+ OWNER_ONLY = "owner_only"
16
+ RATE_LIMITED = "rate_limited"
17
+ REQUEST_REJECTED = "request_rejected"
18
+ UPSTREAM_ERROR = "upstream_error"
19
+ UPSTREAM_RATE_LIMITED = "upstream_rate_limited"
20
+
21
+ def __str__(self) -> str:
22
+ return str(self.value)
@@ -0,0 +1,88 @@
1
+ from __future__ import annotations
2
+
3
+ from collections.abc import Mapping
4
+ from typing import Any, TypeVar
5
+
6
+ from attrs import define as _attrs_define
7
+ from attrs import field as _attrs_field
8
+
9
+ from ..types import UNSET, Unset
10
+
11
+ T = TypeVar("T", bound="GetMeResponse200")
12
+
13
+
14
+ @_attrs_define
15
+ class GetMeResponse200:
16
+ """
17
+ Attributes:
18
+ customer_id (str | Unset):
19
+ key_prefix (str | Unset):
20
+ balance (float | Unset):
21
+ rate_limit_qps (int | Unset):
22
+ """
23
+
24
+ customer_id: str | Unset = UNSET
25
+ key_prefix: str | Unset = UNSET
26
+ balance: float | Unset = UNSET
27
+ rate_limit_qps: int | Unset = UNSET
28
+ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
29
+
30
+ def to_dict(self) -> dict[str, Any]:
31
+ customer_id = self.customer_id
32
+
33
+ key_prefix = self.key_prefix
34
+
35
+ balance = self.balance
36
+
37
+ rate_limit_qps = self.rate_limit_qps
38
+
39
+ field_dict: dict[str, Any] = {}
40
+ field_dict.update(self.additional_properties)
41
+ field_dict.update({})
42
+ if customer_id is not UNSET:
43
+ field_dict["customer_id"] = customer_id
44
+ if key_prefix is not UNSET:
45
+ field_dict["key_prefix"] = key_prefix
46
+ if balance is not UNSET:
47
+ field_dict["balance"] = balance
48
+ if rate_limit_qps is not UNSET:
49
+ field_dict["rate_limit_qps"] = rate_limit_qps
50
+
51
+ return field_dict
52
+
53
+ @classmethod
54
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
55
+ d = dict(src_dict)
56
+ customer_id = d.pop("customer_id", UNSET)
57
+
58
+ key_prefix = d.pop("key_prefix", UNSET)
59
+
60
+ balance = d.pop("balance", UNSET)
61
+
62
+ rate_limit_qps = d.pop("rate_limit_qps", UNSET)
63
+
64
+ get_me_response_200 = cls(
65
+ customer_id=customer_id,
66
+ key_prefix=key_prefix,
67
+ balance=balance,
68
+ rate_limit_qps=rate_limit_qps,
69
+ )
70
+
71
+ get_me_response_200.additional_properties = d
72
+ return get_me_response_200
73
+
74
+ @property
75
+ def additional_keys(self) -> list[str]:
76
+ return list(self.additional_properties.keys())
77
+
78
+ def __getitem__(self, key: str) -> Any:
79
+ return self.additional_properties[key]
80
+
81
+ def __setitem__(self, key: str, value: Any) -> None:
82
+ self.additional_properties[key] = value
83
+
84
+ def __delitem__(self, key: str) -> None:
85
+ del self.additional_properties[key]
86
+
87
+ def __contains__(self, key: str) -> bool:
88
+ return key in self.additional_properties
@@ -0,0 +1,61 @@
1
+ from __future__ import annotations
2
+
3
+ from collections.abc import Mapping
4
+ from typing import Any, TypeVar, cast
5
+
6
+ from attrs import define as _attrs_define
7
+ from attrs import field as _attrs_field
8
+
9
+ T = TypeVar("T", bound="GetUsersBody")
10
+
11
+
12
+ @_attrs_define
13
+ class GetUsersBody:
14
+ """
15
+ Attributes:
16
+ usernames (list[str]): Example: ['tiktok', 'nba', 'espn'].
17
+ """
18
+
19
+ usernames: list[str]
20
+ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
21
+
22
+ def to_dict(self) -> dict[str, Any]:
23
+ usernames = self.usernames
24
+
25
+ field_dict: dict[str, Any] = {}
26
+ field_dict.update(self.additional_properties)
27
+ field_dict.update(
28
+ {
29
+ "usernames": usernames,
30
+ }
31
+ )
32
+
33
+ return field_dict
34
+
35
+ @classmethod
36
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
37
+ d = dict(src_dict)
38
+ usernames = cast(list[str], d.pop("usernames"))
39
+
40
+ get_users_body = cls(
41
+ usernames=usernames,
42
+ )
43
+
44
+ get_users_body.additional_properties = d
45
+ return get_users_body
46
+
47
+ @property
48
+ def additional_keys(self) -> list[str]:
49
+ return list(self.additional_properties.keys())
50
+
51
+ def __getitem__(self, key: str) -> Any:
52
+ return self.additional_properties[key]
53
+
54
+ def __setitem__(self, key: str, value: Any) -> None:
55
+ self.additional_properties[key] = value
56
+
57
+ def __delitem__(self, key: str) -> None:
58
+ del self.additional_properties[key]
59
+
60
+ def __contains__(self, key: str) -> bool:
61
+ return key in self.additional_properties
@@ -0,0 +1,72 @@
1
+ from __future__ import annotations
2
+
3
+ from collections.abc import Mapping
4
+ from typing import Any, TypeVar, cast
5
+
6
+ from attrs import define as _attrs_define
7
+ from attrs import field as _attrs_field
8
+
9
+ from ..types import UNSET, Unset
10
+
11
+ T = TypeVar("T", bound="GetUsersVideosBody")
12
+
13
+
14
+ @_attrs_define
15
+ class GetUsersVideosBody:
16
+ """
17
+ Attributes:
18
+ users (list[str]): Usernames or sec_uids. Example: ['tiktok', 'nba'].
19
+ count (int | Unset): Videos for each account. Default: 3.
20
+ """
21
+
22
+ users: list[str]
23
+ count: int | Unset = 3
24
+ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
25
+
26
+ def to_dict(self) -> dict[str, Any]:
27
+ users = self.users
28
+
29
+ count = self.count
30
+
31
+ field_dict: dict[str, Any] = {}
32
+ field_dict.update(self.additional_properties)
33
+ field_dict.update(
34
+ {
35
+ "users": users,
36
+ }
37
+ )
38
+ if count is not UNSET:
39
+ field_dict["count"] = count
40
+
41
+ return field_dict
42
+
43
+ @classmethod
44
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
45
+ d = dict(src_dict)
46
+ users = cast(list[str], d.pop("users"))
47
+
48
+ count = d.pop("count", UNSET)
49
+
50
+ get_users_videos_body = cls(
51
+ users=users,
52
+ count=count,
53
+ )
54
+
55
+ get_users_videos_body.additional_properties = d
56
+ return get_users_videos_body
57
+
58
+ @property
59
+ def additional_keys(self) -> list[str]:
60
+ return list(self.additional_properties.keys())
61
+
62
+ def __getitem__(self, key: str) -> Any:
63
+ return self.additional_properties[key]
64
+
65
+ def __setitem__(self, key: str, value: Any) -> None:
66
+ self.additional_properties[key] = value
67
+
68
+ def __delitem__(self, key: str) -> None:
69
+ del self.additional_properties[key]
70
+
71
+ def __contains__(self, key: str) -> bool:
72
+ return key in self.additional_properties
@@ -0,0 +1,61 @@
1
+ from __future__ import annotations
2
+
3
+ from collections.abc import Mapping
4
+ from typing import Any, TypeVar, cast
5
+
6
+ from attrs import define as _attrs_define
7
+ from attrs import field as _attrs_field
8
+
9
+ T = TypeVar("T", bound="GetVideosBody")
10
+
11
+
12
+ @_attrs_define
13
+ class GetVideosBody:
14
+ """
15
+ Attributes:
16
+ ids (list[str]): Example: ['7106594312292453675'].
17
+ """
18
+
19
+ ids: list[str]
20
+ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
21
+
22
+ def to_dict(self) -> dict[str, Any]:
23
+ ids = self.ids
24
+
25
+ field_dict: dict[str, Any] = {}
26
+ field_dict.update(self.additional_properties)
27
+ field_dict.update(
28
+ {
29
+ "ids": ids,
30
+ }
31
+ )
32
+
33
+ return field_dict
34
+
35
+ @classmethod
36
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
37
+ d = dict(src_dict)
38
+ ids = cast(list[str], d.pop("ids"))
39
+
40
+ get_videos_body = cls(
41
+ ids=ids,
42
+ )
43
+
44
+ get_videos_body.additional_properties = d
45
+ return get_videos_body
46
+
47
+ @property
48
+ def additional_keys(self) -> list[str]:
49
+ return list(self.additional_properties.keys())
50
+
51
+ def __getitem__(self, key: str) -> Any:
52
+ return self.additional_properties[key]
53
+
54
+ def __setitem__(self, key: str, value: Any) -> None:
55
+ self.additional_properties[key] = value
56
+
57
+ def __delitem__(self, key: str) -> None:
58
+ del self.additional_properties[key]
59
+
60
+ def __contains__(self, key: str) -> bool:
61
+ return key in self.additional_properties
@@ -0,0 +1,124 @@
1
+ from __future__ import annotations
2
+
3
+ import datetime
4
+ from collections.abc import Mapping
5
+ from typing import Any, TypeVar
6
+
7
+ from attrs import define as _attrs_define
8
+ from attrs import field as _attrs_field
9
+
10
+ from ..types import UNSET, Unset
11
+
12
+ T = TypeVar("T", bound="Hashtag")
13
+
14
+
15
+ @_attrs_define
16
+ class Hashtag:
17
+ """
18
+ Attributes:
19
+ id (str): Example: 1636.
20
+ name (str): Without `#`. Example: fyp.
21
+ videos (int): Videos with this hashtag.
22
+ views (int): Plays of all videos with this hashtag.
23
+ collected_at (datetime.datetime): When we read this hashtag from TikTok. A hashtag from cache keeps the time of
24
+ its own read. Example: 2026-12-02T08:55:12Z.
25
+ url (str | Unset): Example: https://www.tiktok.com/tag/fyp.
26
+ description (str | Unset):
27
+ cover_url (str | Unset): Signed address; it stops working after some days.
28
+ """
29
+
30
+ id: str
31
+ name: str
32
+ videos: int
33
+ views: int
34
+ collected_at: datetime.datetime
35
+ url: str | Unset = UNSET
36
+ description: str | Unset = UNSET
37
+ cover_url: str | Unset = UNSET
38
+ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
39
+
40
+ def to_dict(self) -> dict[str, Any]:
41
+ id = self.id
42
+
43
+ name = self.name
44
+
45
+ videos = self.videos
46
+
47
+ views = self.views
48
+
49
+ collected_at = self.collected_at.isoformat()
50
+
51
+ url = self.url
52
+
53
+ description = self.description
54
+
55
+ cover_url = self.cover_url
56
+
57
+ field_dict: dict[str, Any] = {}
58
+ field_dict.update(self.additional_properties)
59
+ field_dict.update(
60
+ {
61
+ "id": id,
62
+ "name": name,
63
+ "videos": videos,
64
+ "views": views,
65
+ "collected_at": collected_at,
66
+ }
67
+ )
68
+ if url is not UNSET:
69
+ field_dict["url"] = url
70
+ if description is not UNSET:
71
+ field_dict["description"] = description
72
+ if cover_url is not UNSET:
73
+ field_dict["cover_url"] = cover_url
74
+
75
+ return field_dict
76
+
77
+ @classmethod
78
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
79
+ d = dict(src_dict)
80
+ id = d.pop("id")
81
+
82
+ name = d.pop("name")
83
+
84
+ videos = d.pop("videos")
85
+
86
+ views = d.pop("views")
87
+
88
+ collected_at = datetime.datetime.fromisoformat(d.pop("collected_at"))
89
+
90
+ url = d.pop("url", UNSET)
91
+
92
+ description = d.pop("description", UNSET)
93
+
94
+ cover_url = d.pop("cover_url", UNSET)
95
+
96
+ hashtag = cls(
97
+ id=id,
98
+ name=name,
99
+ videos=videos,
100
+ views=views,
101
+ collected_at=collected_at,
102
+ url=url,
103
+ description=description,
104
+ cover_url=cover_url,
105
+ )
106
+
107
+ hashtag.additional_properties = d
108
+ return hashtag
109
+
110
+ @property
111
+ def additional_keys(self) -> list[str]:
112
+ return list(self.additional_properties.keys())
113
+
114
+ def __getitem__(self, key: str) -> Any:
115
+ return self.additional_properties[key]
116
+
117
+ def __setitem__(self, key: str, value: Any) -> None:
118
+ self.additional_properties[key] = value
119
+
120
+ def __delitem__(self, key: str) -> None:
121
+ del self.additional_properties[key]
122
+
123
+ def __contains__(self, key: str) -> bool:
124
+ return key in self.additional_properties
@@ -0,0 +1,122 @@
1
+ from __future__ import annotations
2
+
3
+ from collections.abc import Mapping
4
+ from typing import TYPE_CHECKING, Any, TypeVar
5
+ from uuid import UUID
6
+
7
+ from attrs import define as _attrs_define
8
+ from attrs import field as _attrs_field
9
+
10
+ from ..models.meta_cache import MetaCache
11
+ from ..types import UNSET, Unset
12
+
13
+ if TYPE_CHECKING:
14
+ from ..models.hashtag import Hashtag
15
+
16
+
17
+ T = TypeVar("T", bound="HashtagResponse")
18
+
19
+
20
+ @_attrs_define
21
+ class HashtagResponse:
22
+ """
23
+ Attributes:
24
+ items (int): Objects returned.
25
+ credits_charged (float): Example: 16.
26
+ balance_remaining (float): Example: 79984.
27
+ cache (MetaCache): `miss`: read from TikTok, normal price. `hit`: from cache, half price. `bypass`: `fresh=true`
28
+ skipped a cached copy, 2x. A page that has cached and new items is `miss` (or `bypass`), and each item costs the
29
+ price of its own source; `hit` means all of it came from cache.
30
+ request_id (UUID):
31
+ data (Hashtag):
32
+ next_cursor (str | Unset):
33
+ """
34
+
35
+ items: int
36
+ credits_charged: float
37
+ balance_remaining: float
38
+ cache: MetaCache
39
+ request_id: UUID
40
+ data: Hashtag
41
+ next_cursor: str | Unset = UNSET
42
+ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
43
+
44
+ def to_dict(self) -> dict[str, Any]:
45
+ items = self.items
46
+
47
+ credits_charged = self.credits_charged
48
+
49
+ balance_remaining = self.balance_remaining
50
+
51
+ cache = self.cache.value
52
+
53
+ request_id = str(self.request_id)
54
+
55
+ data = self.data.to_dict()
56
+
57
+ next_cursor = self.next_cursor
58
+
59
+ field_dict: dict[str, Any] = {}
60
+ field_dict.update(self.additional_properties)
61
+ field_dict.update(
62
+ {
63
+ "items": items,
64
+ "credits_charged": credits_charged,
65
+ "balance_remaining": balance_remaining,
66
+ "cache": cache,
67
+ "request_id": request_id,
68
+ "data": data,
69
+ }
70
+ )
71
+ if next_cursor is not UNSET:
72
+ field_dict["next_cursor"] = next_cursor
73
+
74
+ return field_dict
75
+
76
+ @classmethod
77
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
78
+ from ..models.hashtag import Hashtag # noqa: PLC0415
79
+
80
+ d = dict(src_dict)
81
+ items = d.pop("items")
82
+
83
+ credits_charged = d.pop("credits_charged")
84
+
85
+ balance_remaining = d.pop("balance_remaining")
86
+
87
+ cache = MetaCache(d.pop("cache"))
88
+
89
+ request_id = UUID(d.pop("request_id"))
90
+
91
+ data = Hashtag.from_dict(d.pop("data"))
92
+
93
+ next_cursor = d.pop("next_cursor", UNSET)
94
+
95
+ hashtag_response = cls(
96
+ items=items,
97
+ credits_charged=credits_charged,
98
+ balance_remaining=balance_remaining,
99
+ cache=cache,
100
+ request_id=request_id,
101
+ data=data,
102
+ next_cursor=next_cursor,
103
+ )
104
+
105
+ hashtag_response.additional_properties = d
106
+ return hashtag_response
107
+
108
+ @property
109
+ def additional_keys(self) -> list[str]:
110
+ return list(self.additional_properties.keys())
111
+
112
+ def __getitem__(self, key: str) -> Any:
113
+ return self.additional_properties[key]
114
+
115
+ def __setitem__(self, key: str, value: Any) -> None:
116
+ self.additional_properties[key] = value
117
+
118
+ def __delitem__(self, key: str) -> None:
119
+ del self.additional_properties[key]
120
+
121
+ def __contains__(self, key: str) -> bool:
122
+ return key in self.additional_properties