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,310 @@
1
+ from __future__ import annotations
2
+
3
+ import datetime
4
+ from collections.abc import Mapping
5
+ from typing import TYPE_CHECKING, 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
+ if TYPE_CHECKING:
13
+ from ..models.media import Media
14
+ from ..models.user import User
15
+
16
+
17
+ T = TypeVar("T", bound="Tweet")
18
+
19
+
20
+ @_attrs_define
21
+ class Tweet:
22
+ """
23
+ Attributes:
24
+ id (str): Example: 20.
25
+ text (str):
26
+ created_at (datetime.datetime):
27
+ author_id (str):
28
+ lang (str | Unset):
29
+ author (User | Unset):
30
+ conversation_id (str | Unset):
31
+ in_reply_to_id (str | Unset):
32
+ in_reply_to_user_id (str | Unset):
33
+ quoted_id (str | Unset):
34
+ retweeted_id (str | Unset):
35
+ replies (int | Unset):
36
+ retweets (int | Unset):
37
+ likes (int | Unset):
38
+ quotes (int | Unset):
39
+ bookmarks (int | Unset):
40
+ views (int | Unset):
41
+ media (list[Media] | Unset):
42
+ urls (list[str] | Unset):
43
+ hashtags (list[str] | Unset):
44
+ mentions (list[str] | Unset):
45
+ is_retweet (bool | Unset):
46
+ is_quote (bool | Unset):
47
+ is_reply (bool | Unset):
48
+ source (str | Unset):
49
+ """
50
+
51
+ id: str
52
+ text: str
53
+ created_at: datetime.datetime
54
+ author_id: str
55
+ lang: str | Unset = UNSET
56
+ author: User | Unset = UNSET
57
+ conversation_id: str | Unset = UNSET
58
+ in_reply_to_id: str | Unset = UNSET
59
+ in_reply_to_user_id: str | Unset = UNSET
60
+ quoted_id: str | Unset = UNSET
61
+ retweeted_id: str | Unset = UNSET
62
+ replies: int | Unset = UNSET
63
+ retweets: int | Unset = UNSET
64
+ likes: int | Unset = UNSET
65
+ quotes: int | Unset = UNSET
66
+ bookmarks: int | Unset = UNSET
67
+ views: int | Unset = UNSET
68
+ media: list[Media] | Unset = UNSET
69
+ urls: list[str] | Unset = UNSET
70
+ hashtags: list[str] | Unset = UNSET
71
+ mentions: list[str] | Unset = UNSET
72
+ is_retweet: bool | Unset = UNSET
73
+ is_quote: bool | Unset = UNSET
74
+ is_reply: bool | Unset = UNSET
75
+ source: str | Unset = UNSET
76
+ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
77
+
78
+ def to_dict(self) -> dict[str, Any]:
79
+ id = self.id
80
+
81
+ text = self.text
82
+
83
+ created_at = self.created_at.isoformat()
84
+
85
+ author_id = self.author_id
86
+
87
+ lang = self.lang
88
+
89
+ author: dict[str, Any] | Unset = UNSET
90
+ if not isinstance(self.author, Unset):
91
+ author = self.author.to_dict()
92
+
93
+ conversation_id = self.conversation_id
94
+
95
+ in_reply_to_id = self.in_reply_to_id
96
+
97
+ in_reply_to_user_id = self.in_reply_to_user_id
98
+
99
+ quoted_id = self.quoted_id
100
+
101
+ retweeted_id = self.retweeted_id
102
+
103
+ replies = self.replies
104
+
105
+ retweets = self.retweets
106
+
107
+ likes = self.likes
108
+
109
+ quotes = self.quotes
110
+
111
+ bookmarks = self.bookmarks
112
+
113
+ views = self.views
114
+
115
+ media: list[dict[str, Any]] | Unset = UNSET
116
+ if not isinstance(self.media, Unset):
117
+ media = []
118
+ for media_item_data in self.media:
119
+ media_item = media_item_data.to_dict()
120
+ media.append(media_item)
121
+
122
+ urls: list[str] | Unset = UNSET
123
+ if not isinstance(self.urls, Unset):
124
+ urls = self.urls
125
+
126
+ hashtags: list[str] | Unset = UNSET
127
+ if not isinstance(self.hashtags, Unset):
128
+ hashtags = self.hashtags
129
+
130
+ mentions: list[str] | Unset = UNSET
131
+ if not isinstance(self.mentions, Unset):
132
+ mentions = self.mentions
133
+
134
+ is_retweet = self.is_retweet
135
+
136
+ is_quote = self.is_quote
137
+
138
+ is_reply = self.is_reply
139
+
140
+ source = self.source
141
+
142
+ field_dict: dict[str, Any] = {}
143
+ field_dict.update(self.additional_properties)
144
+ field_dict.update(
145
+ {
146
+ "id": id,
147
+ "text": text,
148
+ "created_at": created_at,
149
+ "author_id": author_id,
150
+ }
151
+ )
152
+ if lang is not UNSET:
153
+ field_dict["lang"] = lang
154
+ if author is not UNSET:
155
+ field_dict["author"] = author
156
+ if conversation_id is not UNSET:
157
+ field_dict["conversation_id"] = conversation_id
158
+ if in_reply_to_id is not UNSET:
159
+ field_dict["in_reply_to_id"] = in_reply_to_id
160
+ if in_reply_to_user_id is not UNSET:
161
+ field_dict["in_reply_to_user_id"] = in_reply_to_user_id
162
+ if quoted_id is not UNSET:
163
+ field_dict["quoted_id"] = quoted_id
164
+ if retweeted_id is not UNSET:
165
+ field_dict["retweeted_id"] = retweeted_id
166
+ if replies is not UNSET:
167
+ field_dict["replies"] = replies
168
+ if retweets is not UNSET:
169
+ field_dict["retweets"] = retweets
170
+ if likes is not UNSET:
171
+ field_dict["likes"] = likes
172
+ if quotes is not UNSET:
173
+ field_dict["quotes"] = quotes
174
+ if bookmarks is not UNSET:
175
+ field_dict["bookmarks"] = bookmarks
176
+ if views is not UNSET:
177
+ field_dict["views"] = views
178
+ if media is not UNSET:
179
+ field_dict["media"] = media
180
+ if urls is not UNSET:
181
+ field_dict["urls"] = urls
182
+ if hashtags is not UNSET:
183
+ field_dict["hashtags"] = hashtags
184
+ if mentions is not UNSET:
185
+ field_dict["mentions"] = mentions
186
+ if is_retweet is not UNSET:
187
+ field_dict["is_retweet"] = is_retweet
188
+ if is_quote is not UNSET:
189
+ field_dict["is_quote"] = is_quote
190
+ if is_reply is not UNSET:
191
+ field_dict["is_reply"] = is_reply
192
+ if source is not UNSET:
193
+ field_dict["source"] = source
194
+
195
+ return field_dict
196
+
197
+ @classmethod
198
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
199
+ from ..models.media import Media # noqa: PLC0415
200
+ from ..models.user import User # noqa: PLC0415
201
+
202
+ d = dict(src_dict)
203
+ id = d.pop("id")
204
+
205
+ text = d.pop("text")
206
+
207
+ created_at = datetime.datetime.fromisoformat(d.pop("created_at"))
208
+
209
+ author_id = d.pop("author_id")
210
+
211
+ lang = d.pop("lang", UNSET)
212
+
213
+ _author = d.pop("author", UNSET)
214
+ author: User | Unset
215
+ if isinstance(_author, Unset):
216
+ author = UNSET
217
+ else:
218
+ author = User.from_dict(_author)
219
+
220
+ conversation_id = d.pop("conversation_id", UNSET)
221
+
222
+ in_reply_to_id = d.pop("in_reply_to_id", UNSET)
223
+
224
+ in_reply_to_user_id = d.pop("in_reply_to_user_id", UNSET)
225
+
226
+ quoted_id = d.pop("quoted_id", UNSET)
227
+
228
+ retweeted_id = d.pop("retweeted_id", UNSET)
229
+
230
+ replies = d.pop("replies", UNSET)
231
+
232
+ retweets = d.pop("retweets", UNSET)
233
+
234
+ likes = d.pop("likes", UNSET)
235
+
236
+ quotes = d.pop("quotes", UNSET)
237
+
238
+ bookmarks = d.pop("bookmarks", UNSET)
239
+
240
+ views = d.pop("views", UNSET)
241
+
242
+ _media = d.pop("media", UNSET)
243
+ media: list[Media] | Unset = UNSET
244
+ if _media is not UNSET:
245
+ media = []
246
+ for media_item_data in _media:
247
+ media_item = Media.from_dict(media_item_data)
248
+
249
+ media.append(media_item)
250
+
251
+ urls = cast(list[str], d.pop("urls", UNSET))
252
+
253
+ hashtags = cast(list[str], d.pop("hashtags", UNSET))
254
+
255
+ mentions = cast(list[str], d.pop("mentions", UNSET))
256
+
257
+ is_retweet = d.pop("is_retweet", UNSET)
258
+
259
+ is_quote = d.pop("is_quote", UNSET)
260
+
261
+ is_reply = d.pop("is_reply", UNSET)
262
+
263
+ source = d.pop("source", UNSET)
264
+
265
+ tweet = cls(
266
+ id=id,
267
+ text=text,
268
+ created_at=created_at,
269
+ author_id=author_id,
270
+ lang=lang,
271
+ author=author,
272
+ conversation_id=conversation_id,
273
+ in_reply_to_id=in_reply_to_id,
274
+ in_reply_to_user_id=in_reply_to_user_id,
275
+ quoted_id=quoted_id,
276
+ retweeted_id=retweeted_id,
277
+ replies=replies,
278
+ retweets=retweets,
279
+ likes=likes,
280
+ quotes=quotes,
281
+ bookmarks=bookmarks,
282
+ views=views,
283
+ media=media,
284
+ urls=urls,
285
+ hashtags=hashtags,
286
+ mentions=mentions,
287
+ is_retweet=is_retweet,
288
+ is_quote=is_quote,
289
+ is_reply=is_reply,
290
+ source=source,
291
+ )
292
+
293
+ tweet.additional_properties = d
294
+ return tweet
295
+
296
+ @property
297
+ def additional_keys(self) -> list[str]:
298
+ return list(self.additional_properties.keys())
299
+
300
+ def __getitem__(self, key: str) -> Any:
301
+ return self.additional_properties[key]
302
+
303
+ def __setitem__(self, key: str, value: Any) -> None:
304
+ self.additional_properties[key] = value
305
+
306
+ def __delitem__(self, key: str) -> None:
307
+ del self.additional_properties[key]
308
+
309
+ def __contains__(self, key: str) -> bool:
310
+ 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.tweet import Tweet
16
+
17
+
18
+ T = TypeVar("T", bound="TweetBatch")
19
+
20
+
21
+ @_attrs_define
22
+ class TweetBatch:
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[Tweet] | Unset): Found tweets
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[Tweet] | 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.tweet import Tweet # 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[Tweet] | Unset = UNSET
115
+ if _data is not UNSET:
116
+ data = []
117
+ for data_item_data in _data:
118
+ data_item = Tweet.from_dict(data_item_data)
119
+
120
+ data.append(data_item)
121
+
122
+ tweet_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
+ tweet_batch.additional_properties = d
134
+ return tweet_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.tweet import Tweet
15
+
16
+
17
+ T = TypeVar("T", bound="TweetPage")
18
+
19
+
20
+ @_attrs_define
21
+ class TweetPage:
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[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: list[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: 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.tweet import Tweet # 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[Tweet] | Unset = UNSET
99
+ if _data is not UNSET:
100
+ data = []
101
+ for data_item_data in _data:
102
+ data_item = Tweet.from_dict(data_item_data)
103
+
104
+ data.append(data_item)
105
+
106
+ tweet_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
+ tweet_page.additional_properties = d
117
+ return tweet_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