TwitterClient
Attributes
TRIGGER_OPERATIONS
module-attribute
TRIGGER_OPERATIONS: Dict[str, Dict[str, Any]] = {'OnNewTweet': {'operation_id': 'OnNewTweet', 'path': '/{connectionId}/onnewtweet', 'method': 'get', 'required_parameters': ['searchQuery'], 'callback_payload_type': 'TriggerBatchResponseTweetModel'}}
Classes
TweetModel
dataclass
TweetModel(tweet_text: str, retweet_count: int, tweeted_by: str, *, tweet_id: Optional[str] = None, created_at: Optional[str] = None, created_at_iso: Optional[str] = None, media_urls: Optional[List[str]] = None, tweet_language_code: Optional[str] = None, tweet_in_reply_to_user_id: Optional[str] = None, favorited: Optional[bool] = None, user_mentions: Optional[List[UserMentionsModel | Mapping[str, Any]]] = None, original_tweet: Optional[OriginalTweetModel | Mapping[str, Any]] = None, user_details: Optional[UserDetailsModel | Mapping[str, Any]] = None)
Response for Get user timeline
Attributes
tweet_text
class-attribute
instance-attribute
Text content of the tweet
tweet_id
class-attribute
instance-attribute
tweet_id: Optional[str] = dataclass_field(default=None, kw_only=True, metadata={'wire_name': 'TweetId'})
Id of the tweet
created_at
class-attribute
instance-attribute
created_at: Optional[str] = dataclass_field(default=None, kw_only=True, metadata={'wire_name': 'CreatedAt'})
Time at which the tweet was posted
created_at_iso
class-attribute
instance-attribute
created_at_iso: Optional[str] = dataclass_field(default=None, kw_only=True, metadata={'wire_name': 'CreatedAtIso'})
Time at which the tweet was posted
retweet_count
class-attribute
instance-attribute
Total number of re-tweets for the tweet
tweeted_by
class-attribute
instance-attribute
Name of the user who has posted the tweet
media_urls
class-attribute
instance-attribute
media_urls: Optional[List[str]] = dataclass_field(default=None, kw_only=True, metadata={'wire_name': 'MediaUrls'})
Url of the media posted along with the tweet
tweet_language_code
class-attribute
instance-attribute
tweet_language_code: Optional[str] = dataclass_field(default=None, kw_only=True, metadata={'wire_name': 'TweetLanguageCode'})
Language code of the tweet
tweet_in_reply_to_user_id
class-attribute
instance-attribute
tweet_in_reply_to_user_id: Optional[str] = dataclass_field(default=None, kw_only=True, metadata={'wire_name': 'TweetInReplyToUserId'})
User Id of the author of the tweet that the current tweet is a reply to
UserDetailsModel
dataclass
UserDetailsModel(full_name: str, location: str, user_name: str, description: str, *, id: Optional[int] = None, followers_count: Optional[int] = None, statuses_count: Optional[int] = None, friends_count: Optional[int] = None, favourites_count: Optional[int] = None, profile_image_url: Optional[str] = None)
Response for Get followers
Attributes
full_name
class-attribute
instance-attribute
Name of the user
location
class-attribute
instance-attribute
Location of the user
id
class-attribute
instance-attribute
X id (handle) of the user
user_name
class-attribute
instance-attribute
Screen name of the user
followers_count
class-attribute
instance-attribute
followers_count: Optional[int] = dataclass_field(default=None, kw_only=True, metadata={'wire_name': 'FollowersCount'})
Number of followers
description
class-attribute
instance-attribute
User description
statuses_count
class-attribute
instance-attribute
statuses_count: Optional[int] = dataclass_field(default=None, kw_only=True, metadata={'wire_name': 'StatusesCount'})
User status count
friends_count
class-attribute
instance-attribute
friends_count: Optional[int] = dataclass_field(default=None, kw_only=True, metadata={'wire_name': 'FriendsCount'})
Number of friends
TweetResponseModel
dataclass
TriggerBatchResponseTweetModel
dataclass
UserMentionsModel
dataclass
OriginalTweetModel
dataclass
OriginalTweetModel(tweet_text: str, retweet_count: int, tweeted_by: str, *, tweet_id: Optional[str] = None, created_at: Optional[str] = None, created_at_iso: Optional[str] = None, media_urls: Optional[List[str]] = None, tweet_language_code: Optional[str] = None, tweet_in_reply_to_user_id: Optional[str] = None, favorited: Optional[bool] = None, user_mentions: Optional[List[OriginalTweetUserMentionsModel | Mapping[str, Any]]] = None, user_details: Optional[OriginalTweetUserDetailsModel | Mapping[str, Any]] = None)
Definition: OriginalTweetModel
Attributes
tweet_text
class-attribute
instance-attribute
Text content of the original retrieved tweet
tweet_id
class-attribute
instance-attribute
tweet_id: Optional[str] = dataclass_field(default=None, kw_only=True, metadata={'wire_name': 'TweetId'})
Id of the original tweet
created_at
class-attribute
instance-attribute
created_at: Optional[str] = dataclass_field(default=None, kw_only=True, metadata={'wire_name': 'CreatedAt'})
Time at which original tweet was posted
created_at_iso
class-attribute
instance-attribute
created_at_iso: Optional[str] = dataclass_field(default=None, kw_only=True, metadata={'wire_name': 'CreatedAtIso'})
Time at which original tweet was posted
retweet_count
class-attribute
instance-attribute
Total number of re-tweets for this original tweet
tweeted_by
class-attribute
instance-attribute
User name of the person who posted the original tweet
media_urls
class-attribute
instance-attribute
media_urls: Optional[List[str]] = dataclass_field(default=None, kw_only=True, metadata={'wire_name': 'MediaUrls'})
Url of the media posted along with the original tweet
tweet_language_code
class-attribute
instance-attribute
tweet_language_code: Optional[str] = dataclass_field(default=None, kw_only=True, metadata={'wire_name': 'TweetLanguageCode'})
Language code for the original tweet
tweet_in_reply_to_user_id
class-attribute
instance-attribute
tweet_in_reply_to_user_id: Optional[str] = dataclass_field(default=None, kw_only=True, metadata={'wire_name': 'TweetInReplyToUserId'})
User Id of the author of the tweet that the current original tweet is a reply to
OriginalTweetUserMentionsModel
dataclass
OriginalTweetUserMentionsModel(id: int, *, full_name: Optional[str] = None, user_name: Optional[str] = None)
OriginalTweetUserDetailsModel
dataclass
OriginalTweetUserDetailsModel(full_name: str, location: str, user_name: str, description: str, *, id: Optional[int] = None, followers_count: Optional[int] = None, statuses_count: Optional[int] = None, friends_count: Optional[int] = None, favourites_count: Optional[int] = None, profile_image_url: Optional[str] = None)
Definition: OriginalTweetUserDetailsModel
Attributes
full_name
class-attribute
instance-attribute
Name of the user
location
class-attribute
instance-attribute
Location of the user
id
class-attribute
instance-attribute
X id (handle) of the user
user_name
class-attribute
instance-attribute
Screen name of the user
followers_count
class-attribute
instance-attribute
followers_count: Optional[int] = dataclass_field(default=None, kw_only=True, metadata={'wire_name': 'FollowersCount'})
Number of followers
description
class-attribute
instance-attribute
User description
statuses_count
class-attribute
instance-attribute
statuses_count: Optional[int] = dataclass_field(default=None, kw_only=True, metadata={'wire_name': 'StatusesCount'})
User status count
friends_count
class-attribute
instance-attribute
friends_count: Optional[int] = dataclass_field(default=None, kw_only=True, metadata={'wire_name': 'FriendsCount'})
Number of friends
TwitterClient
TwitterClient(connection_runtime_url: str, credential: AsyncTokenCredential | AzureKeyCredential, *, max_retry_attempts: int = 3, timeout: float = 30.0, use_exponential_backoff: bool = True, initial_retry_delay_seconds: float = 0.5, maximum_retry_delay_seconds: float = 120.0, retry_jitter_factor: float = 0.1, retry_unsafe_http_methods: bool = False, transport: Optional[AsyncHttpTransport] = None, **kwargs: Any)
Bases: ConnectorClientBase
Typed client for twitter connector.
Initialize a TwitterClient.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
connection_runtime_url
|
str
|
The connection runtime URL from Azure Portal. |
required |
credential
|
AsyncTokenCredential | AzureKeyCredential
|
Caller-owned Azure Core credential. |
required |
max_retry_attempts
|
int
|
The maximum number of request attempts. |
3
|
timeout
|
float
|
The network timeout in seconds for each request. The value configures Azure Core retry and transport deadlines. Nonpositive values disable SDK and transport deadlines. |
30.0
|
use_exponential_backoff
|
bool
|
Whether retries use exponential backoff. |
True
|
initial_retry_delay_seconds
|
float
|
The initial retry delay in seconds. |
0.5
|
maximum_retry_delay_seconds
|
float
|
The maximum retry delay in seconds. |
120.0
|
retry_jitter_factor
|
float
|
The jitter fraction applied to retry delays. |
0.1
|
retry_unsafe_http_methods
|
bool
|
Whether unsafe HTTP methods may be retried. |
False
|
transport
|
Optional[AsyncHttpTransport]
|
Optional Azure Core async HTTP transport closed by the client through its asynchronous lifecycle. |
None
|
**kwargs
|
Any
|
Optional Azure Core pipeline policy settings. |
{}
|
Methods:
list_user_timeline
list_user_timeline(user_name: str, *, max_results: Optional[int] = None, timeout: Optional[float] = None, headers: Optional[Mapping[str, str]] = None, client_request_id: Optional[str] = None, response_hook: Optional[ConnectorResponseHook] = None) -> AsyncItemPaged[dict[str, Any]]
Get user timeline
This operation gets a list of the most recent tweets posted by a given user.
Returns a single-page Azure Core async collection.
Swagger operation ID: UserTimeline.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_name
|
str
|
X handle for the user. |
required |
max_results
|
Optional[int]
|
Maximum number of tweets to return. |
None
|
timeout
|
Optional[float]
|
The request timeout in seconds. |
None
|
headers
|
Optional[Mapping[str, str]]
|
Additional HTTP request headers. |
None
|
client_request_id
|
Optional[str]
|
A caller-provided request identifier. |
None
|
response_hook
|
Optional[ConnectorResponseHook]
|
A callback invoked with the connector response. |
None
|
Returns:
| Type | Description |
|---|---|
AsyncItemPaged[dict[str, Any]]
|
AsyncItemPaged[dict[str, Any]]: An Azure Core pager over connector
results. Consume it with |
Raises:
| Type | Description |
|---|---|
ConnectorException
|
If the connector request fails. |
list_home_timeline
list_home_timeline(*, max_results: Optional[int] = None, timeout: Optional[float] = None, headers: Optional[Mapping[str, str]] = None, client_request_id: Optional[str] = None, response_hook: Optional[ConnectorResponseHook] = None) -> AsyncItemPaged[dict[str, Any]]
Get home timeline
This operation gets the most recent tweets and re-tweets posted by me and my followers.
Returns a single-page Azure Core async collection.
Swagger operation ID: HomeTimeline.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
max_results
|
Optional[int]
|
Maximum number of tweets to return. |
None
|
timeout
|
Optional[float]
|
The request timeout in seconds. |
None
|
headers
|
Optional[Mapping[str, str]]
|
Additional HTTP request headers. |
None
|
client_request_id
|
Optional[str]
|
A caller-provided request identifier. |
None
|
response_hook
|
Optional[ConnectorResponseHook]
|
A callback invoked with the connector response. |
None
|
Returns:
| Type | Description |
|---|---|
AsyncItemPaged[dict[str, Any]]
|
AsyncItemPaged[dict[str, Any]]: An Azure Core pager over connector
results. Consume it with |
Raises:
| Type | Description |
|---|---|
ConnectorException
|
If the connector request fails. |
list_search_tweet
list_search_tweet(search_query: str, *, max_results: Optional[int] = None, since_id: Optional[str] = None, timeout: Optional[float] = None, headers: Optional[Mapping[str, str]] = None, client_request_id: Optional[str] = None, response_hook: Optional[ConnectorResponseHook] = None) -> AsyncItemPaged[dict[str, Any]]
Search tweets
This operation gets a list of relevant tweets matching the search query.
Returns a single-page Azure Core async collection.
Swagger operation ID: SearchTweet.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
search_query
|
str
|
Search term like "happy hour", #haiku, from:@username, love OR hate. |
required |
max_results
|
Optional[int]
|
Maximum number of tweets to return. |
None
|
since_id
|
Optional[str]
|
Return tweets after the specified tweet ID. |
None
|
timeout
|
Optional[float]
|
The request timeout in seconds. |
None
|
headers
|
Optional[Mapping[str, str]]
|
Additional HTTP request headers. |
None
|
client_request_id
|
Optional[str]
|
A caller-provided request identifier. |
None
|
response_hook
|
Optional[ConnectorResponseHook]
|
A callback invoked with the connector response. |
None
|
Returns:
| Type | Description |
|---|---|
AsyncItemPaged[dict[str, Any]]
|
AsyncItemPaged[dict[str, Any]]: An Azure Core pager over connector
results. Consume it with |
Raises:
| Type | Description |
|---|---|
ConnectorException
|
If the connector request fails. |
list_followers
list_followers(user_name: str, *, max_results: Optional[int] = None, timeout: Optional[float] = None, headers: Optional[Mapping[str, str]] = None, client_request_id: Optional[str] = None, response_hook: Optional[ConnectorResponseHook] = None) -> AsyncItemPaged[dict[str, Any]]
Get followers
This operation gets the list of users that follow a given user.
Returns a single-page Azure Core async collection.
Swagger operation ID: Followers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_name
|
str
|
X handle for the user. |
required |
max_results
|
Optional[int]
|
Maximum number of users to return. |
None
|
timeout
|
Optional[float]
|
The request timeout in seconds. |
None
|
headers
|
Optional[Mapping[str, str]]
|
Additional HTTP request headers. |
None
|
client_request_id
|
Optional[str]
|
A caller-provided request identifier. |
None
|
response_hook
|
Optional[ConnectorResponseHook]
|
A callback invoked with the connector response. |
None
|
Returns:
| Type | Description |
|---|---|
AsyncItemPaged[dict[str, Any]]
|
AsyncItemPaged[dict[str, Any]]: An Azure Core pager over connector
results. Consume it with |
Raises:
| Type | Description |
|---|---|
ConnectorException
|
If the connector request fails. |
list_my_followers
list_my_followers(*, max_results: Optional[int] = None, timeout: Optional[float] = None, headers: Optional[Mapping[str, str]] = None, client_request_id: Optional[str] = None, response_hook: Optional[ConnectorResponseHook] = None) -> AsyncItemPaged[dict[str, Any]]
Get my followers
This operation gets the list of users who are following me.
Returns a single-page Azure Core async collection.
Swagger operation ID: MyFollowers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
max_results
|
Optional[int]
|
Maximum number of users to get. |
None
|
timeout
|
Optional[float]
|
The request timeout in seconds. |
None
|
headers
|
Optional[Mapping[str, str]]
|
Additional HTTP request headers. |
None
|
client_request_id
|
Optional[str]
|
A caller-provided request identifier. |
None
|
response_hook
|
Optional[ConnectorResponseHook]
|
A callback invoked with the connector response. |
None
|
Returns:
| Type | Description |
|---|---|
AsyncItemPaged[dict[str, Any]]
|
AsyncItemPaged[dict[str, Any]]: An Azure Core pager over connector
results. Consume it with |
Raises:
| Type | Description |
|---|---|
ConnectorException
|
If the connector request fails. |
list_following
list_following(user_name: str, *, max_results: Optional[int] = None, timeout: Optional[float] = None, headers: Optional[Mapping[str, str]] = None, client_request_id: Optional[str] = None, response_hook: Optional[ConnectorResponseHook] = None) -> AsyncItemPaged[dict[str, Any]]
Get following
The operation gets the list of people the given user follows.
Returns a single-page Azure Core async collection.
Swagger operation ID: Following.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_name
|
str
|
X handle for the user. |
required |
max_results
|
Optional[int]
|
Maximum number of users to return. |
None
|
timeout
|
Optional[float]
|
The request timeout in seconds. |
None
|
headers
|
Optional[Mapping[str, str]]
|
Additional HTTP request headers. |
None
|
client_request_id
|
Optional[str]
|
A caller-provided request identifier. |
None
|
response_hook
|
Optional[ConnectorResponseHook]
|
A callback invoked with the connector response. |
None
|
Returns:
| Type | Description |
|---|---|
AsyncItemPaged[dict[str, Any]]
|
AsyncItemPaged[dict[str, Any]]: An Azure Core pager over connector
results. Consume it with |
Raises:
| Type | Description |
|---|---|
ConnectorException
|
If the connector request fails. |
list_my_following
list_my_following(*, max_results: Optional[int] = None, timeout: Optional[float] = None, headers: Optional[Mapping[str, str]] = None, client_request_id: Optional[str] = None, response_hook: Optional[ConnectorResponseHook] = None) -> AsyncItemPaged[dict[str, Any]]
Get my following
This operation gets the list of users that I am following.
Returns a single-page Azure Core async collection.
Swagger operation ID: MyFollowing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
max_results
|
Optional[int]
|
Maximum number of users to return. |
None
|
timeout
|
Optional[float]
|
The request timeout in seconds. |
None
|
headers
|
Optional[Mapping[str, str]]
|
Additional HTTP request headers. |
None
|
client_request_id
|
Optional[str]
|
A caller-provided request identifier. |
None
|
response_hook
|
Optional[ConnectorResponseHook]
|
A callback invoked with the connector response. |
None
|
Returns:
| Type | Description |
|---|---|
AsyncItemPaged[dict[str, Any]]
|
AsyncItemPaged[dict[str, Any]]: An Azure Core pager over connector
results. Consume it with |
Raises:
| Type | Description |
|---|---|
ConnectorException
|
If the connector request fails. |
user
async
user(user_name: str, *, timeout: Optional[float] = None, headers: Optional[Mapping[str, str]] = None, client_request_id: Optional[str] = None, response_hook: Optional[ConnectorResponseHook] = None) -> dict[str, Any] | None
Get user
This operation gets the profile details for a given user, such as user name, description, followers count, and more.
Swagger operation ID: User.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_name
|
str
|
X handle for the user. |
required |
timeout
|
Optional[float]
|
The request timeout in seconds. |
None
|
headers
|
Optional[Mapping[str, str]]
|
Additional HTTP request headers. |
None
|
client_request_id
|
Optional[str]
|
A caller-provided request identifier. |
None
|
response_hook
|
Optional[ConnectorResponseHook]
|
A callback invoked with the connector response. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Any] | None
|
dict[str, Any] | None: The connector operation result. |
Raises:
| Type | Description |
|---|---|
ConnectorException
|
If the connector request fails. |
tweet
async
tweet(input: bytes, *, tweet_text: Optional[str] = None, timeout: Optional[float] = None, headers: Optional[Mapping[str, str]] = None, client_request_id: Optional[str] = None, response_hook: Optional[ConnectorResponseHook] = None) -> dict[str, Any] | None
Post a tweet
This operation posts a new tweet.
Swagger operation ID: Tweet.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input
|
bytes
|
The binary request body. |
required |
tweet_text
|
Optional[str]
|
Text to be posted. |
None
|
timeout
|
Optional[float]
|
The request timeout in seconds. |
None
|
headers
|
Optional[Mapping[str, str]]
|
Additional HTTP request headers. |
None
|
client_request_id
|
Optional[str]
|
A caller-provided request identifier. |
None
|
response_hook
|
Optional[ConnectorResponseHook]
|
A callback invoked with the connector response. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Any] | None
|
dict[str, Any] | None: The connector operation result. |
Raises:
| Type | Description |
|---|---|
ConnectorException
|
If the connector request fails. |
retweet
async
retweet(tweet_id: str, *, trim_user: Optional[bool] = None, timeout: Optional[float] = None, headers: Optional[Mapping[str, str]] = None, client_request_id: Optional[str] = None, response_hook: Optional[ConnectorResponseHook] = None) -> dict[str, Any] | None
Retweet
This operation retweets a tweet.
Swagger operation ID: Retweet.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tweet_id
|
str
|
Tweet to be retweeted. |
required |
trim_user
|
Optional[bool]
|
Boolean to indicate whether to trim user information. |
None
|
timeout
|
Optional[float]
|
The request timeout in seconds. |
None
|
headers
|
Optional[Mapping[str, str]]
|
Additional HTTP request headers. |
None
|
client_request_id
|
Optional[str]
|
A caller-provided request identifier. |
None
|
response_hook
|
Optional[ConnectorResponseHook]
|
A callback invoked with the connector response. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Any] | None
|
dict[str, Any] | None: The connector operation result. |
Raises:
| Type | Description |
|---|---|
ConnectorException
|
If the connector request fails. |