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.
- universal_mcp/applications/ahrefs/README.md +51 -0
- universal_mcp/applications/ahrefs/__init__.py +1 -0
- universal_mcp/applications/ahrefs/app.py +2291 -0
- universal_mcp/applications/airtable/README.md +22 -0
- universal_mcp/applications/airtable/__init__.py +1 -0
- universal_mcp/applications/airtable/app.py +479 -0
- universal_mcp/applications/apollo/README.md +44 -0
- universal_mcp/applications/apollo/__init__.py +1 -0
- universal_mcp/applications/apollo/app.py +1847 -0
- universal_mcp/applications/asana/README.md +199 -0
- universal_mcp/applications/asana/__init__.py +1 -0
- universal_mcp/applications/asana/app.py +9509 -0
- universal_mcp/applications/aws-s3/README.md +0 -0
- universal_mcp/applications/aws-s3/__init__.py +1 -0
- universal_mcp/applications/aws-s3/app.py +552 -0
- universal_mcp/applications/bill/README.md +0 -0
- universal_mcp/applications/bill/__init__.py +1 -0
- universal_mcp/applications/bill/app.py +8705 -0
- universal_mcp/applications/box/README.md +307 -0
- universal_mcp/applications/box/__init__.py +1 -0
- universal_mcp/applications/box/app.py +15987 -0
- universal_mcp/applications/braze/README.md +106 -0
- universal_mcp/applications/braze/__init__.py +1 -0
- universal_mcp/applications/braze/app.py +4754 -0
- universal_mcp/applications/cal-com-v2/README.md +150 -0
- universal_mcp/applications/cal-com-v2/__init__.py +1 -0
- universal_mcp/applications/cal-com-v2/app.py +5541 -0
- universal_mcp/applications/calendly/README.md +53 -0
- universal_mcp/applications/calendly/__init__.py +1 -0
- universal_mcp/applications/calendly/app.py +1436 -0
- universal_mcp/applications/canva/README.md +43 -0
- universal_mcp/applications/canva/__init__.py +1 -0
- universal_mcp/applications/canva/app.py +941 -0
- universal_mcp/applications/clickup/README.md +135 -0
- universal_mcp/applications/clickup/__init__.py +1 -0
- universal_mcp/applications/clickup/app.py +5009 -0
- universal_mcp/applications/coda/README.md +108 -0
- universal_mcp/applications/coda/__init__.py +1 -0
- universal_mcp/applications/coda/app.py +3671 -0
- universal_mcp/applications/confluence/README.md +198 -0
- universal_mcp/applications/confluence/__init__.py +1 -0
- universal_mcp/applications/confluence/app.py +6273 -0
- universal_mcp/applications/contentful/README.md +17 -0
- universal_mcp/applications/contentful/__init__.py +1 -0
- universal_mcp/applications/contentful/app.py +364 -0
- universal_mcp/applications/crustdata/README.md +25 -0
- universal_mcp/applications/crustdata/__init__.py +1 -0
- universal_mcp/applications/crustdata/app.py +586 -0
- universal_mcp/applications/dialpad/README.md +202 -0
- universal_mcp/applications/dialpad/__init__.py +1 -0
- universal_mcp/applications/dialpad/app.py +5949 -0
- universal_mcp/applications/digitalocean/README.md +463 -0
- universal_mcp/applications/digitalocean/__init__.py +1 -0
- universal_mcp/applications/digitalocean/app.py +20835 -0
- universal_mcp/applications/domain-checker/README.md +13 -0
- universal_mcp/applications/domain-checker/__init__.py +1 -0
- universal_mcp/applications/domain-checker/app.py +265 -0
- universal_mcp/applications/e2b/README.md +12 -0
- universal_mcp/applications/e2b/__init__.py +1 -0
- universal_mcp/applications/e2b/app.py +187 -0
- universal_mcp/applications/elevenlabs/README.md +88 -0
- universal_mcp/applications/elevenlabs/__init__.py +1 -0
- universal_mcp/applications/elevenlabs/app.py +3235 -0
- universal_mcp/applications/exa/README.md +15 -0
- universal_mcp/applications/exa/__init__.py +1 -0
- universal_mcp/applications/exa/app.py +221 -0
- universal_mcp/applications/falai/README.md +17 -0
- universal_mcp/applications/falai/__init__.py +1 -0
- universal_mcp/applications/falai/app.py +331 -0
- universal_mcp/applications/figma/README.md +49 -0
- universal_mcp/applications/figma/__init__.py +1 -0
- universal_mcp/applications/figma/app.py +1090 -0
- universal_mcp/applications/firecrawl/README.md +20 -0
- universal_mcp/applications/firecrawl/__init__.py +1 -0
- universal_mcp/applications/firecrawl/app.py +514 -0
- universal_mcp/applications/fireflies/README.md +25 -0
- universal_mcp/applications/fireflies/__init__.py +1 -0
- universal_mcp/applications/fireflies/app.py +506 -0
- universal_mcp/applications/fpl/README.md +23 -0
- universal_mcp/applications/fpl/__init__.py +1 -0
- universal_mcp/applications/fpl/app.py +1327 -0
- universal_mcp/applications/fpl/utils/api.py +142 -0
- universal_mcp/applications/fpl/utils/fixtures.py +629 -0
- universal_mcp/applications/fpl/utils/helper.py +982 -0
- universal_mcp/applications/fpl/utils/league_utils.py +546 -0
- universal_mcp/applications/fpl/utils/position_utils.py +68 -0
- universal_mcp/applications/ghost-content/README.md +25 -0
- universal_mcp/applications/ghost-content/__init__.py +1 -0
- universal_mcp/applications/ghost-content/app.py +654 -0
- universal_mcp/applications/github/README.md +1049 -0
- universal_mcp/applications/github/__init__.py +1 -0
- universal_mcp/applications/github/app.py +50600 -0
- universal_mcp/applications/gong/README.md +63 -0
- universal_mcp/applications/gong/__init__.py +1 -0
- universal_mcp/applications/gong/app.py +2297 -0
- universal_mcp/applications/google-ads/README.md +0 -0
- universal_mcp/applications/google-ads/__init__.py +1 -0
- universal_mcp/applications/google-ads/app.py +23 -0
- universal_mcp/applications/google-calendar/README.md +21 -0
- universal_mcp/applications/google-calendar/__init__.py +1 -0
- universal_mcp/applications/google-calendar/app.py +574 -0
- universal_mcp/applications/google-docs/README.md +25 -0
- universal_mcp/applications/google-docs/__init__.py +1 -0
- universal_mcp/applications/google-docs/app.py +760 -0
- universal_mcp/applications/google-drive/README.md +68 -0
- universal_mcp/applications/google-drive/__init__.py +1 -0
- universal_mcp/applications/google-drive/app.py +4936 -0
- universal_mcp/applications/google-gemini/README.md +25 -0
- universal_mcp/applications/google-gemini/__init__.py +1 -0
- universal_mcp/applications/google-gemini/app.py +663 -0
- universal_mcp/applications/google-mail/README.md +31 -0
- universal_mcp/applications/google-mail/__init__.py +1 -0
- universal_mcp/applications/google-mail/app.py +1354 -0
- universal_mcp/applications/google-searchconsole/README.md +21 -0
- universal_mcp/applications/google-searchconsole/__init__.py +1 -0
- universal_mcp/applications/google-searchconsole/app.py +320 -0
- universal_mcp/applications/google-sheet/README.md +36 -0
- universal_mcp/applications/google-sheet/__init__.py +1 -0
- universal_mcp/applications/google-sheet/app.py +1941 -0
- universal_mcp/applications/hashnode/README.md +20 -0
- universal_mcp/applications/hashnode/__init__.py +1 -0
- universal_mcp/applications/hashnode/app.py +455 -0
- universal_mcp/applications/heygen/README.md +44 -0
- universal_mcp/applications/heygen/__init__.py +1 -0
- universal_mcp/applications/heygen/app.py +961 -0
- universal_mcp/applications/http-tools/README.md +16 -0
- universal_mcp/applications/http-tools/__init__.py +1 -0
- universal_mcp/applications/http-tools/app.py +153 -0
- universal_mcp/applications/hubspot/README.md +239 -0
- universal_mcp/applications/hubspot/__init__.py +1 -0
- universal_mcp/applications/hubspot/app.py +416 -0
- universal_mcp/applications/jira/README.md +600 -0
- universal_mcp/applications/jira/__init__.py +1 -0
- universal_mcp/applications/jira/app.py +28804 -0
- universal_mcp/applications/klaviyo/README.md +313 -0
- universal_mcp/applications/klaviyo/__init__.py +1 -0
- universal_mcp/applications/klaviyo/app.py +11236 -0
- universal_mcp/applications/linkedin/README.md +15 -0
- universal_mcp/applications/linkedin/__init__.py +1 -0
- universal_mcp/applications/linkedin/app.py +243 -0
- universal_mcp/applications/mailchimp/README.md +281 -0
- universal_mcp/applications/mailchimp/__init__.py +1 -0
- universal_mcp/applications/mailchimp/app.py +10937 -0
- universal_mcp/applications/markitdown/README.md +12 -0
- universal_mcp/applications/markitdown/__init__.py +1 -0
- universal_mcp/applications/markitdown/app.py +63 -0
- universal_mcp/applications/miro/README.md +151 -0
- universal_mcp/applications/miro/__init__.py +1 -0
- universal_mcp/applications/miro/app.py +5429 -0
- universal_mcp/applications/ms-teams/README.md +42 -0
- universal_mcp/applications/ms-teams/__init__.py +1 -0
- universal_mcp/applications/ms-teams/app.py +1823 -0
- universal_mcp/applications/neon/README.md +74 -0
- universal_mcp/applications/neon/__init__.py +1 -0
- universal_mcp/applications/neon/app.py +2018 -0
- universal_mcp/applications/notion/README.md +30 -0
- universal_mcp/applications/notion/__init__.py +1 -0
- universal_mcp/applications/notion/app.py +527 -0
- universal_mcp/applications/openai/README.md +22 -0
- universal_mcp/applications/openai/__init__.py +1 -0
- universal_mcp/applications/openai/app.py +759 -0
- universal_mcp/applications/outlook/README.md +20 -0
- universal_mcp/applications/outlook/__init__.py +1 -0
- universal_mcp/applications/outlook/app.py +444 -0
- universal_mcp/applications/perplexity/README.md +12 -0
- universal_mcp/applications/perplexity/__init__.py +1 -0
- universal_mcp/applications/perplexity/app.py +65 -0
- universal_mcp/applications/pipedrive/README.md +284 -0
- universal_mcp/applications/pipedrive/__init__.py +1 -0
- universal_mcp/applications/pipedrive/app.py +12924 -0
- universal_mcp/applications/posthog/README.md +132 -0
- universal_mcp/applications/posthog/__init__.py +1 -0
- universal_mcp/applications/posthog/app.py +7125 -0
- universal_mcp/applications/reddit/README.md +135 -0
- universal_mcp/applications/reddit/__init__.py +1 -0
- universal_mcp/applications/reddit/app.py +4652 -0
- universal_mcp/applications/replicate/README.md +18 -0
- universal_mcp/applications/replicate/__init__.py +1 -0
- universal_mcp/applications/replicate/app.py +495 -0
- universal_mcp/applications/resend/README.md +40 -0
- universal_mcp/applications/resend/__init__.py +1 -0
- universal_mcp/applications/resend/app.py +881 -0
- universal_mcp/applications/retell/README.md +21 -0
- universal_mcp/applications/retell/__init__.py +1 -0
- universal_mcp/applications/retell/app.py +333 -0
- universal_mcp/applications/rocketlane/README.md +70 -0
- universal_mcp/applications/rocketlane/__init__.py +1 -0
- universal_mcp/applications/rocketlane/app.py +4346 -0
- universal_mcp/applications/semanticscholar/README.md +25 -0
- universal_mcp/applications/semanticscholar/__init__.py +1 -0
- universal_mcp/applications/semanticscholar/app.py +482 -0
- universal_mcp/applications/semrush/README.md +44 -0
- universal_mcp/applications/semrush/__init__.py +1 -0
- universal_mcp/applications/semrush/app.py +2081 -0
- universal_mcp/applications/sendgrid/README.md +362 -0
- universal_mcp/applications/sendgrid/__init__.py +1 -0
- universal_mcp/applications/sendgrid/app.py +9752 -0
- universal_mcp/applications/sentry/README.md +186 -0
- universal_mcp/applications/sentry/__init__.py +1 -0
- universal_mcp/applications/sentry/app.py +7471 -0
- universal_mcp/applications/serpapi/README.md +14 -0
- universal_mcp/applications/serpapi/__init__.py +1 -0
- universal_mcp/applications/serpapi/app.py +293 -0
- universal_mcp/applications/sharepoint/README.md +0 -0
- universal_mcp/applications/sharepoint/__init__.py +1 -0
- universal_mcp/applications/sharepoint/app.py +215 -0
- universal_mcp/applications/shopify/README.md +321 -0
- universal_mcp/applications/shopify/__init__.py +1 -0
- universal_mcp/applications/shopify/app.py +15392 -0
- universal_mcp/applications/shortcut/README.md +128 -0
- universal_mcp/applications/shortcut/__init__.py +1 -0
- universal_mcp/applications/shortcut/app.py +4478 -0
- universal_mcp/applications/slack/README.md +0 -0
- universal_mcp/applications/slack/__init__.py +1 -0
- universal_mcp/applications/slack/app.py +570 -0
- universal_mcp/applications/spotify/README.md +91 -0
- universal_mcp/applications/spotify/__init__.py +1 -0
- universal_mcp/applications/spotify/app.py +2526 -0
- universal_mcp/applications/supabase/README.md +87 -0
- universal_mcp/applications/supabase/__init__.py +1 -0
- universal_mcp/applications/supabase/app.py +2970 -0
- universal_mcp/applications/tavily/README.md +12 -0
- universal_mcp/applications/tavily/__init__.py +1 -0
- universal_mcp/applications/tavily/app.py +51 -0
- universal_mcp/applications/trello/README.md +266 -0
- universal_mcp/applications/trello/__init__.py +1 -0
- universal_mcp/applications/trello/app.py +10875 -0
- universal_mcp/applications/twillo/README.md +0 -0
- universal_mcp/applications/twillo/__init__.py +1 -0
- universal_mcp/applications/twillo/app.py +269 -0
- universal_mcp/applications/twitter/README.md +100 -0
- universal_mcp/applications/twitter/__init__.py +1 -0
- universal_mcp/applications/twitter/api_segments/__init__.py +0 -0
- universal_mcp/applications/twitter/api_segments/api_segment_base.py +51 -0
- universal_mcp/applications/twitter/api_segments/compliance_api.py +122 -0
- universal_mcp/applications/twitter/api_segments/dm_conversations_api.py +255 -0
- universal_mcp/applications/twitter/api_segments/dm_events_api.py +140 -0
- universal_mcp/applications/twitter/api_segments/likes_api.py +159 -0
- universal_mcp/applications/twitter/api_segments/lists_api.py +395 -0
- universal_mcp/applications/twitter/api_segments/openapi_json_api.py +34 -0
- universal_mcp/applications/twitter/api_segments/spaces_api.py +309 -0
- universal_mcp/applications/twitter/api_segments/trends_api.py +40 -0
- universal_mcp/applications/twitter/api_segments/tweets_api.py +1403 -0
- universal_mcp/applications/twitter/api_segments/usage_api.py +40 -0
- universal_mcp/applications/twitter/api_segments/users_api.py +1498 -0
- universal_mcp/applications/twitter/app.py +46 -0
- universal_mcp/applications/unipile/README.md +28 -0
- universal_mcp/applications/unipile/__init__.py +1 -0
- universal_mcp/applications/unipile/app.py +829 -0
- universal_mcp/applications/whatsapp/README.md +23 -0
- universal_mcp/applications/whatsapp/__init__.py +1 -0
- universal_mcp/applications/whatsapp/app.py +595 -0
- universal_mcp/applications/whatsapp-business/README.md +34 -0
- universal_mcp/applications/whatsapp-business/__init__.py +1 -0
- universal_mcp/applications/whatsapp-business/app.py +1065 -0
- universal_mcp/applications/wrike/README.md +46 -0
- universal_mcp/applications/wrike/__init__.py +1 -0
- universal_mcp/applications/wrike/app.py +1583 -0
- universal_mcp/applications/youtube/README.md +57 -0
- universal_mcp/applications/youtube/__init__.py +1 -0
- universal_mcp/applications/youtube/app.py +1696 -0
- universal_mcp/applications/zenquotes/README.md +12 -0
- universal_mcp/applications/zenquotes/__init__.py +1 -0
- universal_mcp/applications/zenquotes/app.py +31 -0
- universal_mcp_applications-0.1.1.dist-info/METADATA +172 -0
- universal_mcp_applications-0.1.1.dist-info/RECORD +268 -0
- universal_mcp_applications-0.1.1.dist-info/WHEEL +4 -0
- universal_mcp_applications-0.1.1.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
|
|
3
|
+
from .api_segment_base import APISegmentBase
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class DmConversationsApi(APISegmentBase):
|
|
7
|
+
def __init__(self, main_app_client: Any):
|
|
8
|
+
super().__init__(main_app_client)
|
|
9
|
+
|
|
10
|
+
def dm_conversation_id_create(
|
|
11
|
+
self, conversation_type=None, message=None, participant_ids=None
|
|
12
|
+
) -> dict[str, Any]:
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
Creates a new group Direct Message conversation and sends an initial message to the specified participants.
|
|
16
|
+
|
|
17
|
+
Args:
|
|
18
|
+
conversation_type (string): The conversation type that is being created.
|
|
19
|
+
message (string): message
|
|
20
|
+
participant_ids (array): Participants for the DM Conversation.
|
|
21
|
+
|
|
22
|
+
Returns:
|
|
23
|
+
dict[str, Any]: The request has succeeded.
|
|
24
|
+
|
|
25
|
+
Raises:
|
|
26
|
+
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
27
|
+
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
28
|
+
|
|
29
|
+
Tags:
|
|
30
|
+
Direct Messages
|
|
31
|
+
"""
|
|
32
|
+
request_body_data = None
|
|
33
|
+
request_body_data = {
|
|
34
|
+
"conversation_type": conversation_type,
|
|
35
|
+
"message": message,
|
|
36
|
+
"participant_ids": participant_ids,
|
|
37
|
+
}
|
|
38
|
+
request_body_data = {
|
|
39
|
+
k: v for k, v in request_body_data.items() if v is not None
|
|
40
|
+
}
|
|
41
|
+
url = f"{self.main_app_client.base_url}/2/dm_conversations"
|
|
42
|
+
query_params = {}
|
|
43
|
+
response = self._post(
|
|
44
|
+
url,
|
|
45
|
+
data=request_body_data,
|
|
46
|
+
params=query_params,
|
|
47
|
+
content_type="application/json",
|
|
48
|
+
)
|
|
49
|
+
response.raise_for_status()
|
|
50
|
+
return response.json()
|
|
51
|
+
|
|
52
|
+
def get_dm_conversations_with_participant_id_dm_events(
|
|
53
|
+
self,
|
|
54
|
+
participant_id,
|
|
55
|
+
max_results=None,
|
|
56
|
+
pagination_token=None,
|
|
57
|
+
event_types=None,
|
|
58
|
+
dm_event_fields=None,
|
|
59
|
+
expansions=None,
|
|
60
|
+
media_fields=None,
|
|
61
|
+
user_fields=None,
|
|
62
|
+
tweet_fields=None,
|
|
63
|
+
) -> dict[str, Any]:
|
|
64
|
+
"""
|
|
65
|
+
|
|
66
|
+
Retrieves a list of direct message events for a conversation with a specific participant, allowing for optional filtering by event types and pagination.
|
|
67
|
+
|
|
68
|
+
Args:
|
|
69
|
+
participant_id (string): participant_id
|
|
70
|
+
max_results (integer): The maximum number of direct message events to return in the response, with a default of 100.
|
|
71
|
+
pagination_token (string): The opaque token used to retrieve the next page of direct message events in the conversation with the specified participant.
|
|
72
|
+
event_types (array): An optional array parameter specifying the types of DM events to include, such as "MessageCreate", "ParticipantsLeave", and "ParticipantsJoin", with default values of "MessageCreate", "ParticipantsLeave", and "ParticipantsJoin". Example: "['MessageCreate', 'ParticipantsLeave']".
|
|
73
|
+
dm_event_fields (array): A comma separated list of DmEvent fields to display. Example: "['attachments', 'created_at', 'dm_conversation_id', 'entities', 'event_type', 'id', 'participant_ids', 'referenced_tweets', 'sender_id', 'text']".
|
|
74
|
+
expansions (array): A comma separated list of fields to expand. Example: "['attachments.media_keys', 'participant_ids', 'referenced_tweets.id', 'sender_id']".
|
|
75
|
+
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']".
|
|
76
|
+
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']".
|
|
77
|
+
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']".
|
|
78
|
+
|
|
79
|
+
Returns:
|
|
80
|
+
dict[str, Any]: The request has succeeded.
|
|
81
|
+
|
|
82
|
+
Raises:
|
|
83
|
+
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
84
|
+
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
85
|
+
|
|
86
|
+
Tags:
|
|
87
|
+
Direct Messages
|
|
88
|
+
"""
|
|
89
|
+
if participant_id is None:
|
|
90
|
+
raise ValueError("Missing required parameter 'participant_id'.")
|
|
91
|
+
url = f"{self.main_app_client.base_url}/2/dm_conversations/with/{participant_id}/dm_events"
|
|
92
|
+
query_params = {
|
|
93
|
+
k: v
|
|
94
|
+
for k, v in [
|
|
95
|
+
("max_results", max_results),
|
|
96
|
+
("pagination_token", pagination_token),
|
|
97
|
+
("event_types", event_types),
|
|
98
|
+
("dm_event.fields", dm_event_fields),
|
|
99
|
+
("expansions", expansions),
|
|
100
|
+
("media.fields", media_fields),
|
|
101
|
+
("user.fields", user_fields),
|
|
102
|
+
("tweet.fields", tweet_fields),
|
|
103
|
+
]
|
|
104
|
+
if v is not None
|
|
105
|
+
}
|
|
106
|
+
response = self._get(url, params=query_params)
|
|
107
|
+
response.raise_for_status()
|
|
108
|
+
return response.json()
|
|
109
|
+
|
|
110
|
+
def dm_conversation_with_user_event_id_create(
|
|
111
|
+
self, participant_id, attachments=None, text=None
|
|
112
|
+
) -> dict[str, Any]:
|
|
113
|
+
"""
|
|
114
|
+
|
|
115
|
+
Creates a new one-to-one Direct Message conversation with the specified participant or adds a message to an existing conversation using the X API.
|
|
116
|
+
|
|
117
|
+
Args:
|
|
118
|
+
participant_id (string): participant_id
|
|
119
|
+
attachments (array): Attachments to a DM Event.
|
|
120
|
+
text (string): Text of the message.
|
|
121
|
+
|
|
122
|
+
Returns:
|
|
123
|
+
dict[str, Any]: The request has succeeded.
|
|
124
|
+
|
|
125
|
+
Raises:
|
|
126
|
+
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
127
|
+
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
128
|
+
|
|
129
|
+
Tags:
|
|
130
|
+
Direct Messages
|
|
131
|
+
"""
|
|
132
|
+
if participant_id is None:
|
|
133
|
+
raise ValueError("Missing required parameter 'participant_id'.")
|
|
134
|
+
request_body_data = None
|
|
135
|
+
request_body_data = {"attachments": attachments, "text": text}
|
|
136
|
+
request_body_data = {
|
|
137
|
+
k: v for k, v in request_body_data.items() if v is not None
|
|
138
|
+
}
|
|
139
|
+
url = f"{self.main_app_client.base_url}/2/dm_conversations/with/{participant_id}/messages"
|
|
140
|
+
query_params = {}
|
|
141
|
+
response = self._post(
|
|
142
|
+
url,
|
|
143
|
+
data=request_body_data,
|
|
144
|
+
params=query_params,
|
|
145
|
+
content_type="application/json",
|
|
146
|
+
)
|
|
147
|
+
response.raise_for_status()
|
|
148
|
+
return response.json()
|
|
149
|
+
|
|
150
|
+
def dm_conversation_by_id_event_id_create(
|
|
151
|
+
self, dm_conversation_id, attachments=None, text=None
|
|
152
|
+
) -> dict[str, Any]:
|
|
153
|
+
"""
|
|
154
|
+
|
|
155
|
+
Creates a new Direct Message and adds it to an existing conversation specified by the provided dm_conversation_id.
|
|
156
|
+
|
|
157
|
+
Args:
|
|
158
|
+
dm_conversation_id (string): dm_conversation_id
|
|
159
|
+
attachments (array): Attachments to a DM Event.
|
|
160
|
+
text (string): Text of the message.
|
|
161
|
+
|
|
162
|
+
Returns:
|
|
163
|
+
dict[str, Any]: The request has succeeded.
|
|
164
|
+
|
|
165
|
+
Raises:
|
|
166
|
+
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
167
|
+
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
168
|
+
|
|
169
|
+
Tags:
|
|
170
|
+
Direct Messages
|
|
171
|
+
"""
|
|
172
|
+
if dm_conversation_id is None:
|
|
173
|
+
raise ValueError("Missing required parameter 'dm_conversation_id'.")
|
|
174
|
+
request_body_data = None
|
|
175
|
+
request_body_data = {"attachments": attachments, "text": text}
|
|
176
|
+
request_body_data = {
|
|
177
|
+
k: v for k, v in request_body_data.items() if v is not None
|
|
178
|
+
}
|
|
179
|
+
url = f"{self.main_app_client.base_url}/2/dm_conversations/{dm_conversation_id}/messages"
|
|
180
|
+
query_params = {}
|
|
181
|
+
response = self._post(
|
|
182
|
+
url,
|
|
183
|
+
data=request_body_data,
|
|
184
|
+
params=query_params,
|
|
185
|
+
content_type="application/json",
|
|
186
|
+
)
|
|
187
|
+
response.raise_for_status()
|
|
188
|
+
return response.json()
|
|
189
|
+
|
|
190
|
+
def get_dm_conversations_id_dm_events(
|
|
191
|
+
self,
|
|
192
|
+
id,
|
|
193
|
+
max_results=None,
|
|
194
|
+
pagination_token=None,
|
|
195
|
+
event_types=None,
|
|
196
|
+
dm_event_fields=None,
|
|
197
|
+
expansions=None,
|
|
198
|
+
media_fields=None,
|
|
199
|
+
user_fields=None,
|
|
200
|
+
tweet_fields=None,
|
|
201
|
+
) -> dict[str, Any]:
|
|
202
|
+
"""
|
|
203
|
+
|
|
204
|
+
Retrieves a list of direct message events for a specified conversation ID, allowing for optional filtering by event types and pagination.
|
|
205
|
+
|
|
206
|
+
Args:
|
|
207
|
+
id (string): id
|
|
208
|
+
max_results (integer): Limits the number of DM events returned in the response, with a default value of 100, allowing users to customize the amount of data retrieved.
|
|
209
|
+
pagination_token (string): Optional token used to paginate responses, specifying the resource to start fetching from for the next page of DM events.
|
|
210
|
+
event_types (array): Filter the types of direct message events to return, such as message creation, participants joining, or leaving; defaults to ["MessageCreate","ParticipantsLeave","ParticipantsJoin"]. Example: "['MessageCreate', 'ParticipantsLeave']".
|
|
211
|
+
dm_event_fields (array): A comma separated list of DmEvent fields to display. Example: "['attachments', 'created_at', 'dm_conversation_id', 'entities', 'event_type', 'id', 'participant_ids', 'referenced_tweets', 'sender_id', 'text']".
|
|
212
|
+
expansions (array): A comma separated list of fields to expand. Example: "['attachments.media_keys', 'participant_ids', 'referenced_tweets.id', 'sender_id']".
|
|
213
|
+
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']".
|
|
214
|
+
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']".
|
|
215
|
+
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']".
|
|
216
|
+
|
|
217
|
+
Returns:
|
|
218
|
+
dict[str, Any]: The request has succeeded.
|
|
219
|
+
|
|
220
|
+
Raises:
|
|
221
|
+
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
222
|
+
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
223
|
+
|
|
224
|
+
Tags:
|
|
225
|
+
Direct Messages
|
|
226
|
+
"""
|
|
227
|
+
if id is None:
|
|
228
|
+
raise ValueError("Missing required parameter 'id'.")
|
|
229
|
+
url = f"{self.main_app_client.base_url}/2/dm_conversations/{id}/dm_events"
|
|
230
|
+
query_params = {
|
|
231
|
+
k: v
|
|
232
|
+
for k, v in [
|
|
233
|
+
("max_results", max_results),
|
|
234
|
+
("pagination_token", pagination_token),
|
|
235
|
+
("event_types", event_types),
|
|
236
|
+
("dm_event.fields", dm_event_fields),
|
|
237
|
+
("expansions", expansions),
|
|
238
|
+
("media.fields", media_fields),
|
|
239
|
+
("user.fields", user_fields),
|
|
240
|
+
("tweet.fields", tweet_fields),
|
|
241
|
+
]
|
|
242
|
+
if v is not None
|
|
243
|
+
}
|
|
244
|
+
response = self._get(url, params=query_params)
|
|
245
|
+
response.raise_for_status()
|
|
246
|
+
return response.json()
|
|
247
|
+
|
|
248
|
+
def list_tools(self):
|
|
249
|
+
return [
|
|
250
|
+
self.dm_conversation_id_create,
|
|
251
|
+
self.get_dm_conversations_with_participant_id_dm_events,
|
|
252
|
+
self.dm_conversation_with_user_event_id_create,
|
|
253
|
+
self.dm_conversation_by_id_event_id_create,
|
|
254
|
+
self.get_dm_conversations_id_dm_events,
|
|
255
|
+
]
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
|
|
3
|
+
from .api_segment_base import APISegmentBase
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class DmEventsApi(APISegmentBase):
|
|
7
|
+
def __init__(self, main_app_client: Any):
|
|
8
|
+
super().__init__(main_app_client)
|
|
9
|
+
|
|
10
|
+
def get_dm_events(
|
|
11
|
+
self,
|
|
12
|
+
max_results=None,
|
|
13
|
+
pagination_token=None,
|
|
14
|
+
event_types=None,
|
|
15
|
+
dm_event_fields=None,
|
|
16
|
+
expansions=None,
|
|
17
|
+
media_fields=None,
|
|
18
|
+
user_fields=None,
|
|
19
|
+
tweet_fields=None,
|
|
20
|
+
) -> dict[str, Any]:
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
Retrieves a list of direct message events with optional filtering by event types, pagination, and field expansions for media, users, tweets, and DM event details.
|
|
24
|
+
|
|
25
|
+
Args:
|
|
26
|
+
max_results (integer): Limits the number of DM events returned in the response, with a default of 100 if not specified.
|
|
27
|
+
pagination_token (string): Optional token used to specify the starting point for paginating the response of DM events.
|
|
28
|
+
event_types (array): An optional array parameter specifying the types of events to retrieve, defaulting to ["MessageCreate", "ParticipantsLeave", "ParticipantsJoin"] if not provided. Example: "['MessageCreate', 'ParticipantsLeave']".
|
|
29
|
+
dm_event_fields (array): A comma separated list of DmEvent fields to display. Example: "['attachments', 'created_at', 'dm_conversation_id', 'entities', 'event_type', 'id', 'participant_ids', 'referenced_tweets', 'sender_id', 'text']".
|
|
30
|
+
expansions (array): A comma separated list of fields to expand. Example: "['attachments.media_keys', 'participant_ids', 'referenced_tweets.id', 'sender_id']".
|
|
31
|
+
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']".
|
|
32
|
+
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']".
|
|
33
|
+
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']".
|
|
34
|
+
|
|
35
|
+
Returns:
|
|
36
|
+
dict[str, Any]: The request has succeeded.
|
|
37
|
+
|
|
38
|
+
Raises:
|
|
39
|
+
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
40
|
+
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
41
|
+
|
|
42
|
+
Tags:
|
|
43
|
+
Direct Messages
|
|
44
|
+
"""
|
|
45
|
+
url = f"{self.main_app_client.base_url}/2/dm_events"
|
|
46
|
+
query_params = {
|
|
47
|
+
k: v
|
|
48
|
+
for k, v in [
|
|
49
|
+
("max_results", max_results),
|
|
50
|
+
("pagination_token", pagination_token),
|
|
51
|
+
("event_types", event_types),
|
|
52
|
+
("dm_event.fields", dm_event_fields),
|
|
53
|
+
("expansions", expansions),
|
|
54
|
+
("media.fields", media_fields),
|
|
55
|
+
("user.fields", user_fields),
|
|
56
|
+
("tweet.fields", tweet_fields),
|
|
57
|
+
]
|
|
58
|
+
if v is not None
|
|
59
|
+
}
|
|
60
|
+
response = self._get(url, params=query_params)
|
|
61
|
+
response.raise_for_status()
|
|
62
|
+
return response.json()
|
|
63
|
+
|
|
64
|
+
def dm_event_delete(self, event_id) -> dict[str, Any]:
|
|
65
|
+
"""
|
|
66
|
+
|
|
67
|
+
Deletes a DM event by its ID using the DELETE method, requiring authentication via OAuth2UserToken with "dm.read" and "dm.write" scopes or UserToken.
|
|
68
|
+
|
|
69
|
+
Args:
|
|
70
|
+
event_id (string): event_id
|
|
71
|
+
|
|
72
|
+
Returns:
|
|
73
|
+
dict[str, Any]: The request has succeeded.
|
|
74
|
+
|
|
75
|
+
Raises:
|
|
76
|
+
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
77
|
+
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
78
|
+
|
|
79
|
+
Tags:
|
|
80
|
+
Direct Messages
|
|
81
|
+
"""
|
|
82
|
+
if event_id is None:
|
|
83
|
+
raise ValueError("Missing required parameter 'event_id'.")
|
|
84
|
+
url = f"{self.main_app_client.base_url}/2/dm_events/{event_id}"
|
|
85
|
+
query_params = {}
|
|
86
|
+
response = self._delete(url, params=query_params)
|
|
87
|
+
response.raise_for_status()
|
|
88
|
+
return response.json()
|
|
89
|
+
|
|
90
|
+
def get_dm_events_by_id(
|
|
91
|
+
self,
|
|
92
|
+
event_id,
|
|
93
|
+
dm_event_fields=None,
|
|
94
|
+
expansions=None,
|
|
95
|
+
media_fields=None,
|
|
96
|
+
user_fields=None,
|
|
97
|
+
tweet_fields=None,
|
|
98
|
+
) -> dict[str, Any]:
|
|
99
|
+
"""
|
|
100
|
+
|
|
101
|
+
Retrieves detailed information about a specific direct message event by its event ID with optional expansions and field selections.
|
|
102
|
+
|
|
103
|
+
Args:
|
|
104
|
+
event_id (string): event_id
|
|
105
|
+
dm_event_fields (array): A comma separated list of DmEvent fields to display. Example: "['attachments', 'created_at', 'dm_conversation_id', 'entities', 'event_type', 'id', 'participant_ids', 'referenced_tweets', 'sender_id', 'text']".
|
|
106
|
+
expansions (array): A comma separated list of fields to expand. Example: "['attachments.media_keys', 'participant_ids', 'referenced_tweets.id', 'sender_id']".
|
|
107
|
+
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']".
|
|
108
|
+
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']".
|
|
109
|
+
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']".
|
|
110
|
+
|
|
111
|
+
Returns:
|
|
112
|
+
dict[str, Any]: The request has succeeded.
|
|
113
|
+
|
|
114
|
+
Raises:
|
|
115
|
+
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
116
|
+
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
117
|
+
|
|
118
|
+
Tags:
|
|
119
|
+
Direct Messages
|
|
120
|
+
"""
|
|
121
|
+
if event_id is None:
|
|
122
|
+
raise ValueError("Missing required parameter 'event_id'.")
|
|
123
|
+
url = f"{self.main_app_client.base_url}/2/dm_events/{event_id}"
|
|
124
|
+
query_params = {
|
|
125
|
+
k: v
|
|
126
|
+
for k, v in [
|
|
127
|
+
("dm_event.fields", dm_event_fields),
|
|
128
|
+
("expansions", expansions),
|
|
129
|
+
("media.fields", media_fields),
|
|
130
|
+
("user.fields", user_fields),
|
|
131
|
+
("tweet.fields", tweet_fields),
|
|
132
|
+
]
|
|
133
|
+
if v is not None
|
|
134
|
+
}
|
|
135
|
+
response = self._get(url, params=query_params)
|
|
136
|
+
response.raise_for_status()
|
|
137
|
+
return response.json()
|
|
138
|
+
|
|
139
|
+
def list_tools(self):
|
|
140
|
+
return [self.get_dm_events, self.dm_event_delete, self.get_dm_events_by_id]
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
|
|
3
|
+
from .api_segment_base import APISegmentBase
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class LikesApi(APISegmentBase):
|
|
7
|
+
def __init__(self, main_app_client: Any):
|
|
8
|
+
super().__init__(main_app_client)
|
|
9
|
+
|
|
10
|
+
def get_likes_compliance_stream(
|
|
11
|
+
self, backfill_minutes=None, start_time=None, end_time=None
|
|
12
|
+
) -> Any:
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
Streams compliance-related likes data using the GET method, allowing optional filtering by backfill minutes and time range.
|
|
16
|
+
|
|
17
|
+
Args:
|
|
18
|
+
backfill_minutes (integer): Specifies the number of minutes of missed data to recover in case of a disconnection, allowing retrieval of up to five minutes of past data.
|
|
19
|
+
start_time (string): The optional start_time query parameter specifies the earliest timestamp from which to retrieve compliance stream data. Example: '2021-02-01T18:40:40.000Z'.
|
|
20
|
+
end_time (string): Optional end time to filter the compliance stream, specified as a string. Example: '2021-02-01T18:40:40.000Z'.
|
|
21
|
+
|
|
22
|
+
Returns:
|
|
23
|
+
Any: The request has succeeded.
|
|
24
|
+
|
|
25
|
+
Raises:
|
|
26
|
+
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
27
|
+
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
28
|
+
|
|
29
|
+
Tags:
|
|
30
|
+
Compliance
|
|
31
|
+
"""
|
|
32
|
+
url = f"{self.main_app_client.base_url}/2/likes/compliance/stream"
|
|
33
|
+
query_params = {
|
|
34
|
+
k: v
|
|
35
|
+
for k, v in [
|
|
36
|
+
("backfill_minutes", backfill_minutes),
|
|
37
|
+
("start_time", start_time),
|
|
38
|
+
("end_time", end_time),
|
|
39
|
+
]
|
|
40
|
+
if v is not None
|
|
41
|
+
}
|
|
42
|
+
response = self._get(url, params=query_params)
|
|
43
|
+
response.raise_for_status()
|
|
44
|
+
return response.json()
|
|
45
|
+
|
|
46
|
+
def likes_firehose_stream(
|
|
47
|
+
self,
|
|
48
|
+
partition,
|
|
49
|
+
backfill_minutes=None,
|
|
50
|
+
start_time=None,
|
|
51
|
+
end_time=None,
|
|
52
|
+
like_with_tweet_author_fields=None,
|
|
53
|
+
expansions=None,
|
|
54
|
+
user_fields=None,
|
|
55
|
+
tweet_fields=None,
|
|
56
|
+
) -> dict[str, Any]:
|
|
57
|
+
"""
|
|
58
|
+
|
|
59
|
+
Streams a real-time firehose of likes data filtered by partition and optional time range parameters, including expanded tweet and user fields, using Bearer Token authentication.
|
|
60
|
+
|
|
61
|
+
Args:
|
|
62
|
+
partition (integer): The partition query parameter specifies the integer identifier of the data subset or bucket to stream from the firehose endpoint, enabling segmented retrieval of likes data.
|
|
63
|
+
backfill_minutes (integer): The number of minutes (up to five) to backfill and recover missed data from the stream after a disconnection.
|
|
64
|
+
start_time (string): Optional query parameter specifying the start time for filtering the firehose stream of likes. Example: '2021-02-14T18:40:40.000Z'.
|
|
65
|
+
end_time (string): The end_time query parameter specifies the optional cutoff timestamp to limit the data streamed to only items created before this time. Example: '2021-02-14T18:40:40.000Z'.
|
|
66
|
+
like_with_tweet_author_fields (array): A comma separated list of LikeWithTweetAuthor fields to display. Example: "['created_at', 'id', 'liked_tweet_author_id', 'liked_tweet_id', 'timestamp_ms']".
|
|
67
|
+
expansions (array): A comma separated list of fields to expand. Example: "['liked_tweet_author_id', 'liked_tweet_id']".
|
|
68
|
+
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']".
|
|
69
|
+
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']".
|
|
70
|
+
|
|
71
|
+
Returns:
|
|
72
|
+
dict[str, Any]: The request has succeeded.
|
|
73
|
+
|
|
74
|
+
Raises:
|
|
75
|
+
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
76
|
+
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
77
|
+
|
|
78
|
+
Tags:
|
|
79
|
+
Likes
|
|
80
|
+
"""
|
|
81
|
+
url = f"{self.main_app_client.base_url}/2/likes/firehose/stream"
|
|
82
|
+
query_params = {
|
|
83
|
+
k: v
|
|
84
|
+
for k, v in [
|
|
85
|
+
("backfill_minutes", backfill_minutes),
|
|
86
|
+
("partition", partition),
|
|
87
|
+
("start_time", start_time),
|
|
88
|
+
("end_time", end_time),
|
|
89
|
+
("like_with_tweet_author.fields", like_with_tweet_author_fields),
|
|
90
|
+
("expansions", expansions),
|
|
91
|
+
("user.fields", user_fields),
|
|
92
|
+
("tweet.fields", tweet_fields),
|
|
93
|
+
]
|
|
94
|
+
if v is not None
|
|
95
|
+
}
|
|
96
|
+
response = self._get(url, params=query_params)
|
|
97
|
+
response.raise_for_status()
|
|
98
|
+
return response.json()
|
|
99
|
+
|
|
100
|
+
def likes_sample_stream(
|
|
101
|
+
self,
|
|
102
|
+
partition,
|
|
103
|
+
backfill_minutes=None,
|
|
104
|
+
start_time=None,
|
|
105
|
+
end_time=None,
|
|
106
|
+
like_with_tweet_author_fields=None,
|
|
107
|
+
expansions=None,
|
|
108
|
+
user_fields=None,
|
|
109
|
+
tweet_fields=None,
|
|
110
|
+
) -> dict[str, Any]:
|
|
111
|
+
"""
|
|
112
|
+
|
|
113
|
+
Streams a sample of 10 likes using the GET method, optionally filtering by backfill minutes, partition, start and end times, and including specific tweet and user fields.
|
|
114
|
+
|
|
115
|
+
Args:
|
|
116
|
+
partition (integer): The partition query parameter specifies the integer identifier of the data partition to retrieve in the sample10 likes stream.
|
|
117
|
+
backfill_minutes (integer): Optional integer parameter to specify the number of minutes of missed data to recover, used for reconnecting after a disconnection in the stream.
|
|
118
|
+
start_time (string): Optional query parameter specifying the start time for filtering the stream of likes; defaults to no filtering if omitted. Example: '2021-02-14T18:40:40.000Z'.
|
|
119
|
+
end_time (string): Optional query parameter specifying the end time for filtering the sample stream of likes. Example: '2021-02-14T18:40:40.000Z'.
|
|
120
|
+
like_with_tweet_author_fields (array): A comma separated list of LikeWithTweetAuthor fields to display. Example: "['created_at', 'id', 'liked_tweet_author_id', 'liked_tweet_id', 'timestamp_ms']".
|
|
121
|
+
expansions (array): A comma separated list of fields to expand. Example: "['liked_tweet_author_id', 'liked_tweet_id']".
|
|
122
|
+
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']".
|
|
123
|
+
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']".
|
|
124
|
+
|
|
125
|
+
Returns:
|
|
126
|
+
dict[str, Any]: The request has succeeded.
|
|
127
|
+
|
|
128
|
+
Raises:
|
|
129
|
+
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
130
|
+
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
131
|
+
|
|
132
|
+
Tags:
|
|
133
|
+
Likes
|
|
134
|
+
"""
|
|
135
|
+
url = f"{self.main_app_client.base_url}/2/likes/sample10/stream"
|
|
136
|
+
query_params = {
|
|
137
|
+
k: v
|
|
138
|
+
for k, v in [
|
|
139
|
+
("backfill_minutes", backfill_minutes),
|
|
140
|
+
("partition", partition),
|
|
141
|
+
("start_time", start_time),
|
|
142
|
+
("end_time", end_time),
|
|
143
|
+
("like_with_tweet_author.fields", like_with_tweet_author_fields),
|
|
144
|
+
("expansions", expansions),
|
|
145
|
+
("user.fields", user_fields),
|
|
146
|
+
("tweet.fields", tweet_fields),
|
|
147
|
+
]
|
|
148
|
+
if v is not None
|
|
149
|
+
}
|
|
150
|
+
response = self._get(url, params=query_params)
|
|
151
|
+
response.raise_for_status()
|
|
152
|
+
return response.json()
|
|
153
|
+
|
|
154
|
+
def list_tools(self):
|
|
155
|
+
return [
|
|
156
|
+
self.get_likes_compliance_stream,
|
|
157
|
+
self.likes_firehose_stream,
|
|
158
|
+
self.likes_sample_stream,
|
|
159
|
+
]
|