xdataapi 0.3.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 (61) hide show
  1. xdataapi/__init__.py +8 -0
  2. xdataapi/api/__init__.py +1 -0
  3. xdataapi/api/account/__init__.py +1 -0
  4. xdataapi/api/account/get_me.py +144 -0
  5. xdataapi/api/billing/__init__.py +1 -0
  6. xdataapi/api/billing/create_checkout.py +206 -0
  7. xdataapi/api/billing/list_packs.py +144 -0
  8. xdataapi/api/tweets/__init__.py +1 -0
  9. xdataapi/api/tweets/get_quotes.py +241 -0
  10. xdataapi/api/tweets/get_replies.py +230 -0
  11. xdataapi/api/tweets/get_retweeters.py +245 -0
  12. xdataapi/api/tweets/get_thread.py +226 -0
  13. xdataapi/api/tweets/get_tweet.py +213 -0
  14. xdataapi/api/tweets/get_tweets.py +223 -0
  15. xdataapi/api/tweets/search_tweets.py +277 -0
  16. xdataapi/api/users/__init__.py +1 -0
  17. xdataapi/api/users/get_follower_ids.py +254 -0
  18. xdataapi/api/users/get_followers.py +254 -0
  19. xdataapi/api/users/get_following.py +246 -0
  20. xdataapi/api/users/get_user.py +213 -0
  21. xdataapi/api/users/get_user_tweets.py +241 -0
  22. xdataapi/api/users/get_users.py +231 -0
  23. xdataapi/client.py +268 -0
  24. xdataapi/errors.py +16 -0
  25. xdataapi/models/__init__.py +67 -0
  26. xdataapi/models/batch_error.py +79 -0
  27. xdataapi/models/batch_error_code.py +15 -0
  28. xdataapi/models/batch_meta.py +126 -0
  29. xdataapi/models/batch_meta_cache.py +11 -0
  30. xdataapi/models/create_checkout_body.py +63 -0
  31. xdataapi/models/create_checkout_body_pack.py +11 -0
  32. xdataapi/models/create_checkout_response_200.py +97 -0
  33. xdataapi/models/error.py +78 -0
  34. xdataapi/models/error_body.py +72 -0
  35. xdataapi/models/error_body_code.py +22 -0
  36. xdataapi/models/get_me_response_200.py +88 -0
  37. xdataapi/models/get_tweets_body.py +61 -0
  38. xdataapi/models/get_users_body.py +61 -0
  39. xdataapi/models/id_page.py +117 -0
  40. xdataapi/models/list_packs_response_200.py +105 -0
  41. xdataapi/models/list_packs_response_200_data_item.py +88 -0
  42. xdataapi/models/list_packs_response_200_rate_limits_item.py +70 -0
  43. xdataapi/models/media.py +96 -0
  44. xdataapi/models/media_type.py +10 -0
  45. xdataapi/models/meta.py +106 -0
  46. xdataapi/models/meta_cache.py +10 -0
  47. xdataapi/models/problem.py +131 -0
  48. xdataapi/models/search_tweets_product.py +12 -0
  49. xdataapi/models/tweet.py +310 -0
  50. xdataapi/models/tweet_batch.py +150 -0
  51. xdataapi/models/tweet_page.py +133 -0
  52. xdataapi/models/tweet_response.py +128 -0
  53. xdataapi/models/user.py +204 -0
  54. xdataapi/models/user_batch.py +150 -0
  55. xdataapi/models/user_page.py +133 -0
  56. xdataapi/models/user_response.py +128 -0
  57. xdataapi/py.typed +1 -0
  58. xdataapi/types.py +54 -0
  59. xdataapi-0.3.0.dist-info/METADATA +148 -0
  60. xdataapi-0.3.0.dist-info/RECORD +61 -0
  61. xdataapi-0.3.0.dist-info/WHEEL +4 -0
@@ -0,0 +1,128 @@
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.tweet import Tweet
15
+
16
+
17
+ T = TypeVar("T", bound="TweetResponse")
18
+
19
+
20
+ @_attrs_define
21
+ class TweetResponse:
22
+ """
23
+ Attributes:
24
+ items (int): Objects returned.
25
+ credits_charged (float): Example: 20.
26
+ balance_remaining (float): Example: 79980.
27
+ cache (MetaCache):
28
+ request_id (UUID):
29
+ next_cursor (str | Unset):
30
+ data (Tweet | Unset):
31
+ """
32
+
33
+ items: int
34
+ credits_charged: float
35
+ balance_remaining: float
36
+ cache: MetaCache
37
+ request_id: UUID
38
+ next_cursor: str | Unset = UNSET
39
+ data: Tweet | Unset = UNSET
40
+ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
41
+
42
+ def to_dict(self) -> dict[str, Any]:
43
+ items = self.items
44
+
45
+ credits_charged = self.credits_charged
46
+
47
+ balance_remaining = self.balance_remaining
48
+
49
+ cache = self.cache.value
50
+
51
+ request_id = str(self.request_id)
52
+
53
+ next_cursor = self.next_cursor
54
+
55
+ data: dict[str, Any] | Unset = UNSET
56
+ if not isinstance(self.data, Unset):
57
+ data = self.data.to_dict()
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
+ }
69
+ )
70
+ if next_cursor is not UNSET:
71
+ field_dict["next_cursor"] = next_cursor
72
+ if data is not UNSET:
73
+ field_dict["data"] = data
74
+
75
+ return field_dict
76
+
77
+ @classmethod
78
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
79
+ from ..models.tweet import Tweet # noqa: PLC0415
80
+
81
+ d = dict(src_dict)
82
+ items = d.pop("items")
83
+
84
+ credits_charged = d.pop("credits_charged")
85
+
86
+ balance_remaining = d.pop("balance_remaining")
87
+
88
+ cache = MetaCache(d.pop("cache"))
89
+
90
+ request_id = UUID(d.pop("request_id"))
91
+
92
+ next_cursor = d.pop("next_cursor", UNSET)
93
+
94
+ _data = d.pop("data", UNSET)
95
+ data: Tweet | Unset
96
+ if isinstance(_data, Unset):
97
+ data = UNSET
98
+ else:
99
+ data = Tweet.from_dict(_data)
100
+
101
+ tweet_response = cls(
102
+ items=items,
103
+ credits_charged=credits_charged,
104
+ balance_remaining=balance_remaining,
105
+ cache=cache,
106
+ request_id=request_id,
107
+ next_cursor=next_cursor,
108
+ data=data,
109
+ )
110
+
111
+ tweet_response.additional_properties = d
112
+ return tweet_response
113
+
114
+ @property
115
+ def additional_keys(self) -> list[str]:
116
+ return list(self.additional_properties.keys())
117
+
118
+ def __getitem__(self, key: str) -> Any:
119
+ return self.additional_properties[key]
120
+
121
+ def __setitem__(self, key: str, value: Any) -> None:
122
+ self.additional_properties[key] = value
123
+
124
+ def __delitem__(self, key: str) -> None:
125
+ del self.additional_properties[key]
126
+
127
+ def __contains__(self, key: str) -> bool:
128
+ return key in self.additional_properties
@@ -0,0 +1,204 @@
1
+ from __future__ import annotations
2
+
3
+ import datetime
4
+ from collections.abc import Mapping
5
+ from typing import Any, TypeVar, cast
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="User")
13
+
14
+
15
+ @_attrs_define
16
+ class User:
17
+ """
18
+ Attributes:
19
+ id (str): Example: 783214.
20
+ handle (str): Example: X.
21
+ name (str):
22
+ followers (int):
23
+ following (int):
24
+ tweets (int):
25
+ created_at (datetime.datetime):
26
+ bio (str | Unset):
27
+ location (str | Unset):
28
+ url (str | Unset):
29
+ avatar_url (str | Unset):
30
+ banner_url (str | Unset):
31
+ verified (bool | Unset):
32
+ protected (bool | Unset):
33
+ likes (int | Unset):
34
+ listed (int | Unset):
35
+ pinned_tweet_ids (list[str] | Unset):
36
+ """
37
+
38
+ id: str
39
+ handle: str
40
+ name: str
41
+ followers: int
42
+ following: int
43
+ tweets: int
44
+ created_at: datetime.datetime
45
+ bio: str | Unset = UNSET
46
+ location: str | Unset = UNSET
47
+ url: str | Unset = UNSET
48
+ avatar_url: str | Unset = UNSET
49
+ banner_url: str | Unset = UNSET
50
+ verified: bool | Unset = UNSET
51
+ protected: bool | Unset = UNSET
52
+ likes: int | Unset = UNSET
53
+ listed: int | Unset = UNSET
54
+ pinned_tweet_ids: list[str] | Unset = UNSET
55
+ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
56
+
57
+ def to_dict(self) -> dict[str, Any]:
58
+ id = self.id
59
+
60
+ handle = self.handle
61
+
62
+ name = self.name
63
+
64
+ followers = self.followers
65
+
66
+ following = self.following
67
+
68
+ tweets = self.tweets
69
+
70
+ created_at = self.created_at.isoformat()
71
+
72
+ bio = self.bio
73
+
74
+ location = self.location
75
+
76
+ url = self.url
77
+
78
+ avatar_url = self.avatar_url
79
+
80
+ banner_url = self.banner_url
81
+
82
+ verified = self.verified
83
+
84
+ protected = self.protected
85
+
86
+ likes = self.likes
87
+
88
+ listed = self.listed
89
+
90
+ pinned_tweet_ids: list[str] | Unset = UNSET
91
+ if not isinstance(self.pinned_tweet_ids, Unset):
92
+ pinned_tweet_ids = self.pinned_tweet_ids
93
+
94
+ field_dict: dict[str, Any] = {}
95
+ field_dict.update(self.additional_properties)
96
+ field_dict.update(
97
+ {
98
+ "id": id,
99
+ "handle": handle,
100
+ "name": name,
101
+ "followers": followers,
102
+ "following": following,
103
+ "tweets": tweets,
104
+ "created_at": created_at,
105
+ }
106
+ )
107
+ if bio is not UNSET:
108
+ field_dict["bio"] = bio
109
+ if location is not UNSET:
110
+ field_dict["location"] = location
111
+ if url is not UNSET:
112
+ field_dict["url"] = url
113
+ if avatar_url is not UNSET:
114
+ field_dict["avatar_url"] = avatar_url
115
+ if banner_url is not UNSET:
116
+ field_dict["banner_url"] = banner_url
117
+ if verified is not UNSET:
118
+ field_dict["verified"] = verified
119
+ if protected is not UNSET:
120
+ field_dict["protected"] = protected
121
+ if likes is not UNSET:
122
+ field_dict["likes"] = likes
123
+ if listed is not UNSET:
124
+ field_dict["listed"] = listed
125
+ if pinned_tweet_ids is not UNSET:
126
+ field_dict["pinned_tweet_ids"] = pinned_tweet_ids
127
+
128
+ return field_dict
129
+
130
+ @classmethod
131
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
132
+ d = dict(src_dict)
133
+ id = d.pop("id")
134
+
135
+ handle = d.pop("handle")
136
+
137
+ name = d.pop("name")
138
+
139
+ followers = d.pop("followers")
140
+
141
+ following = d.pop("following")
142
+
143
+ tweets = d.pop("tweets")
144
+
145
+ created_at = datetime.datetime.fromisoformat(d.pop("created_at"))
146
+
147
+ bio = d.pop("bio", UNSET)
148
+
149
+ location = d.pop("location", UNSET)
150
+
151
+ url = d.pop("url", UNSET)
152
+
153
+ avatar_url = d.pop("avatar_url", UNSET)
154
+
155
+ banner_url = d.pop("banner_url", UNSET)
156
+
157
+ verified = d.pop("verified", UNSET)
158
+
159
+ protected = d.pop("protected", UNSET)
160
+
161
+ likes = d.pop("likes", UNSET)
162
+
163
+ listed = d.pop("listed", UNSET)
164
+
165
+ pinned_tweet_ids = cast(list[str], d.pop("pinned_tweet_ids", UNSET))
166
+
167
+ user = cls(
168
+ id=id,
169
+ handle=handle,
170
+ name=name,
171
+ followers=followers,
172
+ following=following,
173
+ tweets=tweets,
174
+ created_at=created_at,
175
+ bio=bio,
176
+ location=location,
177
+ url=url,
178
+ avatar_url=avatar_url,
179
+ banner_url=banner_url,
180
+ verified=verified,
181
+ protected=protected,
182
+ likes=likes,
183
+ listed=listed,
184
+ pinned_tweet_ids=pinned_tweet_ids,
185
+ )
186
+
187
+ user.additional_properties = d
188
+ return user
189
+
190
+ @property
191
+ def additional_keys(self) -> list[str]:
192
+ return list(self.additional_properties.keys())
193
+
194
+ def __getitem__(self, key: str) -> Any:
195
+ return self.additional_properties[key]
196
+
197
+ def __setitem__(self, key: str, value: Any) -> None:
198
+ self.additional_properties[key] = value
199
+
200
+ def __delitem__(self, key: str) -> None:
201
+ del self.additional_properties[key]
202
+
203
+ def __contains__(self, key: str) -> bool:
204
+ return key in self.additional_properties
@@ -0,0 +1,150 @@
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.batch_meta_cache import BatchMetaCache
11
+ from ..types import UNSET, Unset
12
+
13
+ if TYPE_CHECKING:
14
+ from ..models.batch_error import BatchError
15
+ from ..models.user import User
16
+
17
+
18
+ T = TypeVar("T", bound="UserBatch")
19
+
20
+
21
+ @_attrs_define
22
+ class UserBatch:
23
+ """
24
+ Attributes:
25
+ errors (list[BatchError]): Inputs that returned nothing, with the reason. Never charged.
26
+ items (int): Objects returned.
27
+ credits_charged (float):
28
+ balance_remaining (float):
29
+ cache (BatchMetaCache):
30
+ cache_hits (int): Objects served from cache
31
+ request_id (UUID):
32
+ data (list[User] | Unset): Found profiles
33
+ """
34
+
35
+ errors: list[BatchError]
36
+ items: int
37
+ credits_charged: float
38
+ balance_remaining: float
39
+ cache: BatchMetaCache
40
+ cache_hits: int
41
+ request_id: UUID
42
+ data: list[User] | Unset = UNSET
43
+ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
44
+
45
+ def to_dict(self) -> dict[str, Any]:
46
+ errors = []
47
+ for errors_item_data in self.errors:
48
+ errors_item = errors_item_data.to_dict()
49
+ errors.append(errors_item)
50
+
51
+ items = self.items
52
+
53
+ credits_charged = self.credits_charged
54
+
55
+ balance_remaining = self.balance_remaining
56
+
57
+ cache = self.cache.value
58
+
59
+ cache_hits = self.cache_hits
60
+
61
+ request_id = str(self.request_id)
62
+
63
+ data: list[dict[str, Any]] | Unset = UNSET
64
+ if not isinstance(self.data, Unset):
65
+ data = []
66
+ for data_item_data in self.data:
67
+ data_item = data_item_data.to_dict()
68
+ data.append(data_item)
69
+
70
+ field_dict: dict[str, Any] = {}
71
+ field_dict.update(self.additional_properties)
72
+ field_dict.update(
73
+ {
74
+ "errors": errors,
75
+ "items": items,
76
+ "credits_charged": credits_charged,
77
+ "balance_remaining": balance_remaining,
78
+ "cache": cache,
79
+ "cache_hits": cache_hits,
80
+ "request_id": request_id,
81
+ }
82
+ )
83
+ if data is not UNSET:
84
+ field_dict["data"] = data
85
+
86
+ return field_dict
87
+
88
+ @classmethod
89
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
90
+ from ..models.batch_error import BatchError # noqa: PLC0415
91
+ from ..models.user import User # noqa: PLC0415
92
+
93
+ d = dict(src_dict)
94
+ errors = []
95
+ _errors = d.pop("errors")
96
+ for errors_item_data in _errors:
97
+ errors_item = BatchError.from_dict(errors_item_data)
98
+
99
+ errors.append(errors_item)
100
+
101
+ items = d.pop("items")
102
+
103
+ credits_charged = d.pop("credits_charged")
104
+
105
+ balance_remaining = d.pop("balance_remaining")
106
+
107
+ cache = BatchMetaCache(d.pop("cache"))
108
+
109
+ cache_hits = d.pop("cache_hits")
110
+
111
+ request_id = UUID(d.pop("request_id"))
112
+
113
+ _data = d.pop("data", UNSET)
114
+ data: list[User] | Unset = UNSET
115
+ if _data is not UNSET:
116
+ data = []
117
+ for data_item_data in _data:
118
+ data_item = User.from_dict(data_item_data)
119
+
120
+ data.append(data_item)
121
+
122
+ user_batch = cls(
123
+ errors=errors,
124
+ items=items,
125
+ credits_charged=credits_charged,
126
+ balance_remaining=balance_remaining,
127
+ cache=cache,
128
+ cache_hits=cache_hits,
129
+ request_id=request_id,
130
+ data=data,
131
+ )
132
+
133
+ user_batch.additional_properties = d
134
+ return user_batch
135
+
136
+ @property
137
+ def additional_keys(self) -> list[str]:
138
+ return list(self.additional_properties.keys())
139
+
140
+ def __getitem__(self, key: str) -> Any:
141
+ return self.additional_properties[key]
142
+
143
+ def __setitem__(self, key: str, value: Any) -> None:
144
+ self.additional_properties[key] = value
145
+
146
+ def __delitem__(self, key: str) -> None:
147
+ del self.additional_properties[key]
148
+
149
+ def __contains__(self, key: str) -> bool:
150
+ return key in self.additional_properties
@@ -0,0 +1,133 @@
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.user import User
15
+
16
+
17
+ T = TypeVar("T", bound="UserPage")
18
+
19
+
20
+ @_attrs_define
21
+ class UserPage:
22
+ """
23
+ Attributes:
24
+ items (int): Objects returned.
25
+ credits_charged (float): Example: 20.
26
+ balance_remaining (float): Example: 79980.
27
+ cache (MetaCache):
28
+ request_id (UUID):
29
+ next_cursor (str | Unset):
30
+ data (list[User] | Unset):
31
+ """
32
+
33
+ items: int
34
+ credits_charged: float
35
+ balance_remaining: float
36
+ cache: MetaCache
37
+ request_id: UUID
38
+ next_cursor: str | Unset = UNSET
39
+ data: list[User] | Unset = UNSET
40
+ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
41
+
42
+ def to_dict(self) -> dict[str, Any]:
43
+ items = self.items
44
+
45
+ credits_charged = self.credits_charged
46
+
47
+ balance_remaining = self.balance_remaining
48
+
49
+ cache = self.cache.value
50
+
51
+ request_id = str(self.request_id)
52
+
53
+ next_cursor = self.next_cursor
54
+
55
+ data: list[dict[str, Any]] | Unset = UNSET
56
+ if not isinstance(self.data, Unset):
57
+ data = []
58
+ for data_item_data in self.data:
59
+ data_item = data_item_data.to_dict()
60
+ data.append(data_item)
61
+
62
+ field_dict: dict[str, Any] = {}
63
+ field_dict.update(self.additional_properties)
64
+ field_dict.update(
65
+ {
66
+ "items": items,
67
+ "credits_charged": credits_charged,
68
+ "balance_remaining": balance_remaining,
69
+ "cache": cache,
70
+ "request_id": request_id,
71
+ }
72
+ )
73
+ if next_cursor is not UNSET:
74
+ field_dict["next_cursor"] = next_cursor
75
+ if data is not UNSET:
76
+ field_dict["data"] = data
77
+
78
+ return field_dict
79
+
80
+ @classmethod
81
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
82
+ from ..models.user import User # noqa: PLC0415
83
+
84
+ d = dict(src_dict)
85
+ items = d.pop("items")
86
+
87
+ credits_charged = d.pop("credits_charged")
88
+
89
+ balance_remaining = d.pop("balance_remaining")
90
+
91
+ cache = MetaCache(d.pop("cache"))
92
+
93
+ request_id = UUID(d.pop("request_id"))
94
+
95
+ next_cursor = d.pop("next_cursor", UNSET)
96
+
97
+ _data = d.pop("data", UNSET)
98
+ data: list[User] | Unset = UNSET
99
+ if _data is not UNSET:
100
+ data = []
101
+ for data_item_data in _data:
102
+ data_item = User.from_dict(data_item_data)
103
+
104
+ data.append(data_item)
105
+
106
+ user_page = cls(
107
+ items=items,
108
+ credits_charged=credits_charged,
109
+ balance_remaining=balance_remaining,
110
+ cache=cache,
111
+ request_id=request_id,
112
+ next_cursor=next_cursor,
113
+ data=data,
114
+ )
115
+
116
+ user_page.additional_properties = d
117
+ return user_page
118
+
119
+ @property
120
+ def additional_keys(self) -> list[str]:
121
+ return list(self.additional_properties.keys())
122
+
123
+ def __getitem__(self, key: str) -> Any:
124
+ return self.additional_properties[key]
125
+
126
+ def __setitem__(self, key: str, value: Any) -> None:
127
+ self.additional_properties[key] = value
128
+
129
+ def __delitem__(self, key: str) -> None:
130
+ del self.additional_properties[key]
131
+
132
+ def __contains__(self, key: str) -> bool:
133
+ return key in self.additional_properties