universal-mcp-applications 0.1.1__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 (268) hide show
  1. universal_mcp/applications/ahrefs/README.md +51 -0
  2. universal_mcp/applications/ahrefs/__init__.py +1 -0
  3. universal_mcp/applications/ahrefs/app.py +2291 -0
  4. universal_mcp/applications/airtable/README.md +22 -0
  5. universal_mcp/applications/airtable/__init__.py +1 -0
  6. universal_mcp/applications/airtable/app.py +479 -0
  7. universal_mcp/applications/apollo/README.md +44 -0
  8. universal_mcp/applications/apollo/__init__.py +1 -0
  9. universal_mcp/applications/apollo/app.py +1847 -0
  10. universal_mcp/applications/asana/README.md +199 -0
  11. universal_mcp/applications/asana/__init__.py +1 -0
  12. universal_mcp/applications/asana/app.py +9509 -0
  13. universal_mcp/applications/aws-s3/README.md +0 -0
  14. universal_mcp/applications/aws-s3/__init__.py +1 -0
  15. universal_mcp/applications/aws-s3/app.py +552 -0
  16. universal_mcp/applications/bill/README.md +0 -0
  17. universal_mcp/applications/bill/__init__.py +1 -0
  18. universal_mcp/applications/bill/app.py +8705 -0
  19. universal_mcp/applications/box/README.md +307 -0
  20. universal_mcp/applications/box/__init__.py +1 -0
  21. universal_mcp/applications/box/app.py +15987 -0
  22. universal_mcp/applications/braze/README.md +106 -0
  23. universal_mcp/applications/braze/__init__.py +1 -0
  24. universal_mcp/applications/braze/app.py +4754 -0
  25. universal_mcp/applications/cal-com-v2/README.md +150 -0
  26. universal_mcp/applications/cal-com-v2/__init__.py +1 -0
  27. universal_mcp/applications/cal-com-v2/app.py +5541 -0
  28. universal_mcp/applications/calendly/README.md +53 -0
  29. universal_mcp/applications/calendly/__init__.py +1 -0
  30. universal_mcp/applications/calendly/app.py +1436 -0
  31. universal_mcp/applications/canva/README.md +43 -0
  32. universal_mcp/applications/canva/__init__.py +1 -0
  33. universal_mcp/applications/canva/app.py +941 -0
  34. universal_mcp/applications/clickup/README.md +135 -0
  35. universal_mcp/applications/clickup/__init__.py +1 -0
  36. universal_mcp/applications/clickup/app.py +5009 -0
  37. universal_mcp/applications/coda/README.md +108 -0
  38. universal_mcp/applications/coda/__init__.py +1 -0
  39. universal_mcp/applications/coda/app.py +3671 -0
  40. universal_mcp/applications/confluence/README.md +198 -0
  41. universal_mcp/applications/confluence/__init__.py +1 -0
  42. universal_mcp/applications/confluence/app.py +6273 -0
  43. universal_mcp/applications/contentful/README.md +17 -0
  44. universal_mcp/applications/contentful/__init__.py +1 -0
  45. universal_mcp/applications/contentful/app.py +364 -0
  46. universal_mcp/applications/crustdata/README.md +25 -0
  47. universal_mcp/applications/crustdata/__init__.py +1 -0
  48. universal_mcp/applications/crustdata/app.py +586 -0
  49. universal_mcp/applications/dialpad/README.md +202 -0
  50. universal_mcp/applications/dialpad/__init__.py +1 -0
  51. universal_mcp/applications/dialpad/app.py +5949 -0
  52. universal_mcp/applications/digitalocean/README.md +463 -0
  53. universal_mcp/applications/digitalocean/__init__.py +1 -0
  54. universal_mcp/applications/digitalocean/app.py +20835 -0
  55. universal_mcp/applications/domain-checker/README.md +13 -0
  56. universal_mcp/applications/domain-checker/__init__.py +1 -0
  57. universal_mcp/applications/domain-checker/app.py +265 -0
  58. universal_mcp/applications/e2b/README.md +12 -0
  59. universal_mcp/applications/e2b/__init__.py +1 -0
  60. universal_mcp/applications/e2b/app.py +187 -0
  61. universal_mcp/applications/elevenlabs/README.md +88 -0
  62. universal_mcp/applications/elevenlabs/__init__.py +1 -0
  63. universal_mcp/applications/elevenlabs/app.py +3235 -0
  64. universal_mcp/applications/exa/README.md +15 -0
  65. universal_mcp/applications/exa/__init__.py +1 -0
  66. universal_mcp/applications/exa/app.py +221 -0
  67. universal_mcp/applications/falai/README.md +17 -0
  68. universal_mcp/applications/falai/__init__.py +1 -0
  69. universal_mcp/applications/falai/app.py +331 -0
  70. universal_mcp/applications/figma/README.md +49 -0
  71. universal_mcp/applications/figma/__init__.py +1 -0
  72. universal_mcp/applications/figma/app.py +1090 -0
  73. universal_mcp/applications/firecrawl/README.md +20 -0
  74. universal_mcp/applications/firecrawl/__init__.py +1 -0
  75. universal_mcp/applications/firecrawl/app.py +514 -0
  76. universal_mcp/applications/fireflies/README.md +25 -0
  77. universal_mcp/applications/fireflies/__init__.py +1 -0
  78. universal_mcp/applications/fireflies/app.py +506 -0
  79. universal_mcp/applications/fpl/README.md +23 -0
  80. universal_mcp/applications/fpl/__init__.py +1 -0
  81. universal_mcp/applications/fpl/app.py +1327 -0
  82. universal_mcp/applications/fpl/utils/api.py +142 -0
  83. universal_mcp/applications/fpl/utils/fixtures.py +629 -0
  84. universal_mcp/applications/fpl/utils/helper.py +982 -0
  85. universal_mcp/applications/fpl/utils/league_utils.py +546 -0
  86. universal_mcp/applications/fpl/utils/position_utils.py +68 -0
  87. universal_mcp/applications/ghost-content/README.md +25 -0
  88. universal_mcp/applications/ghost-content/__init__.py +1 -0
  89. universal_mcp/applications/ghost-content/app.py +654 -0
  90. universal_mcp/applications/github/README.md +1049 -0
  91. universal_mcp/applications/github/__init__.py +1 -0
  92. universal_mcp/applications/github/app.py +50600 -0
  93. universal_mcp/applications/gong/README.md +63 -0
  94. universal_mcp/applications/gong/__init__.py +1 -0
  95. universal_mcp/applications/gong/app.py +2297 -0
  96. universal_mcp/applications/google-ads/README.md +0 -0
  97. universal_mcp/applications/google-ads/__init__.py +1 -0
  98. universal_mcp/applications/google-ads/app.py +23 -0
  99. universal_mcp/applications/google-calendar/README.md +21 -0
  100. universal_mcp/applications/google-calendar/__init__.py +1 -0
  101. universal_mcp/applications/google-calendar/app.py +574 -0
  102. universal_mcp/applications/google-docs/README.md +25 -0
  103. universal_mcp/applications/google-docs/__init__.py +1 -0
  104. universal_mcp/applications/google-docs/app.py +760 -0
  105. universal_mcp/applications/google-drive/README.md +68 -0
  106. universal_mcp/applications/google-drive/__init__.py +1 -0
  107. universal_mcp/applications/google-drive/app.py +4936 -0
  108. universal_mcp/applications/google-gemini/README.md +25 -0
  109. universal_mcp/applications/google-gemini/__init__.py +1 -0
  110. universal_mcp/applications/google-gemini/app.py +663 -0
  111. universal_mcp/applications/google-mail/README.md +31 -0
  112. universal_mcp/applications/google-mail/__init__.py +1 -0
  113. universal_mcp/applications/google-mail/app.py +1354 -0
  114. universal_mcp/applications/google-searchconsole/README.md +21 -0
  115. universal_mcp/applications/google-searchconsole/__init__.py +1 -0
  116. universal_mcp/applications/google-searchconsole/app.py +320 -0
  117. universal_mcp/applications/google-sheet/README.md +36 -0
  118. universal_mcp/applications/google-sheet/__init__.py +1 -0
  119. universal_mcp/applications/google-sheet/app.py +1941 -0
  120. universal_mcp/applications/hashnode/README.md +20 -0
  121. universal_mcp/applications/hashnode/__init__.py +1 -0
  122. universal_mcp/applications/hashnode/app.py +455 -0
  123. universal_mcp/applications/heygen/README.md +44 -0
  124. universal_mcp/applications/heygen/__init__.py +1 -0
  125. universal_mcp/applications/heygen/app.py +961 -0
  126. universal_mcp/applications/http-tools/README.md +16 -0
  127. universal_mcp/applications/http-tools/__init__.py +1 -0
  128. universal_mcp/applications/http-tools/app.py +153 -0
  129. universal_mcp/applications/hubspot/README.md +239 -0
  130. universal_mcp/applications/hubspot/__init__.py +1 -0
  131. universal_mcp/applications/hubspot/app.py +416 -0
  132. universal_mcp/applications/jira/README.md +600 -0
  133. universal_mcp/applications/jira/__init__.py +1 -0
  134. universal_mcp/applications/jira/app.py +28804 -0
  135. universal_mcp/applications/klaviyo/README.md +313 -0
  136. universal_mcp/applications/klaviyo/__init__.py +1 -0
  137. universal_mcp/applications/klaviyo/app.py +11236 -0
  138. universal_mcp/applications/linkedin/README.md +15 -0
  139. universal_mcp/applications/linkedin/__init__.py +1 -0
  140. universal_mcp/applications/linkedin/app.py +243 -0
  141. universal_mcp/applications/mailchimp/README.md +281 -0
  142. universal_mcp/applications/mailchimp/__init__.py +1 -0
  143. universal_mcp/applications/mailchimp/app.py +10937 -0
  144. universal_mcp/applications/markitdown/README.md +12 -0
  145. universal_mcp/applications/markitdown/__init__.py +1 -0
  146. universal_mcp/applications/markitdown/app.py +63 -0
  147. universal_mcp/applications/miro/README.md +151 -0
  148. universal_mcp/applications/miro/__init__.py +1 -0
  149. universal_mcp/applications/miro/app.py +5429 -0
  150. universal_mcp/applications/ms-teams/README.md +42 -0
  151. universal_mcp/applications/ms-teams/__init__.py +1 -0
  152. universal_mcp/applications/ms-teams/app.py +1823 -0
  153. universal_mcp/applications/neon/README.md +74 -0
  154. universal_mcp/applications/neon/__init__.py +1 -0
  155. universal_mcp/applications/neon/app.py +2018 -0
  156. universal_mcp/applications/notion/README.md +30 -0
  157. universal_mcp/applications/notion/__init__.py +1 -0
  158. universal_mcp/applications/notion/app.py +527 -0
  159. universal_mcp/applications/openai/README.md +22 -0
  160. universal_mcp/applications/openai/__init__.py +1 -0
  161. universal_mcp/applications/openai/app.py +759 -0
  162. universal_mcp/applications/outlook/README.md +20 -0
  163. universal_mcp/applications/outlook/__init__.py +1 -0
  164. universal_mcp/applications/outlook/app.py +444 -0
  165. universal_mcp/applications/perplexity/README.md +12 -0
  166. universal_mcp/applications/perplexity/__init__.py +1 -0
  167. universal_mcp/applications/perplexity/app.py +65 -0
  168. universal_mcp/applications/pipedrive/README.md +284 -0
  169. universal_mcp/applications/pipedrive/__init__.py +1 -0
  170. universal_mcp/applications/pipedrive/app.py +12924 -0
  171. universal_mcp/applications/posthog/README.md +132 -0
  172. universal_mcp/applications/posthog/__init__.py +1 -0
  173. universal_mcp/applications/posthog/app.py +7125 -0
  174. universal_mcp/applications/reddit/README.md +135 -0
  175. universal_mcp/applications/reddit/__init__.py +1 -0
  176. universal_mcp/applications/reddit/app.py +4652 -0
  177. universal_mcp/applications/replicate/README.md +18 -0
  178. universal_mcp/applications/replicate/__init__.py +1 -0
  179. universal_mcp/applications/replicate/app.py +495 -0
  180. universal_mcp/applications/resend/README.md +40 -0
  181. universal_mcp/applications/resend/__init__.py +1 -0
  182. universal_mcp/applications/resend/app.py +881 -0
  183. universal_mcp/applications/retell/README.md +21 -0
  184. universal_mcp/applications/retell/__init__.py +1 -0
  185. universal_mcp/applications/retell/app.py +333 -0
  186. universal_mcp/applications/rocketlane/README.md +70 -0
  187. universal_mcp/applications/rocketlane/__init__.py +1 -0
  188. universal_mcp/applications/rocketlane/app.py +4346 -0
  189. universal_mcp/applications/semanticscholar/README.md +25 -0
  190. universal_mcp/applications/semanticscholar/__init__.py +1 -0
  191. universal_mcp/applications/semanticscholar/app.py +482 -0
  192. universal_mcp/applications/semrush/README.md +44 -0
  193. universal_mcp/applications/semrush/__init__.py +1 -0
  194. universal_mcp/applications/semrush/app.py +2081 -0
  195. universal_mcp/applications/sendgrid/README.md +362 -0
  196. universal_mcp/applications/sendgrid/__init__.py +1 -0
  197. universal_mcp/applications/sendgrid/app.py +9752 -0
  198. universal_mcp/applications/sentry/README.md +186 -0
  199. universal_mcp/applications/sentry/__init__.py +1 -0
  200. universal_mcp/applications/sentry/app.py +7471 -0
  201. universal_mcp/applications/serpapi/README.md +14 -0
  202. universal_mcp/applications/serpapi/__init__.py +1 -0
  203. universal_mcp/applications/serpapi/app.py +293 -0
  204. universal_mcp/applications/sharepoint/README.md +0 -0
  205. universal_mcp/applications/sharepoint/__init__.py +1 -0
  206. universal_mcp/applications/sharepoint/app.py +215 -0
  207. universal_mcp/applications/shopify/README.md +321 -0
  208. universal_mcp/applications/shopify/__init__.py +1 -0
  209. universal_mcp/applications/shopify/app.py +15392 -0
  210. universal_mcp/applications/shortcut/README.md +128 -0
  211. universal_mcp/applications/shortcut/__init__.py +1 -0
  212. universal_mcp/applications/shortcut/app.py +4478 -0
  213. universal_mcp/applications/slack/README.md +0 -0
  214. universal_mcp/applications/slack/__init__.py +1 -0
  215. universal_mcp/applications/slack/app.py +570 -0
  216. universal_mcp/applications/spotify/README.md +91 -0
  217. universal_mcp/applications/spotify/__init__.py +1 -0
  218. universal_mcp/applications/spotify/app.py +2526 -0
  219. universal_mcp/applications/supabase/README.md +87 -0
  220. universal_mcp/applications/supabase/__init__.py +1 -0
  221. universal_mcp/applications/supabase/app.py +2970 -0
  222. universal_mcp/applications/tavily/README.md +12 -0
  223. universal_mcp/applications/tavily/__init__.py +1 -0
  224. universal_mcp/applications/tavily/app.py +51 -0
  225. universal_mcp/applications/trello/README.md +266 -0
  226. universal_mcp/applications/trello/__init__.py +1 -0
  227. universal_mcp/applications/trello/app.py +10875 -0
  228. universal_mcp/applications/twillo/README.md +0 -0
  229. universal_mcp/applications/twillo/__init__.py +1 -0
  230. universal_mcp/applications/twillo/app.py +269 -0
  231. universal_mcp/applications/twitter/README.md +100 -0
  232. universal_mcp/applications/twitter/__init__.py +1 -0
  233. universal_mcp/applications/twitter/api_segments/__init__.py +0 -0
  234. universal_mcp/applications/twitter/api_segments/api_segment_base.py +51 -0
  235. universal_mcp/applications/twitter/api_segments/compliance_api.py +122 -0
  236. universal_mcp/applications/twitter/api_segments/dm_conversations_api.py +255 -0
  237. universal_mcp/applications/twitter/api_segments/dm_events_api.py +140 -0
  238. universal_mcp/applications/twitter/api_segments/likes_api.py +159 -0
  239. universal_mcp/applications/twitter/api_segments/lists_api.py +395 -0
  240. universal_mcp/applications/twitter/api_segments/openapi_json_api.py +34 -0
  241. universal_mcp/applications/twitter/api_segments/spaces_api.py +309 -0
  242. universal_mcp/applications/twitter/api_segments/trends_api.py +40 -0
  243. universal_mcp/applications/twitter/api_segments/tweets_api.py +1403 -0
  244. universal_mcp/applications/twitter/api_segments/usage_api.py +40 -0
  245. universal_mcp/applications/twitter/api_segments/users_api.py +1498 -0
  246. universal_mcp/applications/twitter/app.py +46 -0
  247. universal_mcp/applications/unipile/README.md +28 -0
  248. universal_mcp/applications/unipile/__init__.py +1 -0
  249. universal_mcp/applications/unipile/app.py +829 -0
  250. universal_mcp/applications/whatsapp/README.md +23 -0
  251. universal_mcp/applications/whatsapp/__init__.py +1 -0
  252. universal_mcp/applications/whatsapp/app.py +595 -0
  253. universal_mcp/applications/whatsapp-business/README.md +34 -0
  254. universal_mcp/applications/whatsapp-business/__init__.py +1 -0
  255. universal_mcp/applications/whatsapp-business/app.py +1065 -0
  256. universal_mcp/applications/wrike/README.md +46 -0
  257. universal_mcp/applications/wrike/__init__.py +1 -0
  258. universal_mcp/applications/wrike/app.py +1583 -0
  259. universal_mcp/applications/youtube/README.md +57 -0
  260. universal_mcp/applications/youtube/__init__.py +1 -0
  261. universal_mcp/applications/youtube/app.py +1696 -0
  262. universal_mcp/applications/zenquotes/README.md +12 -0
  263. universal_mcp/applications/zenquotes/__init__.py +1 -0
  264. universal_mcp/applications/zenquotes/app.py +31 -0
  265. universal_mcp_applications-0.1.1.dist-info/METADATA +172 -0
  266. universal_mcp_applications-0.1.1.dist-info/RECORD +268 -0
  267. universal_mcp_applications-0.1.1.dist-info/WHEEL +4 -0
  268. universal_mcp_applications-0.1.1.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,1403 @@
1
+ from typing import Any
2
+
3
+ from .api_segment_base import APISegmentBase
4
+
5
+
6
+ class TweetsApi(APISegmentBase):
7
+ def __init__(self, main_app_client: Any):
8
+ super().__init__(main_app_client)
9
+
10
+ def find_tweets_by_id(
11
+ self,
12
+ ids,
13
+ tweet_fields=None,
14
+ expansions=None,
15
+ media_fields=None,
16
+ poll_fields=None,
17
+ user_fields=None,
18
+ place_fields=None,
19
+ ) -> dict[str, Any]:
20
+ """
21
+
22
+ Retrieves one or more Tweets by their IDs and returns associated details, supporting optional parameters for specifying additional fields and expansions.
23
+
24
+ Args:
25
+ ids (array): An array of IDs for the tweets to retrieve, required for the operation.
26
+ tweet_fields (array): A comma separated list of Tweet fields to display. Example: "['article', 'attachments', 'author_id', 'card_uri', 'context_annotations', 'conversation_id', 'created_at', 'edit_controls', 'edit_history_tweet_ids', 'entities', 'geo', 'id', 'in_reply_to_user_id', 'lang', 'non_public_metrics', 'note_tweet', 'organic_metrics', 'possibly_sensitive', 'promoted_metrics', 'public_metrics', 'referenced_tweets', 'reply_settings', 'scopes', 'source', 'text', 'username', 'withheld']".
27
+ expansions (array): A comma separated list of fields to expand. Example: "['article.cover_media', 'article.media_entities', 'attachments.media_keys', 'attachments.media_source_tweet', 'attachments.poll_ids', 'author_id', 'edit_history_tweet_ids', 'entities.mentions.username', 'geo.place_id', 'in_reply_to_user_id', 'entities.note.mentions.username', 'referenced_tweets.id', 'referenced_tweets.id.author_id', 'author_screen_name']".
28
+ media_fields (array): A comma separated list of Media fields to display. Example: "['alt_text', 'duration_ms', 'height', 'media_key', 'non_public_metrics', 'organic_metrics', 'preview_image_url', 'promoted_metrics', 'public_metrics', 'type', 'url', 'variants', 'width']".
29
+ poll_fields (array): A comma separated list of Poll fields to display. Example: "['duration_minutes', 'end_datetime', 'id', 'options', 'voting_status']".
30
+ user_fields (array): A comma separated list of User fields to display. Example: "['affiliation', 'connection_status', 'created_at', 'description', 'entities', 'id', 'location', 'most_recent_tweet_id', 'name', 'pinned_tweet_id', 'profile_banner_url', 'profile_image_url', 'protected', 'public_metrics', 'receives_your_dm', 'subscription_type', 'url', 'username', 'verified', 'verified_type', 'withheld']".
31
+ place_fields (array): A comma separated list of Place fields to display. Example: "['contained_within', 'country', 'country_code', 'full_name', 'geo', 'id', 'name', 'place_type']".
32
+
33
+ Returns:
34
+ dict[str, Any]: The request has succeeded.
35
+
36
+ Raises:
37
+ HTTPError: Raised when the API request fails (e.g., non-2XX status code).
38
+ JSONDecodeError: Raised if the response body cannot be parsed as JSON.
39
+
40
+ Tags:
41
+ Tweets
42
+ """
43
+ url = f"{self.main_app_client.base_url}/2/tweets"
44
+ query_params = {
45
+ k: v
46
+ for k, v in [
47
+ ("ids", ids),
48
+ ("tweet.fields", tweet_fields),
49
+ ("expansions", expansions),
50
+ ("media.fields", media_fields),
51
+ ("poll.fields", poll_fields),
52
+ ("user.fields", user_fields),
53
+ ("place.fields", place_fields),
54
+ ]
55
+ if v is not None
56
+ }
57
+ response = self._get(url, params=query_params)
58
+ response.raise_for_status()
59
+ return response.json()
60
+
61
+ def create_tweet(
62
+ self,
63
+ card_uri=None,
64
+ direct_message_deep_link=None,
65
+ for_super_followers_only=None,
66
+ geo=None,
67
+ media=None,
68
+ nullcast=None,
69
+ poll=None,
70
+ quote_tweet_id=None,
71
+ reply=None,
72
+ reply_settings=None,
73
+ text=None,
74
+ ) -> dict[str, Any]:
75
+ """
76
+
77
+ Creates a new tweet using the Twitter API v2, requiring an application/json payload and OAuth2 user token for authentication, and returns a 201 status upon successful creation.
78
+
79
+ Args:
80
+ card_uri (string): Card Uri Parameter. This is mutually exclusive from Quote Tweet Id, Poll, Media, and Direct Message Deep Link.
81
+ direct_message_deep_link (string): Link to take the conversation from the public timeline to a private Direct Message.
82
+ for_super_followers_only (boolean): Exclusive Tweet for super followers.
83
+ geo (object): Place ID being attached to the Tweet for geo location.
84
+ media (object): Media information being attached to created Tweet. This is mutually exclusive from Quote Tweet Id, Poll, and Card URI.
85
+ nullcast (boolean): Nullcasted (promoted-only) Posts do not appear in the public timeline and are not served to followers.
86
+ poll (object): Poll options for a Tweet with a poll. This is mutually exclusive from Media, Quote Tweet Id, and Card URI.
87
+ quote_tweet_id (string): Unique identifier of this Tweet. This is returned as a string in order to avoid complications with languages and tools that cannot handle large integers. Example: '1346889436626259968'.
88
+ reply (object): Tweet information of the Tweet being replied to.
89
+ reply_settings (string): Settings to indicate who can reply to the Tweet.
90
+ text (string): The content of the Tweet. Example: 'Learn how to use the user Tweet timeline and user mention timeline endpoints in the X API v2 to explore Tweet\\u2026 https:\\/\\/t.co\\/56a0vZUx7i'.
91
+
92
+ Returns:
93
+ dict[str, Any]: The request has succeeded.
94
+
95
+ Raises:
96
+ HTTPError: Raised when the API request fails (e.g., non-2XX status code).
97
+ JSONDecodeError: Raised if the response body cannot be parsed as JSON.
98
+
99
+ Tags:
100
+ Tweets
101
+ """
102
+ request_body_data = None
103
+ request_body_data = {
104
+ "card_uri": card_uri,
105
+ "direct_message_deep_link": direct_message_deep_link,
106
+ "for_super_followers_only": for_super_followers_only,
107
+ "geo": geo,
108
+ "media": media,
109
+ "nullcast": nullcast,
110
+ "poll": poll,
111
+ "quote_tweet_id": quote_tweet_id,
112
+ "reply": reply,
113
+ "reply_settings": reply_settings,
114
+ "text": text,
115
+ }
116
+ request_body_data = {
117
+ k: v for k, v in request_body_data.items() if v is not None
118
+ }
119
+ url = f"{self.main_app_client.base_url}/2/tweets"
120
+ query_params = {}
121
+ response = self._post(
122
+ url,
123
+ data=request_body_data,
124
+ params=query_params,
125
+ content_type="application/json",
126
+ )
127
+ response.raise_for_status()
128
+ return response.json()
129
+
130
+ def get_tweets_compliance_stream(
131
+ self, partition, backfill_minutes=None, start_time=None, end_time=None
132
+ ) -> Any:
133
+ """
134
+
135
+ Streams compliance events for tweets in real-time, allowing for the retrieval of events such as post deletions, edits, and withholdings, as well as user account changes, using parameters like partition, backfill_minutes, start_time, and end_time.
136
+
137
+ Args:
138
+ partition (integer): Specifies the partition number from which to retrieve compliance stream events, with a required integer value between 1 and 4.
139
+ backfill_minutes (integer): Optional integer parameter to specify the number of minutes of data to recover from a stream disconnection, allowing retrieval of missed tweets.
140
+ start_time (string): Optional string parameter specifying the earliest UTC timestamp from which compliance events will be provided, formatted as YYYY-MM-DDTHH:mm:ssZ. Example: '2021-02-01T18:40:40.000Z'.
141
+ end_time (string): The `end_time` parameter specifies the latest UTC timestamp (in ISO 8601 format) until which compliance events will be streamed. Example: '2021-02-14T18:40:40.000Z'.
142
+
143
+ Returns:
144
+ Any: The request has succeeded.
145
+
146
+ Raises:
147
+ HTTPError: Raised when the API request fails (e.g., non-2XX status code).
148
+ JSONDecodeError: Raised if the response body cannot be parsed as JSON.
149
+
150
+ Tags:
151
+ Compliance
152
+ """
153
+ url = f"{self.main_app_client.base_url}/2/tweets/compliance/stream"
154
+ query_params = {
155
+ k: v
156
+ for k, v in [
157
+ ("backfill_minutes", backfill_minutes),
158
+ ("partition", partition),
159
+ ("start_time", start_time),
160
+ ("end_time", end_time),
161
+ ]
162
+ if v is not None
163
+ }
164
+ response = self._get(url, params=query_params)
165
+ response.raise_for_status()
166
+ return response.json()
167
+
168
+ def tweet_counts_full_archive_search(
169
+ self,
170
+ query,
171
+ start_time=None,
172
+ end_time=None,
173
+ since_id=None,
174
+ until_id=None,
175
+ next_token=None,
176
+ pagination_token=None,
177
+ granularity=None,
178
+ search_count_fields=None,
179
+ ) -> dict[str, Any]:
180
+ """
181
+
182
+ Retrieves the full-archive count of tweets for a specified query using the "/2/tweets/counts/all" endpoint, allowing optional filtering by start and end times, granularity, and pagination.
183
+
184
+ Args:
185
+ query (string): The "query" parameter is a required string used to filter tweets by specifying keywords or phrases, allowing users to retrieve counts for specific topics or hashtags. Example: '(from:TwitterDev OR from:TwitterAPI) has:media -is:retweet'.
186
+ start_time (string): The start_time parameter sets the earliest timestamp from which to begin counting Tweets in the full-archive matching the query, formatted as an ISO 8601 string.
187
+ end_time (string): The end_time parameter specifies the exclusive end timestamp to limit the search query for tweet counts in ISO 8601 format.
188
+ since_id (string): Optional parameter to return results with a Tweet ID greater than the specified ID, effectively retrieving more recent Tweets. Example: '1346889436626259968'.
189
+ until_id (string): Returns tweet counts with Tweet IDs less than (older than) the specified Tweet ID, limiting results to those before this ID. Example: '1346889436626259968'.
190
+ next_token (string): Optional parameter to fetch the next page of results in a paginated response, obtained from the `meta.next_token` field of the previous response.
191
+ pagination_token (string): Used to request the next page of results, providing the value of `next_token` from the previous response to paginate through data.
192
+ granularity (string): The **granularity** parameter specifies the time unit for retrieving tweet counts, allowing options of "minute", "hour", or "day", with "hour" as the default.
193
+ search_count_fields (array): A comma separated list of SearchCount fields to display. Example: "['end', 'start', 'tweet_count']".
194
+
195
+ Returns:
196
+ dict[str, Any]: The request has succeeded.
197
+
198
+ Raises:
199
+ HTTPError: Raised when the API request fails (e.g., non-2XX status code).
200
+ JSONDecodeError: Raised if the response body cannot be parsed as JSON.
201
+
202
+ Tags:
203
+ Tweets
204
+ """
205
+ url = f"{self.main_app_client.base_url}/2/tweets/counts/all"
206
+ query_params = {
207
+ k: v
208
+ for k, v in [
209
+ ("query", query),
210
+ ("start_time", start_time),
211
+ ("end_time", end_time),
212
+ ("since_id", since_id),
213
+ ("until_id", until_id),
214
+ ("next_token", next_token),
215
+ ("pagination_token", pagination_token),
216
+ ("granularity", granularity),
217
+ ("search_count.fields", search_count_fields),
218
+ ]
219
+ if v is not None
220
+ }
221
+ response = self._get(url, params=query_params)
222
+ response.raise_for_status()
223
+ return response.json()
224
+
225
+ def tweet_counts_recent_search(
226
+ self,
227
+ query,
228
+ start_time=None,
229
+ end_time=None,
230
+ since_id=None,
231
+ until_id=None,
232
+ next_token=None,
233
+ pagination_token=None,
234
+ granularity=None,
235
+ search_count_fields=None,
236
+ ) -> dict[str, Any]:
237
+ """
238
+
239
+ Retrieves the count of recent Tweets that match a search query over the last seven days, using the "GET" method with optional parameters for specifying start and end times, granularity, and pagination.
240
+
241
+ Args:
242
+ query (string): The search query to filter recent tweets for counting matching tweets. Example: '(from:TwitterDev OR from:TwitterAPI) has:media -is:retweet'.
243
+ start_time (string): Optional start time for the recent Tweet counts query, specified in ISO 8601 format, which determines the beginning of the time window for which Tweet counts are returned.
244
+ end_time (string): Optional string parameter specifying the end time for the range of Tweets to be included in the count results, formatted in ISO 8601/RFC 3339.
245
+ since_id (string): Optional parameter to retrieve recent tweet counts with IDs greater than the specified ID, returning data for tweets posted after that ID. Example: '1346889436626259968'.
246
+ until_id (string): Optional parameter to specify the latest Tweet ID up to which the count of Tweets will be provided. Example: '1346889436626259968'.
247
+ next_token (string): Optional parameter to paginate through results, used to retrieve the next page of tweet count data by including the token from the previous response's `meta.next_token` field.
248
+ pagination_token (string): Optional parameter to paginate through the results, used by passing the `next_token` value from the previous response to retrieve the next page of tweet count data.
249
+ granularity (string): The granularity parameter specifies the time interval for aggregating Tweet counts in the response, with possible values of "minute," "hour" (default), or "day".
250
+ search_count_fields (array): A comma separated list of SearchCount fields to display. Example: "['end', 'start', 'tweet_count']".
251
+
252
+ Returns:
253
+ dict[str, Any]: The request has succeeded.
254
+
255
+ Raises:
256
+ HTTPError: Raised when the API request fails (e.g., non-2XX status code).
257
+ JSONDecodeError: Raised if the response body cannot be parsed as JSON.
258
+
259
+ Tags:
260
+ Tweets
261
+ """
262
+ url = f"{self.main_app_client.base_url}/2/tweets/counts/recent"
263
+ query_params = {
264
+ k: v
265
+ for k, v in [
266
+ ("query", query),
267
+ ("start_time", start_time),
268
+ ("end_time", end_time),
269
+ ("since_id", since_id),
270
+ ("until_id", until_id),
271
+ ("next_token", next_token),
272
+ ("pagination_token", pagination_token),
273
+ ("granularity", granularity),
274
+ ("search_count.fields", search_count_fields),
275
+ ]
276
+ if v is not None
277
+ }
278
+ response = self._get(url, params=query_params)
279
+ response.raise_for_status()
280
+ return response.json()
281
+
282
+ def get_tweets_firehose_stream(
283
+ self,
284
+ partition,
285
+ backfill_minutes=None,
286
+ start_time=None,
287
+ end_time=None,
288
+ tweet_fields=None,
289
+ expansions=None,
290
+ media_fields=None,
291
+ poll_fields=None,
292
+ user_fields=None,
293
+ place_fields=None,
294
+ ) -> dict[str, Any]:
295
+ """
296
+
297
+ Streams all tweets in real-time using the Firehose API, allowing parameters such as partition, backfill minutes, start and end time, and various field expansions to customize the data retrieved, which requires authentication via a Bearer Token.
298
+
299
+ Args:
300
+ partition (integer): A required integer parameter that specifies the partition from which to retrieve the firehose stream data.
301
+ backfill_minutes (integer): The backfill_minutes parameter allows requesting up to five minutes of missed streaming data to be delivered upon reconnection, helping recover Tweets lost during short disconnections; it accepts an integer value from 1 to 5 and is available only with Academic Research access.
302
+ start_time (string): Optional ISO 8601-formatted timestamp indicating the earliest time from which to retrieve tweets, allowing filtering by time period. Example: '2021-02-14T18:40:40.000Z'.
303
+ end_time (string): The end_time parameter specifies the exclusive upper bound timestamp to filter tweets created before this time in the stream. Example: '2021-02-14T18:40:40.000Z'.
304
+ tweet_fields (array): A comma separated list of Tweet fields to display. Example: "['article', 'attachments', 'author_id', 'card_uri', 'context_annotations', 'conversation_id', 'created_at', 'edit_controls', 'edit_history_tweet_ids', 'entities', 'geo', 'id', 'in_reply_to_user_id', 'lang', 'non_public_metrics', 'note_tweet', 'organic_metrics', 'possibly_sensitive', 'promoted_metrics', 'public_metrics', 'referenced_tweets', 'reply_settings', 'scopes', 'source', 'text', 'username', 'withheld']".
305
+ expansions (array): A comma separated list of fields to expand. Example: "['article.cover_media', 'article.media_entities', 'attachments.media_keys', 'attachments.media_source_tweet', 'attachments.poll_ids', 'author_id', 'edit_history_tweet_ids', 'entities.mentions.username', 'geo.place_id', 'in_reply_to_user_id', 'entities.note.mentions.username', 'referenced_tweets.id', 'referenced_tweets.id.author_id', 'author_screen_name']".
306
+ media_fields (array): A comma separated list of Media fields to display. Example: "['alt_text', 'duration_ms', 'height', 'media_key', 'non_public_metrics', 'organic_metrics', 'preview_image_url', 'promoted_metrics', 'public_metrics', 'type', 'url', 'variants', 'width']".
307
+ poll_fields (array): A comma separated list of Poll fields to display. Example: "['duration_minutes', 'end_datetime', 'id', 'options', 'voting_status']".
308
+ user_fields (array): A comma separated list of User fields to display. Example: "['affiliation', 'connection_status', 'created_at', 'description', 'entities', 'id', 'location', 'most_recent_tweet_id', 'name', 'pinned_tweet_id', 'profile_banner_url', 'profile_image_url', 'protected', 'public_metrics', 'receives_your_dm', 'subscription_type', 'url', 'username', 'verified', 'verified_type', 'withheld']".
309
+ place_fields (array): A comma separated list of Place fields to display. Example: "['contained_within', 'country', 'country_code', 'full_name', 'geo', 'id', 'name', 'place_type']".
310
+
311
+ Returns:
312
+ dict[str, Any]: The request has succeeded.
313
+
314
+ Raises:
315
+ HTTPError: Raised when the API request fails (e.g., non-2XX status code).
316
+ JSONDecodeError: Raised if the response body cannot be parsed as JSON.
317
+
318
+ Tags:
319
+ Tweets
320
+ """
321
+ url = f"{self.main_app_client.base_url}/2/tweets/firehose/stream"
322
+ query_params = {
323
+ k: v
324
+ for k, v in [
325
+ ("backfill_minutes", backfill_minutes),
326
+ ("partition", partition),
327
+ ("start_time", start_time),
328
+ ("end_time", end_time),
329
+ ("tweet.fields", tweet_fields),
330
+ ("expansions", expansions),
331
+ ("media.fields", media_fields),
332
+ ("poll.fields", poll_fields),
333
+ ("user.fields", user_fields),
334
+ ("place.fields", place_fields),
335
+ ]
336
+ if v is not None
337
+ }
338
+ response = self._get(url, params=query_params)
339
+ response.raise_for_status()
340
+ return response.json()
341
+
342
+ def get_tweets_firehose_stream_lang_en(
343
+ self,
344
+ partition,
345
+ backfill_minutes=None,
346
+ start_time=None,
347
+ end_time=None,
348
+ tweet_fields=None,
349
+ expansions=None,
350
+ media_fields=None,
351
+ poll_fields=None,
352
+ user_fields=None,
353
+ place_fields=None,
354
+ ) -> dict[str, Any]:
355
+ """
356
+
357
+ Connects to the Twitter Firehose streaming API to receive a real-time stream of English-language tweets with optional filtering and data field expansions.
358
+
359
+ Args:
360
+ partition (integer): The `partition` parameter is an integer value required in the query for the GET operation at path "/2/tweets/firehose/stream/lang/en", specifying the partition number for the stream.
361
+ backfill_minutes (integer): Requests up to five minutes of missed streaming data to be delivered upon reconnection, useful for recovering data lost during brief disconnections.
362
+ start_time (string): Optional string parameter specifying the start time in ISO 8601 format (YYYY-MM-DDTHH:mm:ssZ) to filter the oldest Tweets included in the response. Example: '2021-02-14T18:40:40.000Z'.
363
+ end_time (string): Optional parameter to specify the end time for filtering tweets in the firehose stream, allowing retrieval of tweets created before this time. Example: '2021-02-14T18:40:40.000Z'.
364
+ tweet_fields (array): A comma separated list of Tweet fields to display. Example: "['article', 'attachments', 'author_id', 'card_uri', 'context_annotations', 'conversation_id', 'created_at', 'edit_controls', 'edit_history_tweet_ids', 'entities', 'geo', 'id', 'in_reply_to_user_id', 'lang', 'non_public_metrics', 'note_tweet', 'organic_metrics', 'possibly_sensitive', 'promoted_metrics', 'public_metrics', 'referenced_tweets', 'reply_settings', 'scopes', 'source', 'text', 'username', 'withheld']".
365
+ expansions (array): A comma separated list of fields to expand. Example: "['article.cover_media', 'article.media_entities', 'attachments.media_keys', 'attachments.media_source_tweet', 'attachments.poll_ids', 'author_id', 'edit_history_tweet_ids', 'entities.mentions.username', 'geo.place_id', 'in_reply_to_user_id', 'entities.note.mentions.username', 'referenced_tweets.id', 'referenced_tweets.id.author_id', 'author_screen_name']".
366
+ media_fields (array): A comma separated list of Media fields to display. Example: "['alt_text', 'duration_ms', 'height', 'media_key', 'non_public_metrics', 'organic_metrics', 'preview_image_url', 'promoted_metrics', 'public_metrics', 'type', 'url', 'variants', 'width']".
367
+ poll_fields (array): A comma separated list of Poll fields to display. Example: "['duration_minutes', 'end_datetime', 'id', 'options', 'voting_status']".
368
+ user_fields (array): A comma separated list of User fields to display. Example: "['affiliation', 'connection_status', 'created_at', 'description', 'entities', 'id', 'location', 'most_recent_tweet_id', 'name', 'pinned_tweet_id', 'profile_banner_url', 'profile_image_url', 'protected', 'public_metrics', 'receives_your_dm', 'subscription_type', 'url', 'username', 'verified', 'verified_type', 'withheld']".
369
+ place_fields (array): A comma separated list of Place fields to display. Example: "['contained_within', 'country', 'country_code', 'full_name', 'geo', 'id', 'name', 'place_type']".
370
+
371
+ Returns:
372
+ dict[str, Any]: The request has succeeded.
373
+
374
+ Raises:
375
+ HTTPError: Raised when the API request fails (e.g., non-2XX status code).
376
+ JSONDecodeError: Raised if the response body cannot be parsed as JSON.
377
+
378
+ Tags:
379
+ Tweets
380
+ """
381
+ url = f"{self.main_app_client.base_url}/2/tweets/firehose/stream/lang/en"
382
+ query_params = {
383
+ k: v
384
+ for k, v in [
385
+ ("backfill_minutes", backfill_minutes),
386
+ ("partition", partition),
387
+ ("start_time", start_time),
388
+ ("end_time", end_time),
389
+ ("tweet.fields", tweet_fields),
390
+ ("expansions", expansions),
391
+ ("media.fields", media_fields),
392
+ ("poll.fields", poll_fields),
393
+ ("user.fields", user_fields),
394
+ ("place.fields", place_fields),
395
+ ]
396
+ if v is not None
397
+ }
398
+ response = self._get(url, params=query_params)
399
+ response.raise_for_status()
400
+ return response.json()
401
+
402
+ def get_tweets_firehose_stream_lang_ja(
403
+ self,
404
+ partition,
405
+ backfill_minutes=None,
406
+ start_time=None,
407
+ end_time=None,
408
+ tweet_fields=None,
409
+ expansions=None,
410
+ media_fields=None,
411
+ poll_fields=None,
412
+ user_fields=None,
413
+ place_fields=None,
414
+ ) -> dict[str, Any]:
415
+ """
416
+
417
+ Retrieves a stream of Tweets in Japanese using the Firehose API, allowing for real-time access to a high-volume stream of Tweets based on specified parameters such as partitions and optional backfill minutes, start and end times, and customizable fields for Tweets, users, and media.
418
+
419
+ Args:
420
+ partition (integer): The partition number used to identify and organize the data stream, which is required for this operation.
421
+ backfill_minutes (integer): The number of minutes (1 to 5) of missed streaming data to backfill and recover upon reconnection, available only with Academic Research access.
422
+ start_time (string): The start_time parameter specifies the oldest UTC timestamp in ISO 8601 format from which Tweets will be provided, inclusive and in second granularity. Example: '2021-02-14T18:40:40.000Z'.
423
+ end_time (string): Optional query parameter to specify the end time for retrieving Tweets in the format compatible with the API's date and time requirements, limiting the results to those created before this time. Example: '2021-02-14T18:40:40.000Z'.
424
+ tweet_fields (array): A comma separated list of Tweet fields to display. Example: "['article', 'attachments', 'author_id', 'card_uri', 'context_annotations', 'conversation_id', 'created_at', 'edit_controls', 'edit_history_tweet_ids', 'entities', 'geo', 'id', 'in_reply_to_user_id', 'lang', 'non_public_metrics', 'note_tweet', 'organic_metrics', 'possibly_sensitive', 'promoted_metrics', 'public_metrics', 'referenced_tweets', 'reply_settings', 'scopes', 'source', 'text', 'username', 'withheld']".
425
+ expansions (array): A comma separated list of fields to expand. Example: "['article.cover_media', 'article.media_entities', 'attachments.media_keys', 'attachments.media_source_tweet', 'attachments.poll_ids', 'author_id', 'edit_history_tweet_ids', 'entities.mentions.username', 'geo.place_id', 'in_reply_to_user_id', 'entities.note.mentions.username', 'referenced_tweets.id', 'referenced_tweets.id.author_id', 'author_screen_name']".
426
+ media_fields (array): A comma separated list of Media fields to display. Example: "['alt_text', 'duration_ms', 'height', 'media_key', 'non_public_metrics', 'organic_metrics', 'preview_image_url', 'promoted_metrics', 'public_metrics', 'type', 'url', 'variants', 'width']".
427
+ poll_fields (array): A comma separated list of Poll fields to display. Example: "['duration_minutes', 'end_datetime', 'id', 'options', 'voting_status']".
428
+ user_fields (array): A comma separated list of User fields to display. Example: "['affiliation', 'connection_status', 'created_at', 'description', 'entities', 'id', 'location', 'most_recent_tweet_id', 'name', 'pinned_tweet_id', 'profile_banner_url', 'profile_image_url', 'protected', 'public_metrics', 'receives_your_dm', 'subscription_type', 'url', 'username', 'verified', 'verified_type', 'withheld']".
429
+ place_fields (array): A comma separated list of Place fields to display. Example: "['contained_within', 'country', 'country_code', 'full_name', 'geo', 'id', 'name', 'place_type']".
430
+
431
+ Returns:
432
+ dict[str, Any]: The request has succeeded.
433
+
434
+ Raises:
435
+ HTTPError: Raised when the API request fails (e.g., non-2XX status code).
436
+ JSONDecodeError: Raised if the response body cannot be parsed as JSON.
437
+
438
+ Tags:
439
+ Tweets
440
+ """
441
+ url = f"{self.main_app_client.base_url}/2/tweets/firehose/stream/lang/ja"
442
+ query_params = {
443
+ k: v
444
+ for k, v in [
445
+ ("backfill_minutes", backfill_minutes),
446
+ ("partition", partition),
447
+ ("start_time", start_time),
448
+ ("end_time", end_time),
449
+ ("tweet.fields", tweet_fields),
450
+ ("expansions", expansions),
451
+ ("media.fields", media_fields),
452
+ ("poll.fields", poll_fields),
453
+ ("user.fields", user_fields),
454
+ ("place.fields", place_fields),
455
+ ]
456
+ if v is not None
457
+ }
458
+ response = self._get(url, params=query_params)
459
+ response.raise_for_status()
460
+ return response.json()
461
+
462
+ def get_tweets_firehose_stream_lang_ko(
463
+ self,
464
+ partition,
465
+ backfill_minutes=None,
466
+ start_time=None,
467
+ end_time=None,
468
+ tweet_fields=None,
469
+ expansions=None,
470
+ media_fields=None,
471
+ poll_fields=None,
472
+ user_fields=None,
473
+ place_fields=None,
474
+ ) -> dict[str, Any]:
475
+ """
476
+
477
+ Streams real-time tweets in Korean from the Twitter firehose, allowing for optional backfill, specific partitions, and customizable start and end times, with support for various tweet, media, poll, user, and place fields.
478
+
479
+ Args:
480
+ partition (integer): The partition parameter specifies the integer partition number to use for streaming tweets.
481
+ backfill_minutes (integer): The number of minutes (1 to 5) of previously missed Tweets to backfill and deliver upon reconnection, allowing recovery of up to five minutes of data missed during a disconnection; duplicates may occur and this feature requires Academic Research access.
482
+ start_time (string): The "start_time" parameter specifies the earliest UTC timestamp from which Tweets should be retrieved, formatted as YYYY-MM-DDTHH:mm:ssZ (ISO 8601/RFC 3339). Example: '2021-02-14T18:40:40.000Z'.
483
+ end_time (string): end_time: Optional query parameter to specify the exclusive upper bound timestamp for filtering Tweets in the stream, returning only those created before this time. Example: '2021-02-14T18:40:40.000Z'.
484
+ tweet_fields (array): A comma separated list of Tweet fields to display. Example: "['article', 'attachments', 'author_id', 'card_uri', 'context_annotations', 'conversation_id', 'created_at', 'edit_controls', 'edit_history_tweet_ids', 'entities', 'geo', 'id', 'in_reply_to_user_id', 'lang', 'non_public_metrics', 'note_tweet', 'organic_metrics', 'possibly_sensitive', 'promoted_metrics', 'public_metrics', 'referenced_tweets', 'reply_settings', 'scopes', 'source', 'text', 'username', 'withheld']".
485
+ expansions (array): A comma separated list of fields to expand. Example: "['article.cover_media', 'article.media_entities', 'attachments.media_keys', 'attachments.media_source_tweet', 'attachments.poll_ids', 'author_id', 'edit_history_tweet_ids', 'entities.mentions.username', 'geo.place_id', 'in_reply_to_user_id', 'entities.note.mentions.username', 'referenced_tweets.id', 'referenced_tweets.id.author_id', 'author_screen_name']".
486
+ media_fields (array): A comma separated list of Media fields to display. Example: "['alt_text', 'duration_ms', 'height', 'media_key', 'non_public_metrics', 'organic_metrics', 'preview_image_url', 'promoted_metrics', 'public_metrics', 'type', 'url', 'variants', 'width']".
487
+ poll_fields (array): A comma separated list of Poll fields to display. Example: "['duration_minutes', 'end_datetime', 'id', 'options', 'voting_status']".
488
+ user_fields (array): A comma separated list of User fields to display. Example: "['affiliation', 'connection_status', 'created_at', 'description', 'entities', 'id', 'location', 'most_recent_tweet_id', 'name', 'pinned_tweet_id', 'profile_banner_url', 'profile_image_url', 'protected', 'public_metrics', 'receives_your_dm', 'subscription_type', 'url', 'username', 'verified', 'verified_type', 'withheld']".
489
+ place_fields (array): A comma separated list of Place fields to display. Example: "['contained_within', 'country', 'country_code', 'full_name', 'geo', 'id', 'name', 'place_type']".
490
+
491
+ Returns:
492
+ dict[str, Any]: The request has succeeded.
493
+
494
+ Raises:
495
+ HTTPError: Raised when the API request fails (e.g., non-2XX status code).
496
+ JSONDecodeError: Raised if the response body cannot be parsed as JSON.
497
+
498
+ Tags:
499
+ Tweets
500
+ """
501
+ url = f"{self.main_app_client.base_url}/2/tweets/firehose/stream/lang/ko"
502
+ query_params = {
503
+ k: v
504
+ for k, v in [
505
+ ("backfill_minutes", backfill_minutes),
506
+ ("partition", partition),
507
+ ("start_time", start_time),
508
+ ("end_time", end_time),
509
+ ("tweet.fields", tweet_fields),
510
+ ("expansions", expansions),
511
+ ("media.fields", media_fields),
512
+ ("poll.fields", poll_fields),
513
+ ("user.fields", user_fields),
514
+ ("place.fields", place_fields),
515
+ ]
516
+ if v is not None
517
+ }
518
+ response = self._get(url, params=query_params)
519
+ response.raise_for_status()
520
+ return response.json()
521
+
522
+ def get_tweets_firehose_stream_lang_pt(
523
+ self,
524
+ partition,
525
+ backfill_minutes=None,
526
+ start_time=None,
527
+ end_time=None,
528
+ tweet_fields=None,
529
+ expansions=None,
530
+ media_fields=None,
531
+ poll_fields=None,
532
+ user_fields=None,
533
+ place_fields=None,
534
+ ) -> dict[str, Any]:
535
+ """
536
+
537
+ Streams real-time Tweets in Portuguese using the Firehose API, allowing for filtering by specific parameters such as tweet fields, expansions, media, polls, users, and places, and requires a partition number for the stream.
538
+
539
+ Args:
540
+ partition (integer): The **partition** parameter is a required integer that specifies the partition number for the GET operation at the "/2/tweets/firehose/stream/lang/pt" path, used to distribute the stream of tweets across multiple partitions for efficient processing.
541
+ backfill_minutes (integer): The number of minutes (1-5) of missed streaming data to recover and deliver upon reconnection, available only for Academic Research access.
542
+ start_time (string): The "start_time" parameter specifies the starting point for retrieving Tweets, expressed in ISO 8601 format (YYYY-MM-DDTHH:mm:ssZ), indicating the earliest UTC timestamp for which to include Tweets. Example: '2021-02-14T18:40:40.000Z'.
543
+ end_time (string): The `end_time` parameter specifies the timestamp, in ISO 8601 format, after which tweets are not included in the response, allowing filtering of the firehose stream by a specific end time. Example: '2021-02-14T18:40:40.000Z'.
544
+ tweet_fields (array): A comma separated list of Tweet fields to display. Example: "['article', 'attachments', 'author_id', 'card_uri', 'context_annotations', 'conversation_id', 'created_at', 'edit_controls', 'edit_history_tweet_ids', 'entities', 'geo', 'id', 'in_reply_to_user_id', 'lang', 'non_public_metrics', 'note_tweet', 'organic_metrics', 'possibly_sensitive', 'promoted_metrics', 'public_metrics', 'referenced_tweets', 'reply_settings', 'scopes', 'source', 'text', 'username', 'withheld']".
545
+ expansions (array): A comma separated list of fields to expand. Example: "['article.cover_media', 'article.media_entities', 'attachments.media_keys', 'attachments.media_source_tweet', 'attachments.poll_ids', 'author_id', 'edit_history_tweet_ids', 'entities.mentions.username', 'geo.place_id', 'in_reply_to_user_id', 'entities.note.mentions.username', 'referenced_tweets.id', 'referenced_tweets.id.author_id', 'author_screen_name']".
546
+ media_fields (array): A comma separated list of Media fields to display. Example: "['alt_text', 'duration_ms', 'height', 'media_key', 'non_public_metrics', 'organic_metrics', 'preview_image_url', 'promoted_metrics', 'public_metrics', 'type', 'url', 'variants', 'width']".
547
+ poll_fields (array): A comma separated list of Poll fields to display. Example: "['duration_minutes', 'end_datetime', 'id', 'options', 'voting_status']".
548
+ user_fields (array): A comma separated list of User fields to display. Example: "['affiliation', 'connection_status', 'created_at', 'description', 'entities', 'id', 'location', 'most_recent_tweet_id', 'name', 'pinned_tweet_id', 'profile_banner_url', 'profile_image_url', 'protected', 'public_metrics', 'receives_your_dm', 'subscription_type', 'url', 'username', 'verified', 'verified_type', 'withheld']".
549
+ place_fields (array): A comma separated list of Place fields to display. Example: "['contained_within', 'country', 'country_code', 'full_name', 'geo', 'id', 'name', 'place_type']".
550
+
551
+ Returns:
552
+ dict[str, Any]: The request has succeeded.
553
+
554
+ Raises:
555
+ HTTPError: Raised when the API request fails (e.g., non-2XX status code).
556
+ JSONDecodeError: Raised if the response body cannot be parsed as JSON.
557
+
558
+ Tags:
559
+ Tweets
560
+ """
561
+ url = f"{self.main_app_client.base_url}/2/tweets/firehose/stream/lang/pt"
562
+ query_params = {
563
+ k: v
564
+ for k, v in [
565
+ ("backfill_minutes", backfill_minutes),
566
+ ("partition", partition),
567
+ ("start_time", start_time),
568
+ ("end_time", end_time),
569
+ ("tweet.fields", tweet_fields),
570
+ ("expansions", expansions),
571
+ ("media.fields", media_fields),
572
+ ("poll.fields", poll_fields),
573
+ ("user.fields", user_fields),
574
+ ("place.fields", place_fields),
575
+ ]
576
+ if v is not None
577
+ }
578
+ response = self._get(url, params=query_params)
579
+ response.raise_for_status()
580
+ return response.json()
581
+
582
+ def get_tweets_label_stream(
583
+ self, backfill_minutes=None, start_time=None, end_time=None
584
+ ) -> Any:
585
+ """
586
+
587
+ Streams tweets labeled with a specific identifier in real-time using the Twitter API, allowing for optional parameters to specify backfill minutes, start time, and end time, and requires authentication via a Bearer Token.
588
+
589
+ Args:
590
+ backfill_minutes (integer): The number of minutes (up to five) of missed tweet data to recover and backfill after a disconnection, available for Academic Research access.
591
+ start_time (string): Optional parameter specifying the earliest UTC timestamp (in ISO 8601/RFC 3339 format) from which to retrieve tweets, allowing filtering by creation time. Example: '2021-02-01T18:40:40.000Z'.
592
+ end_time (string): Optional parameter specifying the end time in ISO 8601 format for retrieving tweets from a label stream, used to filter tweets created before this time. Example: '2021-02-01T18:40:40.000Z'.
593
+
594
+ Returns:
595
+ Any: The request has succeeded.
596
+
597
+ Raises:
598
+ HTTPError: Raised when the API request fails (e.g., non-2XX status code).
599
+ JSONDecodeError: Raised if the response body cannot be parsed as JSON.
600
+
601
+ Tags:
602
+ Compliance
603
+ """
604
+ url = f"{self.main_app_client.base_url}/2/tweets/label/stream"
605
+ query_params = {
606
+ k: v
607
+ for k, v in [
608
+ ("backfill_minutes", backfill_minutes),
609
+ ("start_time", start_time),
610
+ ("end_time", end_time),
611
+ ]
612
+ if v is not None
613
+ }
614
+ response = self._get(url, params=query_params)
615
+ response.raise_for_status()
616
+ return response.json()
617
+
618
+ def sample_stream(
619
+ self,
620
+ backfill_minutes=None,
621
+ tweet_fields=None,
622
+ expansions=None,
623
+ media_fields=None,
624
+ poll_fields=None,
625
+ user_fields=None,
626
+ place_fields=None,
627
+ ) -> dict[str, Any]:
628
+ """
629
+
630
+ Retrieves a real-time sampled stream of public Tweets with optional parameters to specify Tweet, user, media, poll, and place fields, supporting backfill for missed data.
631
+
632
+ Args:
633
+ backfill_minutes (integer): The number of minutes (1 to 5) of missed streaming Tweets to backfill and receive upon reconnection, available for Academic Research access.
634
+ tweet_fields (array): A comma separated list of Tweet fields to display. Example: "['article', 'attachments', 'author_id', 'card_uri', 'context_annotations', 'conversation_id', 'created_at', 'edit_controls', 'edit_history_tweet_ids', 'entities', 'geo', 'id', 'in_reply_to_user_id', 'lang', 'non_public_metrics', 'note_tweet', 'organic_metrics', 'possibly_sensitive', 'promoted_metrics', 'public_metrics', 'referenced_tweets', 'reply_settings', 'scopes', 'source', 'text', 'username', 'withheld']".
635
+ expansions (array): A comma separated list of fields to expand. Example: "['article.cover_media', 'article.media_entities', 'attachments.media_keys', 'attachments.media_source_tweet', 'attachments.poll_ids', 'author_id', 'edit_history_tweet_ids', 'entities.mentions.username', 'geo.place_id', 'in_reply_to_user_id', 'entities.note.mentions.username', 'referenced_tweets.id', 'referenced_tweets.id.author_id', 'author_screen_name']".
636
+ media_fields (array): A comma separated list of Media fields to display. Example: "['alt_text', 'duration_ms', 'height', 'media_key', 'non_public_metrics', 'organic_metrics', 'preview_image_url', 'promoted_metrics', 'public_metrics', 'type', 'url', 'variants', 'width']".
637
+ poll_fields (array): A comma separated list of Poll fields to display. Example: "['duration_minutes', 'end_datetime', 'id', 'options', 'voting_status']".
638
+ user_fields (array): A comma separated list of User fields to display. Example: "['affiliation', 'connection_status', 'created_at', 'description', 'entities', 'id', 'location', 'most_recent_tweet_id', 'name', 'pinned_tweet_id', 'profile_banner_url', 'profile_image_url', 'protected', 'public_metrics', 'receives_your_dm', 'subscription_type', 'url', 'username', 'verified', 'verified_type', 'withheld']".
639
+ place_fields (array): A comma separated list of Place fields to display. Example: "['contained_within', 'country', 'country_code', 'full_name', 'geo', 'id', 'name', 'place_type']".
640
+
641
+ Returns:
642
+ dict[str, Any]: The request has succeeded.
643
+
644
+ Raises:
645
+ HTTPError: Raised when the API request fails (e.g., non-2XX status code).
646
+ JSONDecodeError: Raised if the response body cannot be parsed as JSON.
647
+
648
+ Tags:
649
+ Tweets
650
+ """
651
+ url = f"{self.main_app_client.base_url}/2/tweets/sample/stream"
652
+ query_params = {
653
+ k: v
654
+ for k, v in [
655
+ ("backfill_minutes", backfill_minutes),
656
+ ("tweet.fields", tweet_fields),
657
+ ("expansions", expansions),
658
+ ("media.fields", media_fields),
659
+ ("poll.fields", poll_fields),
660
+ ("user.fields", user_fields),
661
+ ("place.fields", place_fields),
662
+ ]
663
+ if v is not None
664
+ }
665
+ response = self._get(url, params=query_params)
666
+ response.raise_for_status()
667
+ return response.json()
668
+
669
+ def get_tweets_sample_stream(
670
+ self,
671
+ partition,
672
+ backfill_minutes=None,
673
+ start_time=None,
674
+ end_time=None,
675
+ tweet_fields=None,
676
+ expansions=None,
677
+ media_fields=None,
678
+ poll_fields=None,
679
+ user_fields=None,
680
+ place_fields=None,
681
+ ) -> dict[str, Any]:
682
+ """
683
+
684
+ Streams a random sample of 10% of all Tweets in real-time, allowing optional filtering by specifying additional parameters such as backfill minutes, partition, start and end times, and various field expansions for tweets, media, polls, users, and places.
685
+
686
+ Args:
687
+ partition (integer): The "partition" parameter specifies the partition number for the stream, which is required for the GET operation at path "/2/tweets/sample10/stream".
688
+ backfill_minutes (integer): The `backfill_minutes` parameter allows you to request up to five minutes of missed streaming data to be delivered upon reconnection, helping recover data lost during disconnections; it is only available for Academic Research access.
689
+ start_time (string): The `start_time` parameter specifies the earliest UTC timestamp from which tweets are returned, formatted as YYYY-MM-DDTHH:mm:ssZ (ISO 8601/RFC 3339), and is inclusive. Example: '2021-02-14T18:40:40.000Z'.
690
+ end_time (string): An optional string parameter specifying the end time in seconds since the Unix epoch for which to stop streaming Tweets. Example: '2021-02-14T18:40:40.000Z'.
691
+ tweet_fields (array): A comma separated list of Tweet fields to display. Example: "['article', 'attachments', 'author_id', 'card_uri', 'context_annotations', 'conversation_id', 'created_at', 'edit_controls', 'edit_history_tweet_ids', 'entities', 'geo', 'id', 'in_reply_to_user_id', 'lang', 'non_public_metrics', 'note_tweet', 'organic_metrics', 'possibly_sensitive', 'promoted_metrics', 'public_metrics', 'referenced_tweets', 'reply_settings', 'scopes', 'source', 'text', 'username', 'withheld']".
692
+ expansions (array): A comma separated list of fields to expand. Example: "['article.cover_media', 'article.media_entities', 'attachments.media_keys', 'attachments.media_source_tweet', 'attachments.poll_ids', 'author_id', 'edit_history_tweet_ids', 'entities.mentions.username', 'geo.place_id', 'in_reply_to_user_id', 'entities.note.mentions.username', 'referenced_tweets.id', 'referenced_tweets.id.author_id', 'author_screen_name']".
693
+ media_fields (array): A comma separated list of Media fields to display. Example: "['alt_text', 'duration_ms', 'height', 'media_key', 'non_public_metrics', 'organic_metrics', 'preview_image_url', 'promoted_metrics', 'public_metrics', 'type', 'url', 'variants', 'width']".
694
+ poll_fields (array): A comma separated list of Poll fields to display. Example: "['duration_minutes', 'end_datetime', 'id', 'options', 'voting_status']".
695
+ user_fields (array): A comma separated list of User fields to display. Example: "['affiliation', 'connection_status', 'created_at', 'description', 'entities', 'id', 'location', 'most_recent_tweet_id', 'name', 'pinned_tweet_id', 'profile_banner_url', 'profile_image_url', 'protected', 'public_metrics', 'receives_your_dm', 'subscription_type', 'url', 'username', 'verified', 'verified_type', 'withheld']".
696
+ place_fields (array): A comma separated list of Place fields to display. Example: "['contained_within', 'country', 'country_code', 'full_name', 'geo', 'id', 'name', 'place_type']".
697
+
698
+ Returns:
699
+ dict[str, Any]: The request has succeeded.
700
+
701
+ Raises:
702
+ HTTPError: Raised when the API request fails (e.g., non-2XX status code).
703
+ JSONDecodeError: Raised if the response body cannot be parsed as JSON.
704
+
705
+ Tags:
706
+ Tweets
707
+ """
708
+ url = f"{self.main_app_client.base_url}/2/tweets/sample10/stream"
709
+ query_params = {
710
+ k: v
711
+ for k, v in [
712
+ ("backfill_minutes", backfill_minutes),
713
+ ("partition", partition),
714
+ ("start_time", start_time),
715
+ ("end_time", end_time),
716
+ ("tweet.fields", tweet_fields),
717
+ ("expansions", expansions),
718
+ ("media.fields", media_fields),
719
+ ("poll.fields", poll_fields),
720
+ ("user.fields", user_fields),
721
+ ("place.fields", place_fields),
722
+ ]
723
+ if v is not None
724
+ }
725
+ response = self._get(url, params=query_params)
726
+ response.raise_for_status()
727
+ return response.json()
728
+
729
+ def tweets_fullarchive_search(
730
+ self,
731
+ query,
732
+ start_time=None,
733
+ end_time=None,
734
+ since_id=None,
735
+ until_id=None,
736
+ max_results=None,
737
+ next_token=None,
738
+ pagination_token=None,
739
+ sort_order=None,
740
+ tweet_fields=None,
741
+ expansions=None,
742
+ media_fields=None,
743
+ poll_fields=None,
744
+ user_fields=None,
745
+ place_fields=None,
746
+ ) -> dict[str, Any]:
747
+ """
748
+
749
+ Retrieves and returns a list of historical Tweets matching a specified query, allowing for filtering by time range, tweet ID, and other parameters.
750
+
751
+ Args:
752
+ query (string): The "query" parameter is a required string input used to specify the search criteria for retrieving tweets. Example: '(from:TwitterDev OR from:TwitterAPI) has:media -is:retweet'.
753
+ start_time (string): Optional timestamp specifying the earliest date and time from which to retrieve Tweets, formatted as YYYY-MM-DDTHH:mm:ssZ in ISO 8601/RFC 3339 format; if not specified and end_time is provided, it defaults to 30 days before end_time.
754
+ end_time (string): The **end_time** parameter specifies the most recent UTC timestamp (in ISO 8601/RFC 3339 format) up to which tweets are returned, exclusive of the specified time.
755
+ since_id (string): Optional parameter to return results with IDs greater than (more recent than) the specified ID, useful for fetching new tweets since the last query. Example: '1346889436626259968'.
756
+ until_id (string): Optional parameter specifying the Tweet ID to return results with IDs less than (i.e., older than) the given ID. Example: '1346889436626259968'.
757
+ max_results (integer): Specifies the maximum number of Tweets to return per response page, with a default value of 10.
758
+ next_token (string): Optional parameter used for pagination; it specifies a token to retrieve the next page of results in the search query response.
759
+ pagination_token (string): The pagination_token query parameter is used to retrieve the next page of results by passing the next_token value returned in the previous response, enabling pagination through large result sets.
760
+ sort_order (string): Optional query parameter to specify the order in which tweets are returned, either by most recent first ("recency") or by most relevant first ("relevancy").
761
+ tweet_fields (array): A comma separated list of Tweet fields to display. Example: "['article', 'attachments', 'author_id', 'card_uri', 'context_annotations', 'conversation_id', 'created_at', 'edit_controls', 'edit_history_tweet_ids', 'entities', 'geo', 'id', 'in_reply_to_user_id', 'lang', 'non_public_metrics', 'note_tweet', 'organic_metrics', 'possibly_sensitive', 'promoted_metrics', 'public_metrics', 'referenced_tweets', 'reply_settings', 'scopes', 'source', 'text', 'username', 'withheld']".
762
+ expansions (array): A comma separated list of fields to expand. Example: "['article.cover_media', 'article.media_entities', 'attachments.media_keys', 'attachments.media_source_tweet', 'attachments.poll_ids', 'author_id', 'edit_history_tweet_ids', 'entities.mentions.username', 'geo.place_id', 'in_reply_to_user_id', 'entities.note.mentions.username', 'referenced_tweets.id', 'referenced_tweets.id.author_id', 'author_screen_name']".
763
+ media_fields (array): A comma separated list of Media fields to display. Example: "['alt_text', 'duration_ms', 'height', 'media_key', 'non_public_metrics', 'organic_metrics', 'preview_image_url', 'promoted_metrics', 'public_metrics', 'type', 'url', 'variants', 'width']".
764
+ poll_fields (array): A comma separated list of Poll fields to display. Example: "['duration_minutes', 'end_datetime', 'id', 'options', 'voting_status']".
765
+ user_fields (array): A comma separated list of User fields to display. Example: "['affiliation', 'connection_status', 'created_at', 'description', 'entities', 'id', 'location', 'most_recent_tweet_id', 'name', 'pinned_tweet_id', 'profile_banner_url', 'profile_image_url', 'protected', 'public_metrics', 'receives_your_dm', 'subscription_type', 'url', 'username', 'verified', 'verified_type', 'withheld']".
766
+ place_fields (array): A comma separated list of Place fields to display. Example: "['contained_within', 'country', 'country_code', 'full_name', 'geo', 'id', 'name', 'place_type']".
767
+
768
+ Returns:
769
+ dict[str, Any]: The request has succeeded.
770
+
771
+ Raises:
772
+ HTTPError: Raised when the API request fails (e.g., non-2XX status code).
773
+ JSONDecodeError: Raised if the response body cannot be parsed as JSON.
774
+
775
+ Tags:
776
+ Tweets
777
+ """
778
+ url = f"{self.main_app_client.base_url}/2/tweets/search/all"
779
+ query_params = {
780
+ k: v
781
+ for k, v in [
782
+ ("query", query),
783
+ ("start_time", start_time),
784
+ ("end_time", end_time),
785
+ ("since_id", since_id),
786
+ ("until_id", until_id),
787
+ ("max_results", max_results),
788
+ ("next_token", next_token),
789
+ ("pagination_token", pagination_token),
790
+ ("sort_order", sort_order),
791
+ ("tweet.fields", tweet_fields),
792
+ ("expansions", expansions),
793
+ ("media.fields", media_fields),
794
+ ("poll.fields", poll_fields),
795
+ ("user.fields", user_fields),
796
+ ("place.fields", place_fields),
797
+ ]
798
+ if v is not None
799
+ }
800
+ response = self._get(url, params=query_params)
801
+ response.raise_for_status()
802
+ return response.json()
803
+
804
+ def tweets_recent_search(
805
+ self,
806
+ query,
807
+ start_time=None,
808
+ end_time=None,
809
+ since_id=None,
810
+ until_id=None,
811
+ max_results=None,
812
+ next_token=None,
813
+ pagination_token=None,
814
+ sort_order=None,
815
+ tweet_fields=None,
816
+ expansions=None,
817
+ media_fields=None,
818
+ poll_fields=None,
819
+ user_fields=None,
820
+ place_fields=None,
821
+ ) -> dict[str, Any]:
822
+ """
823
+
824
+ Retrieves recent tweets based on a specified search query, allowing for optional filtering by time range and additional parameters such as tweet fields, expansions, and user details.
825
+
826
+ Args:
827
+ query (string): A string parameter used to specify the search query for retrieving recent tweets. Example: '(from:TwitterDev OR from:TwitterAPI) has:media -is:retweet'.
828
+ start_time (string): Optional parameter to specify the earliest time to search for tweets, formatted as ISO8601/RFC3339 (e.g., 2023-05-12T00:00:00Z).
829
+ end_time (string): Optional parameter to specify the UTC timestamp (in YYYY-MM-DDTHH:mm:ssZ format) up to which the returned Tweets are retrieved, exclusive of the specified time.
830
+ since_id (string): Optional parameter to return results with an ID greater than the specified ID, retrieving more recent tweets. Example: '1346889436626259968'.
831
+ until_id (string): Returns results with an ID less than (older than) the specified ID, limiting the search to tweets older than that ID. Example: '1346889436626259968'.
832
+ max_results (integer): The "max_results" parameter specifies the maximum number of recent tweets to return per response page, with a default of 10 and a maximum of 100.
833
+ next_token (string): Optional query parameter used to paginate results, specifying the token from a previous response to fetch the next page of tweets.
834
+ pagination_token (string): Used to request the next page of results by passing the `next_token` value from the previous response.
835
+ sort_order (string): Optional parameter to specify the order of search results, either by "recency" (most recent first) or "relevancy" (most relevant first).
836
+ tweet_fields (array): A comma separated list of Tweet fields to display. Example: "['article', 'attachments', 'author_id', 'card_uri', 'context_annotations', 'conversation_id', 'created_at', 'edit_controls', 'edit_history_tweet_ids', 'entities', 'geo', 'id', 'in_reply_to_user_id', 'lang', 'non_public_metrics', 'note_tweet', 'organic_metrics', 'possibly_sensitive', 'promoted_metrics', 'public_metrics', 'referenced_tweets', 'reply_settings', 'scopes', 'source', 'text', 'username', 'withheld']".
837
+ expansions (array): A comma separated list of fields to expand. Example: "['article.cover_media', 'article.media_entities', 'attachments.media_keys', 'attachments.media_source_tweet', 'attachments.poll_ids', 'author_id', 'edit_history_tweet_ids', 'entities.mentions.username', 'geo.place_id', 'in_reply_to_user_id', 'entities.note.mentions.username', 'referenced_tweets.id', 'referenced_tweets.id.author_id', 'author_screen_name']".
838
+ media_fields (array): A comma separated list of Media fields to display. Example: "['alt_text', 'duration_ms', 'height', 'media_key', 'non_public_metrics', 'organic_metrics', 'preview_image_url', 'promoted_metrics', 'public_metrics', 'type', 'url', 'variants', 'width']".
839
+ poll_fields (array): A comma separated list of Poll fields to display. Example: "['duration_minutes', 'end_datetime', 'id', 'options', 'voting_status']".
840
+ user_fields (array): A comma separated list of User fields to display. Example: "['affiliation', 'connection_status', 'created_at', 'description', 'entities', 'id', 'location', 'most_recent_tweet_id', 'name', 'pinned_tweet_id', 'profile_banner_url', 'profile_image_url', 'protected', 'public_metrics', 'receives_your_dm', 'subscription_type', 'url', 'username', 'verified', 'verified_type', 'withheld']".
841
+ place_fields (array): A comma separated list of Place fields to display. Example: "['contained_within', 'country', 'country_code', 'full_name', 'geo', 'id', 'name', 'place_type']".
842
+
843
+ Returns:
844
+ dict[str, Any]: The request has succeeded.
845
+
846
+ Raises:
847
+ HTTPError: Raised when the API request fails (e.g., non-2XX status code).
848
+ JSONDecodeError: Raised if the response body cannot be parsed as JSON.
849
+
850
+ Tags:
851
+ Tweets
852
+ """
853
+ url = f"{self.main_app_client.base_url}/2/tweets/search/recent"
854
+ query_params = {
855
+ k: v
856
+ for k, v in [
857
+ ("query", query),
858
+ ("start_time", start_time),
859
+ ("end_time", end_time),
860
+ ("since_id", since_id),
861
+ ("until_id", until_id),
862
+ ("max_results", max_results),
863
+ ("next_token", next_token),
864
+ ("pagination_token", pagination_token),
865
+ ("sort_order", sort_order),
866
+ ("tweet.fields", tweet_fields),
867
+ ("expansions", expansions),
868
+ ("media.fields", media_fields),
869
+ ("poll.fields", poll_fields),
870
+ ("user.fields", user_fields),
871
+ ("place.fields", place_fields),
872
+ ]
873
+ if v is not None
874
+ }
875
+ response = self._get(url, params=query_params)
876
+ response.raise_for_status()
877
+ return response.json()
878
+
879
+ def search_stream(
880
+ self,
881
+ backfill_minutes=None,
882
+ start_time=None,
883
+ end_time=None,
884
+ tweet_fields=None,
885
+ expansions=None,
886
+ media_fields=None,
887
+ poll_fields=None,
888
+ user_fields=None,
889
+ place_fields=None,
890
+ ) -> dict[str, Any]:
891
+ """
892
+
893
+ Streams tweets based on predefined rules using the Twitter API v2, allowing for real-time filtering and retrieval of tweets with optional parameters for backfill minutes, start and end times, and various tweet, media, poll, user, and place fields.
894
+
895
+ Args:
896
+ backfill_minutes (integer): The "backfill_minutes" parameter allows clients to request up to five minutes of missed data upon reconnection, helping to recover Tweets that were missed due to a disconnection.
897
+ start_time (string): The "start_time" parameter specifies the earliest UTC timestamp (in ISO 8601 format) from which to include Tweets in the search results. Example: '2021-02-01T18:40:40.000Z'.
898
+ end_time (string): The timestamp (in ISO 8601/RFC 3339 format) specifying the exclusive upper bound of the time range for which Tweets will be returned. Example: '2021-02-14T18:40:40.000Z'.
899
+ tweet_fields (array): A comma separated list of Tweet fields to display. Example: "['article', 'attachments', 'author_id', 'card_uri', 'context_annotations', 'conversation_id', 'created_at', 'edit_controls', 'edit_history_tweet_ids', 'entities', 'geo', 'id', 'in_reply_to_user_id', 'lang', 'non_public_metrics', 'note_tweet', 'organic_metrics', 'possibly_sensitive', 'promoted_metrics', 'public_metrics', 'referenced_tweets', 'reply_settings', 'scopes', 'source', 'text', 'username', 'withheld']".
900
+ expansions (array): A comma separated list of fields to expand. Example: "['article.cover_media', 'article.media_entities', 'attachments.media_keys', 'attachments.media_source_tweet', 'attachments.poll_ids', 'author_id', 'edit_history_tweet_ids', 'entities.mentions.username', 'geo.place_id', 'in_reply_to_user_id', 'entities.note.mentions.username', 'referenced_tweets.id', 'referenced_tweets.id.author_id', 'author_screen_name']".
901
+ media_fields (array): A comma separated list of Media fields to display. Example: "['alt_text', 'duration_ms', 'height', 'media_key', 'non_public_metrics', 'organic_metrics', 'preview_image_url', 'promoted_metrics', 'public_metrics', 'type', 'url', 'variants', 'width']".
902
+ poll_fields (array): A comma separated list of Poll fields to display. Example: "['duration_minutes', 'end_datetime', 'id', 'options', 'voting_status']".
903
+ user_fields (array): A comma separated list of User fields to display. Example: "['affiliation', 'connection_status', 'created_at', 'description', 'entities', 'id', 'location', 'most_recent_tweet_id', 'name', 'pinned_tweet_id', 'profile_banner_url', 'profile_image_url', 'protected', 'public_metrics', 'receives_your_dm', 'subscription_type', 'url', 'username', 'verified', 'verified_type', 'withheld']".
904
+ place_fields (array): A comma separated list of Place fields to display. Example: "['contained_within', 'country', 'country_code', 'full_name', 'geo', 'id', 'name', 'place_type']".
905
+
906
+ Returns:
907
+ dict[str, Any]: The request has succeeded.
908
+
909
+ Raises:
910
+ HTTPError: Raised when the API request fails (e.g., non-2XX status code).
911
+ JSONDecodeError: Raised if the response body cannot be parsed as JSON.
912
+
913
+ Tags:
914
+ Tweets
915
+ """
916
+ url = f"{self.main_app_client.base_url}/2/tweets/search/stream"
917
+ query_params = {
918
+ k: v
919
+ for k, v in [
920
+ ("backfill_minutes", backfill_minutes),
921
+ ("start_time", start_time),
922
+ ("end_time", end_time),
923
+ ("tweet.fields", tweet_fields),
924
+ ("expansions", expansions),
925
+ ("media.fields", media_fields),
926
+ ("poll.fields", poll_fields),
927
+ ("user.fields", user_fields),
928
+ ("place.fields", place_fields),
929
+ ]
930
+ if v is not None
931
+ }
932
+ response = self._get(url, params=query_params)
933
+ response.raise_for_status()
934
+ return response.json()
935
+
936
+ def get_rules(
937
+ self, ids=None, max_results=None, pagination_token=None
938
+ ) -> dict[str, Any]:
939
+ """
940
+
941
+ Retrieves the active stream filtering rules for a user's Twitter API v2 filtered stream, optionally filtered by rule IDs, with support for pagination and maximum results.
942
+
943
+ Args:
944
+ ids (array): Optional array of rule IDs to fetch a subset of rules from the user's active rule set.
945
+ max_results (integer): The maximum number of stream filtering rules to return per response, up to 1000; defaults to 1000 if not specified.
946
+ pagination_token (string): The `pagination_token` parameter is a string used to request the next page of results in a paginated response, typically obtained from the `next_token` value in the previous response.
947
+
948
+ Returns:
949
+ dict[str, Any]: The request has succeeded.
950
+
951
+ Raises:
952
+ HTTPError: Raised when the API request fails (e.g., non-2XX status code).
953
+ JSONDecodeError: Raised if the response body cannot be parsed as JSON.
954
+
955
+ Tags:
956
+ Tweets
957
+ """
958
+ url = f"{self.main_app_client.base_url}/2/tweets/search/stream/rules"
959
+ query_params = {
960
+ k: v
961
+ for k, v in [
962
+ ("ids", ids),
963
+ ("max_results", max_results),
964
+ ("pagination_token", pagination_token),
965
+ ]
966
+ if v is not None
967
+ }
968
+ response = self._get(url, params=query_params)
969
+ response.raise_for_status()
970
+ return response.json()
971
+
972
+ def add_or_delete_rules(
973
+ self, dry_run=None, delete_all=None, add=None, delete=None
974
+ ) -> dict[str, Any]:
975
+ """
976
+
977
+ Adds or removes rules from a Twitter API v2 filtered stream using a POST request, allowing for optional dry-run or delete-all parameters.
978
+
979
+ Args:
980
+ dry_run (boolean): Indicates whether to test the syntax of the rule without applying it to the stream, allowing validation of rule changes without taking effect.
981
+ delete_all (boolean): Indicates whether to delete all existing rules for the user before applying new rules; if true, all existing rules will be deleted.
982
+ add (array): add
983
+ delete (object): IDs and values of all deleted user-specified stream filtering rules.
984
+
985
+ Returns:
986
+ dict[str, Any]: The request has succeeded.
987
+
988
+ Raises:
989
+ HTTPError: Raised when the API request fails (e.g., non-2XX status code).
990
+ JSONDecodeError: Raised if the response body cannot be parsed as JSON.
991
+
992
+ Tags:
993
+ Tweets
994
+ """
995
+ request_body_data = None
996
+ request_body_data = {"add": add, "delete": delete}
997
+ request_body_data = {
998
+ k: v for k, v in request_body_data.items() if v is not None
999
+ }
1000
+ url = f"{self.main_app_client.base_url}/2/tweets/search/stream/rules"
1001
+ query_params = {
1002
+ k: v
1003
+ for k, v in [("dry_run", dry_run), ("delete_all", delete_all)]
1004
+ if v is not None
1005
+ }
1006
+ response = self._post(
1007
+ url,
1008
+ data=request_body_data,
1009
+ params=query_params,
1010
+ content_type="application/json",
1011
+ )
1012
+ response.raise_for_status()
1013
+ return response.json()
1014
+
1015
+ def get_rule_count(self, rules_count_fields=None) -> dict[str, Any]:
1016
+ """
1017
+
1018
+ Retrieves the counts of Tweets matching specific search rules using the "GET" method, providing a way to analyze the volume of Tweets based on predefined criteria.
1019
+
1020
+ Args:
1021
+ rules_count_fields (array): A comma separated list of RulesCount fields to display. Example: "['all_project_client_apps', 'cap_per_client_app', 'cap_per_project', 'client_app_rules_count', 'project_rules_count']".
1022
+
1023
+ Returns:
1024
+ dict[str, Any]: The request has succeeded.
1025
+
1026
+ Raises:
1027
+ HTTPError: Raised when the API request fails (e.g., non-2XX status code).
1028
+ JSONDecodeError: Raised if the response body cannot be parsed as JSON.
1029
+
1030
+ Tags:
1031
+ General
1032
+ """
1033
+ url = f"{self.main_app_client.base_url}/2/tweets/search/stream/rules/counts"
1034
+ query_params = {
1035
+ k: v
1036
+ for k, v in [("rules_count.fields", rules_count_fields)]
1037
+ if v is not None
1038
+ }
1039
+ response = self._get(url, params=query_params)
1040
+ response.raise_for_status()
1041
+ return response.json()
1042
+
1043
+ def delete_tweet_by_id(self, id) -> dict[str, Any]:
1044
+ """
1045
+
1046
+ Deletes a specified Tweet by its ID on behalf of an authenticated user.
1047
+
1048
+ Args:
1049
+ id (string): id
1050
+
1051
+ Returns:
1052
+ dict[str, Any]: The request has succeeded.
1053
+
1054
+ Raises:
1055
+ HTTPError: Raised when the API request fails (e.g., non-2XX status code).
1056
+ JSONDecodeError: Raised if the response body cannot be parsed as JSON.
1057
+
1058
+ Tags:
1059
+ Tweets
1060
+ """
1061
+ if id is None:
1062
+ raise ValueError("Missing required parameter 'id'.")
1063
+ url = f"{self.main_app_client.base_url}/2/tweets/{id}"
1064
+ query_params = {}
1065
+ response = self._delete(url, params=query_params)
1066
+ response.raise_for_status()
1067
+ return response.json()
1068
+
1069
+ def find_tweet_by_id(
1070
+ self,
1071
+ id,
1072
+ tweet_fields=None,
1073
+ expansions=None,
1074
+ media_fields=None,
1075
+ poll_fields=None,
1076
+ user_fields=None,
1077
+ place_fields=None,
1078
+ ) -> dict[str, Any]:
1079
+ """
1080
+
1081
+ Retrieves detailed information about a single Tweet specified by its unique ID, with optional expansions for fields related to the Tweet, user, media, polls, and places.
1082
+
1083
+ Args:
1084
+ id (string): id
1085
+ tweet_fields (array): A comma separated list of Tweet fields to display. Example: "['article', 'attachments', 'author_id', 'card_uri', 'context_annotations', 'conversation_id', 'created_at', 'edit_controls', 'edit_history_tweet_ids', 'entities', 'geo', 'id', 'in_reply_to_user_id', 'lang', 'non_public_metrics', 'note_tweet', 'organic_metrics', 'possibly_sensitive', 'promoted_metrics', 'public_metrics', 'referenced_tweets', 'reply_settings', 'scopes', 'source', 'text', 'username', 'withheld']".
1086
+ expansions (array): A comma separated list of fields to expand. Example: "['article.cover_media', 'article.media_entities', 'attachments.media_keys', 'attachments.media_source_tweet', 'attachments.poll_ids', 'author_id', 'edit_history_tweet_ids', 'entities.mentions.username', 'geo.place_id', 'in_reply_to_user_id', 'entities.note.mentions.username', 'referenced_tweets.id', 'referenced_tweets.id.author_id', 'author_screen_name']".
1087
+ media_fields (array): A comma separated list of Media fields to display. Example: "['alt_text', 'duration_ms', 'height', 'media_key', 'non_public_metrics', 'organic_metrics', 'preview_image_url', 'promoted_metrics', 'public_metrics', 'type', 'url', 'variants', 'width']".
1088
+ poll_fields (array): A comma separated list of Poll fields to display. Example: "['duration_minutes', 'end_datetime', 'id', 'options', 'voting_status']".
1089
+ user_fields (array): A comma separated list of User fields to display. Example: "['affiliation', 'connection_status', 'created_at', 'description', 'entities', 'id', 'location', 'most_recent_tweet_id', 'name', 'pinned_tweet_id', 'profile_banner_url', 'profile_image_url', 'protected', 'public_metrics', 'receives_your_dm', 'subscription_type', 'url', 'username', 'verified', 'verified_type', 'withheld']".
1090
+ place_fields (array): A comma separated list of Place fields to display. Example: "['contained_within', 'country', 'country_code', 'full_name', 'geo', 'id', 'name', 'place_type']".
1091
+
1092
+ Returns:
1093
+ dict[str, Any]: The request has succeeded.
1094
+
1095
+ Raises:
1096
+ HTTPError: Raised when the API request fails (e.g., non-2XX status code).
1097
+ JSONDecodeError: Raised if the response body cannot be parsed as JSON.
1098
+
1099
+ Tags:
1100
+ Tweets
1101
+ """
1102
+ if id is None:
1103
+ raise ValueError("Missing required parameter 'id'.")
1104
+ url = f"{self.main_app_client.base_url}/2/tweets/{id}"
1105
+ query_params = {
1106
+ k: v
1107
+ for k, v in [
1108
+ ("tweet.fields", tweet_fields),
1109
+ ("expansions", expansions),
1110
+ ("media.fields", media_fields),
1111
+ ("poll.fields", poll_fields),
1112
+ ("user.fields", user_fields),
1113
+ ("place.fields", place_fields),
1114
+ ]
1115
+ if v is not None
1116
+ }
1117
+ response = self._get(url, params=query_params)
1118
+ response.raise_for_status()
1119
+ return response.json()
1120
+
1121
+ def tweets_id_liking_users(
1122
+ self,
1123
+ id,
1124
+ max_results=None,
1125
+ pagination_token=None,
1126
+ user_fields=None,
1127
+ expansions=None,
1128
+ tweet_fields=None,
1129
+ ) -> dict[str, Any]:
1130
+ """
1131
+
1132
+ Retrieves a list of users who have liked a specified tweet using the provided tweet ID.
1133
+
1134
+ Args:
1135
+ id (string): id
1136
+ max_results (integer): Specifies the maximum number of liking users to return in a response, with a default value of 100 and a maximum allowed value of 100.
1137
+ pagination_token (string): The pagination_token query parameter is an optional token used to retrieve the next page of results in a paginated response for the list of users who liked the tweet.
1138
+ user_fields (array): A comma separated list of User fields to display. Example: "['affiliation', 'connection_status', 'created_at', 'description', 'entities', 'id', 'location', 'most_recent_tweet_id', 'name', 'pinned_tweet_id', 'profile_banner_url', 'profile_image_url', 'protected', 'public_metrics', 'receives_your_dm', 'subscription_type', 'url', 'username', 'verified', 'verified_type', 'withheld']".
1139
+ expansions (array): A comma separated list of fields to expand. Example: "['affiliation.user_id', 'most_recent_tweet_id', 'pinned_tweet_id']".
1140
+ tweet_fields (array): A comma separated list of Tweet fields to display. Example: "['article', 'attachments', 'author_id', 'card_uri', 'context_annotations', 'conversation_id', 'created_at', 'edit_controls', 'edit_history_tweet_ids', 'entities', 'geo', 'id', 'in_reply_to_user_id', 'lang', 'non_public_metrics', 'note_tweet', 'organic_metrics', 'possibly_sensitive', 'promoted_metrics', 'public_metrics', 'referenced_tweets', 'reply_settings', 'scopes', 'source', 'text', 'username', 'withheld']".
1141
+
1142
+ Returns:
1143
+ dict[str, Any]: The request has succeeded.
1144
+
1145
+ Raises:
1146
+ HTTPError: Raised when the API request fails (e.g., non-2XX status code).
1147
+ JSONDecodeError: Raised if the response body cannot be parsed as JSON.
1148
+
1149
+ Tags:
1150
+ Users
1151
+ """
1152
+ if id is None:
1153
+ raise ValueError("Missing required parameter 'id'.")
1154
+ url = f"{self.main_app_client.base_url}/2/tweets/{id}/liking_users"
1155
+ query_params = {
1156
+ k: v
1157
+ for k, v in [
1158
+ ("max_results", max_results),
1159
+ ("pagination_token", pagination_token),
1160
+ ("user.fields", user_fields),
1161
+ ("expansions", expansions),
1162
+ ("tweet.fields", tweet_fields),
1163
+ ]
1164
+ if v is not None
1165
+ }
1166
+ response = self._get(url, params=query_params)
1167
+ response.raise_for_status()
1168
+ return response.json()
1169
+
1170
+ def find_tweets_that_quote_atweet(
1171
+ self,
1172
+ id,
1173
+ max_results=None,
1174
+ pagination_token=None,
1175
+ exclude=None,
1176
+ tweet_fields=None,
1177
+ expansions=None,
1178
+ media_fields=None,
1179
+ poll_fields=None,
1180
+ user_fields=None,
1181
+ place_fields=None,
1182
+ ) -> dict[str, Any]:
1183
+ """
1184
+
1185
+ Retrieves a list of quote Tweets for a specified Tweet ID, allowing for optional parameters to customize the results with fields like tweet fields, media fields, and user expansions, and supports pagination for handling large responses.
1186
+
1187
+ Args:
1188
+ id (string): id
1189
+ max_results (integer): Specifies the maximum number of quote Tweets to return in the response, ranging from 1 to 100, with a default of 10.
1190
+ pagination_token (string): pagination_token is an optional query parameter used to retrieve the next page of results by setting it to the next_token value returned in the previous response.
1191
+ exclude (array): Optional array parameter to exclude specific types of Tweet results from the response, such as retweets. Example: "['replies', 'retweets']".
1192
+ tweet_fields (array): A comma separated list of Tweet fields to display. Example: "['article', 'attachments', 'author_id', 'card_uri', 'context_annotations', 'conversation_id', 'created_at', 'edit_controls', 'edit_history_tweet_ids', 'entities', 'geo', 'id', 'in_reply_to_user_id', 'lang', 'non_public_metrics', 'note_tweet', 'organic_metrics', 'possibly_sensitive', 'promoted_metrics', 'public_metrics', 'referenced_tweets', 'reply_settings', 'scopes', 'source', 'text', 'username', 'withheld']".
1193
+ expansions (array): A comma separated list of fields to expand. Example: "['article.cover_media', 'article.media_entities', 'attachments.media_keys', 'attachments.media_source_tweet', 'attachments.poll_ids', 'author_id', 'edit_history_tweet_ids', 'entities.mentions.username', 'geo.place_id', 'in_reply_to_user_id', 'entities.note.mentions.username', 'referenced_tweets.id', 'referenced_tweets.id.author_id', 'author_screen_name']".
1194
+ media_fields (array): A comma separated list of Media fields to display. Example: "['alt_text', 'duration_ms', 'height', 'media_key', 'non_public_metrics', 'organic_metrics', 'preview_image_url', 'promoted_metrics', 'public_metrics', 'type', 'url', 'variants', 'width']".
1195
+ poll_fields (array): A comma separated list of Poll fields to display. Example: "['duration_minutes', 'end_datetime', 'id', 'options', 'voting_status']".
1196
+ user_fields (array): A comma separated list of User fields to display. Example: "['affiliation', 'connection_status', 'created_at', 'description', 'entities', 'id', 'location', 'most_recent_tweet_id', 'name', 'pinned_tweet_id', 'profile_banner_url', 'profile_image_url', 'protected', 'public_metrics', 'receives_your_dm', 'subscription_type', 'url', 'username', 'verified', 'verified_type', 'withheld']".
1197
+ place_fields (array): A comma separated list of Place fields to display. Example: "['contained_within', 'country', 'country_code', 'full_name', 'geo', 'id', 'name', 'place_type']".
1198
+
1199
+ Returns:
1200
+ dict[str, Any]: The request has succeeded.
1201
+
1202
+ Raises:
1203
+ HTTPError: Raised when the API request fails (e.g., non-2XX status code).
1204
+ JSONDecodeError: Raised if the response body cannot be parsed as JSON.
1205
+
1206
+ Tags:
1207
+ Tweets
1208
+ """
1209
+ if id is None:
1210
+ raise ValueError("Missing required parameter 'id'.")
1211
+ url = f"{self.main_app_client.base_url}/2/tweets/{id}/quote_tweets"
1212
+ query_params = {
1213
+ k: v
1214
+ for k, v in [
1215
+ ("max_results", max_results),
1216
+ ("pagination_token", pagination_token),
1217
+ ("exclude", exclude),
1218
+ ("tweet.fields", tweet_fields),
1219
+ ("expansions", expansions),
1220
+ ("media.fields", media_fields),
1221
+ ("poll.fields", poll_fields),
1222
+ ("user.fields", user_fields),
1223
+ ("place.fields", place_fields),
1224
+ ]
1225
+ if v is not None
1226
+ }
1227
+ response = self._get(url, params=query_params)
1228
+ response.raise_for_status()
1229
+ return response.json()
1230
+
1231
+ def tweets_id_retweeting_users(
1232
+ self,
1233
+ id,
1234
+ max_results=None,
1235
+ pagination_token=None,
1236
+ user_fields=None,
1237
+ expansions=None,
1238
+ tweet_fields=None,
1239
+ ) -> dict[str, Any]:
1240
+ """
1241
+
1242
+ Retrieves a list of User objects representing users who have retweeted the Tweet specified by the given Tweet ID.
1243
+
1244
+ Args:
1245
+ id (string): id
1246
+ max_results (integer): The `max_results` parameter specifies the maximum number of users to return who have retweeted the specified Tweet, with a default value of 100 and a required range of 1 to 100.
1247
+ pagination_token (string): Optional parameter used to retrieve the next page of results by passing the value of the `next_token` returned in the previous response.
1248
+ user_fields (array): A comma separated list of User fields to display. Example: "['affiliation', 'connection_status', 'created_at', 'description', 'entities', 'id', 'location', 'most_recent_tweet_id', 'name', 'pinned_tweet_id', 'profile_banner_url', 'profile_image_url', 'protected', 'public_metrics', 'receives_your_dm', 'subscription_type', 'url', 'username', 'verified', 'verified_type', 'withheld']".
1249
+ expansions (array): A comma separated list of fields to expand. Example: "['affiliation.user_id', 'most_recent_tweet_id', 'pinned_tweet_id']".
1250
+ tweet_fields (array): A comma separated list of Tweet fields to display. Example: "['article', 'attachments', 'author_id', 'card_uri', 'context_annotations', 'conversation_id', 'created_at', 'edit_controls', 'edit_history_tweet_ids', 'entities', 'geo', 'id', 'in_reply_to_user_id', 'lang', 'non_public_metrics', 'note_tweet', 'organic_metrics', 'possibly_sensitive', 'promoted_metrics', 'public_metrics', 'referenced_tweets', 'reply_settings', 'scopes', 'source', 'text', 'username', 'withheld']".
1251
+
1252
+ Returns:
1253
+ dict[str, Any]: The request has succeeded.
1254
+
1255
+ Raises:
1256
+ HTTPError: Raised when the API request fails (e.g., non-2XX status code).
1257
+ JSONDecodeError: Raised if the response body cannot be parsed as JSON.
1258
+
1259
+ Tags:
1260
+ Users
1261
+ """
1262
+ if id is None:
1263
+ raise ValueError("Missing required parameter 'id'.")
1264
+ url = f"{self.main_app_client.base_url}/2/tweets/{id}/retweeted_by"
1265
+ query_params = {
1266
+ k: v
1267
+ for k, v in [
1268
+ ("max_results", max_results),
1269
+ ("pagination_token", pagination_token),
1270
+ ("user.fields", user_fields),
1271
+ ("expansions", expansions),
1272
+ ("tweet.fields", tweet_fields),
1273
+ ]
1274
+ if v is not None
1275
+ }
1276
+ response = self._get(url, params=query_params)
1277
+ response.raise_for_status()
1278
+ return response.json()
1279
+
1280
+ def find_tweets_that_retweet_atweet(
1281
+ self,
1282
+ id,
1283
+ max_results=None,
1284
+ pagination_token=None,
1285
+ tweet_fields=None,
1286
+ expansions=None,
1287
+ media_fields=None,
1288
+ poll_fields=None,
1289
+ user_fields=None,
1290
+ place_fields=None,
1291
+ ) -> dict[str, Any]:
1292
+ """
1293
+
1294
+ Retrieves a list of retweets for a specified Tweet ID, optionally allowing for pagination and customization of returned fields via query parameters.
1295
+
1296
+ Args:
1297
+ id (string): id
1298
+ max_results (integer): Specifies the maximum number of retweets to return per request, with a default of 100 and a maximum value of 100.
1299
+ pagination_token (string): Used to request the next page of results, set this parameter to the `next_token` value returned in the previous response.
1300
+ tweet_fields (array): A comma separated list of Tweet fields to display. Example: "['article', 'attachments', 'author_id', 'card_uri', 'context_annotations', 'conversation_id', 'created_at', 'edit_controls', 'edit_history_tweet_ids', 'entities', 'geo', 'id', 'in_reply_to_user_id', 'lang', 'non_public_metrics', 'note_tweet', 'organic_metrics', 'possibly_sensitive', 'promoted_metrics', 'public_metrics', 'referenced_tweets', 'reply_settings', 'scopes', 'source', 'text', 'username', 'withheld']".
1301
+ expansions (array): A comma separated list of fields to expand. Example: "['article.cover_media', 'article.media_entities', 'attachments.media_keys', 'attachments.media_source_tweet', 'attachments.poll_ids', 'author_id', 'edit_history_tweet_ids', 'entities.mentions.username', 'geo.place_id', 'in_reply_to_user_id', 'entities.note.mentions.username', 'referenced_tweets.id', 'referenced_tweets.id.author_id', 'author_screen_name']".
1302
+ media_fields (array): A comma separated list of Media fields to display. Example: "['alt_text', 'duration_ms', 'height', 'media_key', 'non_public_metrics', 'organic_metrics', 'preview_image_url', 'promoted_metrics', 'public_metrics', 'type', 'url', 'variants', 'width']".
1303
+ poll_fields (array): A comma separated list of Poll fields to display. Example: "['duration_minutes', 'end_datetime', 'id', 'options', 'voting_status']".
1304
+ user_fields (array): A comma separated list of User fields to display. Example: "['affiliation', 'connection_status', 'created_at', 'description', 'entities', 'id', 'location', 'most_recent_tweet_id', 'name', 'pinned_tweet_id', 'profile_banner_url', 'profile_image_url', 'protected', 'public_metrics', 'receives_your_dm', 'subscription_type', 'url', 'username', 'verified', 'verified_type', 'withheld']".
1305
+ place_fields (array): A comma separated list of Place fields to display. Example: "['contained_within', 'country', 'country_code', 'full_name', 'geo', 'id', 'name', 'place_type']".
1306
+
1307
+ Returns:
1308
+ dict[str, Any]: The request has succeeded.
1309
+
1310
+ Raises:
1311
+ HTTPError: Raised when the API request fails (e.g., non-2XX status code).
1312
+ JSONDecodeError: Raised if the response body cannot be parsed as JSON.
1313
+
1314
+ Tags:
1315
+ Tweets
1316
+ """
1317
+ if id is None:
1318
+ raise ValueError("Missing required parameter 'id'.")
1319
+ url = f"{self.main_app_client.base_url}/2/tweets/{id}/retweets"
1320
+ query_params = {
1321
+ k: v
1322
+ for k, v in [
1323
+ ("max_results", max_results),
1324
+ ("pagination_token", pagination_token),
1325
+ ("tweet.fields", tweet_fields),
1326
+ ("expansions", expansions),
1327
+ ("media.fields", media_fields),
1328
+ ("poll.fields", poll_fields),
1329
+ ("user.fields", user_fields),
1330
+ ("place.fields", place_fields),
1331
+ ]
1332
+ if v is not None
1333
+ }
1334
+ response = self._get(url, params=query_params)
1335
+ response.raise_for_status()
1336
+ return response.json()
1337
+
1338
+ def hide_reply_by_id(self, tweet_id, hidden=None) -> dict[str, Any]:
1339
+ """
1340
+
1341
+ Hides or unhides a reply to a specified Tweet by its tweet_id.
1342
+
1343
+ Args:
1344
+ tweet_id (string): tweet_id
1345
+ hidden (boolean): hidden
1346
+
1347
+ Returns:
1348
+ dict[str, Any]: The request has succeeded.
1349
+
1350
+ Raises:
1351
+ HTTPError: Raised when the API request fails (e.g., non-2XX status code).
1352
+ JSONDecodeError: Raised if the response body cannot be parsed as JSON.
1353
+
1354
+ Tags:
1355
+ Tweets
1356
+ """
1357
+ if tweet_id is None:
1358
+ raise ValueError("Missing required parameter 'tweet_id'.")
1359
+ request_body_data = None
1360
+ request_body_data = {"hidden": hidden}
1361
+ request_body_data = {
1362
+ k: v for k, v in request_body_data.items() if v is not None
1363
+ }
1364
+ url = f"{self.main_app_client.base_url}/2/tweets/{tweet_id}/hidden"
1365
+ query_params = {}
1366
+ response = self._put(
1367
+ url,
1368
+ data=request_body_data,
1369
+ params=query_params,
1370
+ content_type="application/json",
1371
+ )
1372
+ response.raise_for_status()
1373
+ return response.json()
1374
+
1375
+ def list_tools(self):
1376
+ return [
1377
+ self.find_tweets_by_id,
1378
+ self.create_tweet,
1379
+ self.get_tweets_compliance_stream,
1380
+ self.tweet_counts_full_archive_search,
1381
+ self.tweet_counts_recent_search,
1382
+ self.get_tweets_firehose_stream,
1383
+ self.get_tweets_firehose_stream_lang_en,
1384
+ self.get_tweets_firehose_stream_lang_ja,
1385
+ self.get_tweets_firehose_stream_lang_ko,
1386
+ self.get_tweets_firehose_stream_lang_pt,
1387
+ self.get_tweets_label_stream,
1388
+ self.sample_stream,
1389
+ self.get_tweets_sample_stream,
1390
+ self.tweets_fullarchive_search,
1391
+ self.tweets_recent_search,
1392
+ self.search_stream,
1393
+ self.get_rules,
1394
+ self.add_or_delete_rules,
1395
+ self.get_rule_count,
1396
+ self.delete_tweet_by_id,
1397
+ self.find_tweet_by_id,
1398
+ self.tweets_id_liking_users,
1399
+ self.find_tweets_that_quote_atweet,
1400
+ self.tweets_id_retweeting_users,
1401
+ self.find_tweets_that_retweet_atweet,
1402
+ self.hide_reply_by_id,
1403
+ ]