pub struct TweetyClient { /* private fields */ }
Implementations§
Source§impl TweetyClient
impl TweetyClient
Sourcepub async fn get_user_bookmark(
self,
user_id: &str,
) -> Result<ResponseWithHeaders, TweetyError>
pub async fn get_user_bookmark( self, user_id: &str, ) -> Result<ResponseWithHeaders, TweetyError>
Bookmarks lookup Lookup a user’s Bookmarks
Sourcepub async fn bookmark_post(
self,
post_id: &str,
) -> Result<ResponseWithHeaders, TweetyError>
pub async fn bookmark_post( self, post_id: &str, ) -> Result<ResponseWithHeaders, TweetyError>
Bookmark a Post
Sourcepub async fn delete_bookmark(
self,
user_id: &str,
tweet_id: &str,
) -> Result<ResponseWithHeaders, TweetyError>
pub async fn delete_bookmark( self, user_id: &str, tweet_id: &str, ) -> Result<ResponseWithHeaders, TweetyError>
Remove a Bookmark of a Post
Source§impl TweetyClient
impl TweetyClient
Sourcepub fn new(
consumer_key: &str,
access_token: &str,
consumer_key_secret: &str,
access_token_secret: &str,
) -> Self
pub fn new( consumer_key: &str, access_token: &str, consumer_key_secret: &str, access_token_secret: &str, ) -> Self
Creates a new TweetyClient
instance with the given credentials.
§Parameters
consumer_key
- The OAuth consumer key.access_token
- The OAuth access token.consumer_key_secret
- The OAuth consumer key secret.access_token_secret
- The OAuth access token secret.
§Example
use tweety_rs::api::client::TweetyClient;
let client = TweetyClient::new(
"your_consumer_key",
"your_access_token",
"your_consumer_key_secret",
"your_access_token_secret",
);
pub fn is_initialized(&self) -> bool
Source§impl TweetyClient
impl TweetyClient
Sourcepub async fn get_direct_messages(
&self,
params: QueryParams,
) -> Result<ResponseWithHeaders, TweetyError>
pub async fn get_direct_messages( &self, params: QueryParams, ) -> Result<ResponseWithHeaders, TweetyError>
Returns a list of Direct Messages for the authenticated user, both sent and received. Direct Message events are returned in reverse chronological order. Supports retrieving events from the previous 30 days. Authentication methods supported by this endpoint
Sourcepub async fn get_dm_events_with_participant(
&self,
participant_id: &str,
params: QueryParams,
) -> Result<ResponseWithHeaders, TweetyError>
pub async fn get_dm_events_with_participant( &self, participant_id: &str, params: QueryParams, ) -> Result<ResponseWithHeaders, TweetyError>
GET /2/dm_conversations/with/:participant_id/dm_events Messages are returned in reverse chronological order.
Sourcepub async fn get_dm_events_in_conversation(
&self,
dm_conversation_id: &str,
params: QueryParams,
) -> Result<ResponseWithHeaders, TweetyError>
pub async fn get_dm_events_in_conversation( &self, dm_conversation_id: &str, params: QueryParams, ) -> Result<ResponseWithHeaders, TweetyError>
Returns a list of Direct Messages within a conversation specified in the dm_conversation_id path parameter. Messages are returned in reverse chronological order.
Source§impl TweetyClient
impl TweetyClient
Sourcepub async fn get_user_followers(
&self,
user_id: &str,
params: Option<UserQueryParams>,
) -> Result<ResponseWithHeaders, TweetyError>
pub async fn get_user_followers( &self, user_id: &str, params: Option<UserQueryParams>, ) -> Result<ResponseWithHeaders, TweetyError>
Returns a list of users who are followers of the specified user ID. Docs
Source§impl TweetyClient
impl TweetyClient
Sourcepub async fn follow_user(
&self,
user_id: &str,
target_user_id: &str,
) -> Result<ResponseWithHeaders, TweetyError>
pub async fn follow_user( &self, user_id: &str, target_user_id: &str, ) -> Result<ResponseWithHeaders, TweetyError>
Allows a user ID to follow another user. If the target user does not have public Tweets, this endpoint will send a follow request. Docs
Sourcepub async fn unfollow_user(
&self,
source_userid: &str,
target_userid: &str,
) -> Result<ResponseWithHeaders, TweetyError>
pub async fn unfollow_user( &self, source_userid: &str, target_userid: &str, ) -> Result<ResponseWithHeaders, TweetyError>
Allows a user ID to unfollow another user. The request succeeds with no action when the authenticated user sends a request to a user they’re not following or have already unfollowed. Docs
Sourcepub async fn get_users_following(
&self,
user_id: &str,
query: Option<UserQueryParams>,
) -> Result<ResponseWithHeaders, TweetyError>
pub async fn get_users_following( &self, user_id: &str, query: Option<UserQueryParams>, ) -> Result<ResponseWithHeaders, TweetyError>
GET /2/users/:id/following Returns a list of users the specified user ID is following. Docs
Source§impl TweetyClient
REFERENCE LINK
Hide replies
PUT /2/tweets/:id/hidden
Hides or unhides a reply to a Tweet.
Endpoint URL
https://api.x.com/2/tweets/:id/hidden
hidden boolean Indicates if the Tweet was successfully hidden or unhidden.
impl TweetyClient
REFERENCE LINK Hide replies PUT /2/tweets/:id/hidden Hides or unhides a reply to a Tweet. Endpoint URL https://api.x.com/2/tweets/:id/hidden hidden boolean Indicates if the Tweet was successfully hidden or unhidden.
pub async fn hide_tweet( self, tweet_id: &str, ) -> Result<ResponseWithHeaders, TweetyError>
Source§impl TweetyClient
impl TweetyClient
Sourcepub async fn unlike_tweet(
&self,
user_id: u64,
tweet_id: u64,
) -> Result<ResponseWithHeaders, TweetyError>
pub async fn unlike_tweet( &self, user_id: u64, tweet_id: u64, ) -> Result<ResponseWithHeaders, TweetyError>
DELETE https://api.x.com/2/tweets/:id/likes/:tweet_id (unlike a Post) https://developer.x.com/en/docs/x-api/tweets/likes/migrate/manage-likes-standard-to-twitter-api-v2
Sourcepub async fn get_users_who_liked_a_post(
&self,
post_id: &str,
) -> Result<ResponseWithHeaders, TweetyError>
pub async fn get_users_who_liked_a_post( &self, post_id: &str, ) -> Result<ResponseWithHeaders, TweetyError>
Users who have liked a Post https://developer.x.com/en/docs/x-api/tweets/likes/api-reference
Sourcepub async fn get_posts_liked_by_a_user(
&self,
user_id: &str,
) -> Result<ResponseWithHeaders, TweetyError>
pub async fn get_posts_liked_by_a_user( &self, user_id: &str, ) -> Result<ResponseWithHeaders, TweetyError>
Posts liked by a user https://developer.x.com/en/docs/x-api/tweets/likes/api-reference
Sourcepub async fn like_a_post(
&self,
user_id: &str,
) -> Result<ResponseWithHeaders, TweetyError>
pub async fn like_a_post( &self, user_id: &str, ) -> Result<ResponseWithHeaders, TweetyError>
MANAGE LIKES Allows a user ID to like a Post https://developer.x.com/en/docs/x-api/tweets/likes/api-reference
Sourcepub async fn unlike_a_post(
&self,
user_id: &str,
tweet_id: &str,
) -> Result<ResponseWithHeaders, TweetyError>
pub async fn unlike_a_post( &self, user_id: &str, tweet_id: &str, ) -> Result<ResponseWithHeaders, TweetyError>
Allows a user ID to unlike a Post https://developer.x.com/en/docs/x-api/tweets/likes/api-reference
Source§impl TweetyClient
impl TweetyClient
Sourcepub async fn get_users_mentions(
&self,
user_id: &str,
query_params: Option<QueryParams>,
) -> Result<ResponseWithHeaders, TweetyError>
pub async fn get_users_mentions( &self, user_id: &str, query_params: Option<QueryParams>, ) -> Result<ResponseWithHeaders, TweetyError>
Authentication methods supported by this endpoint OAuth 1.0a is also available for this endpoint. OAuth 2.0 Authorization Code with PKCE OAuth 2.0 App-only Docs
Source§impl TweetyClient
Retweets
API reference index
For the complete API reference, select an endpoint from the list:
Docs
impl TweetyClient
Retweets API reference index For the complete API reference, select an endpoint from the list: Docs
Sourcepub async fn fetch_retweeters(
self,
tweet_id: &str,
) -> Result<ResponseWithHeaders, TweetyError>
pub async fn fetch_retweeters( self, tweet_id: &str, ) -> Result<ResponseWithHeaders, TweetyError>
Users who have Retweeted a Post
Sourcepub async fn retweet(
&self,
tweet_id: &str,
) -> Result<ResponseWithHeaders, TweetyError>
pub async fn retweet( &self, tweet_id: &str, ) -> Result<ResponseWithHeaders, TweetyError>
Causes the user ID identified in the path parameter to Retweet the target Tweet.
Sourcepub async fn unretweet(
&self,
user_id: &str,
source_tweet_id: &str,
) -> Result<ResponseWithHeaders, TweetyError>
pub async fn unretweet( &self, user_id: &str, source_tweet_id: &str, ) -> Result<ResponseWithHeaders, TweetyError>
Allows a user or authenticated user ID to remove the Retweet of a Tweet. The request succeeds with no action when the user sends a request to a user they’re not Retweeting the Tweet or have already removed the Retweet of. Docs
Sourcepub async fn fetch_retweets(
self,
user_id: &str,
params: Option<RetweetQueryParams>,
) -> Result<ResponseWithHeaders, TweetyError>
pub async fn fetch_retweets( self, user_id: &str, params: Option<RetweetQueryParams>, ) -> Result<ResponseWithHeaders, TweetyError>
Source§impl TweetyClient
impl TweetyClient
Sourcepub async fn recent_search(
&self,
query: &str,
query_params: Option<QueryParams>,
) -> Result<ResponseWithHeaders, TweetyError>
pub async fn recent_search( &self, query: &str, query_params: Option<QueryParams>, ) -> Result<ResponseWithHeaders, TweetyError>
Search for Posts published in the last 7 days The recent search endpoint returns Tweets from the last seven days that match a search query. Docs
Sourcepub async fn full_archive_search(
&self,
query: &str,
query_params: Option<QueryParams>,
) -> Result<ResponseWithHeaders, TweetyError>
pub async fn full_archive_search( &self, query: &str, query_params: Option<QueryParams>, ) -> Result<ResponseWithHeaders, TweetyError>
Only available to those with Pro and Enterprise access Search the full archive of Posts Authentication methods supported by this endpoint OAuth 2.0 App-only Docs
Source§impl TweetyClient
impl TweetyClient
Sourcepub async fn get_tweet(
&self,
tweet_id: Ids,
) -> Result<ResponseWithHeaders, TweetyError>
pub async fn get_tweet( &self, tweet_id: Ids, ) -> Result<ResponseWithHeaders, TweetyError>
GET A TWEET We need to pass the tweet id we want to get its metadata information GET /2/tweets Returns a variety of information about the Tweet specified by the requested ID or list of IDs. Docs
Sourcepub async fn get_tweet_info(
&self,
tweet_id: &str,
) -> Result<ResponseWithHeaders, TweetyError>
pub async fn get_tweet_info( &self, tweet_id: &str, ) -> Result<ResponseWithHeaders, TweetyError>
GET /2/tweets/:id Returns a variety of information about a single Tweet specified by the requested ID. Docs
Sourcepub async fn post_tweet(
&self,
message: &str,
body_params: Option<PostTweetParams>,
) -> Result<ResponseWithHeaders, TweetyError>
pub async fn post_tweet( &self, message: &str, body_params: Option<PostTweetParams>, ) -> Result<ResponseWithHeaders, TweetyError>
SEND tweet message, Media id is optional for attaching tweets with an image You need to uploads the image first and then pass the returned media ID here Docs
Sourcepub async fn edit_tweet(
self,
message: &str,
media_id: &str,
) -> Result<ResponseWithHeaders, TweetyError>
pub async fn edit_tweet( self, message: &str, media_id: &str, ) -> Result<ResponseWithHeaders, TweetyError>
UPDATE/EDIT TWEET
Sourcepub async fn delete_tweet(
&self,
tweet_id: &str,
) -> Result<ResponseWithHeaders, TweetyError>
pub async fn delete_tweet( &self, tweet_id: &str, ) -> Result<ResponseWithHeaders, TweetyError>
DELETE TWEET Path parameter, pass The Tweet ID you are deleting. Delete Docs
Source§impl TweetyClient
impl TweetyClient
Sourcepub async fn upload_file(&self, path: &Path) -> Result<u64, TweetyError>
pub async fn upload_file(&self, path: &Path) -> Result<u64, TweetyError>
Create a media from a file
Will fail if consumer_key
, consumer_secret
, access_token
and access_token_secret
are not set
Will take a path as a parameter and return the media id of the uploaded file is sucess and TweetyError incase of failure
Source§impl TweetyClient
Users lookup
API reference index
impl TweetyClient
Users lookup API reference index
Sourcepub async fn get_user_by_id(
&self,
user_id: &str,
params: Option<UserQueryParams>,
) -> Result<ResponseWithHeaders, TweetyError>
pub async fn get_user_by_id( &self, user_id: &str, params: Option<UserQueryParams>, ) -> Result<ResponseWithHeaders, TweetyError>
Fetches detailed information about a user specified by their ID.
§Arguments
user_id
- The ID of the user to retrieve information about.params
- Additional query parameters to include in the request, such as expansions or specific fields.
§Returns
A Result
containing a Response
with the user data if successful, or a TweetyError
if an error occurs.
§Examples
use tweety_rs::api::client::TweetyClient;
use tweety_rs::api::error::TweetyError;
use tweety_rs::api::user::UserQueryParams;
async fn example() -> Result<(), TweetyError> {
let client = TweetyClient::new("your_consumer_key","your_access_token","your_consumer_key_secret","your_access_token_secret");
let user_id = "12345";
let params = None;
let response = client.get_user_by_id(user_id, params).await?;
println!("{:?}", response);
Ok(())
}
Sourcepub async fn get_users(
&self,
ids: Vec<String>,
params: Option<UserQueryParams>,
) -> Result<ResponseWithHeaders, TweetyError>
pub async fn get_users( &self, ids: Vec<String>, params: Option<UserQueryParams>, ) -> Result<ResponseWithHeaders, TweetyError>
https://developer.x.com/en/docs/x-api/users/lookup/api-reference/get-users#tab1 Endpoint URL: https://api.x.com/2/users Fetches detailed information about one or more users specified by their IDs.
Sourcepub async fn get_users_by_username(
&self,
username: &[&str],
) -> Result<ResponseWithHeaders, TweetyError>
pub async fn get_users_by_username( &self, username: &[&str], ) -> Result<ResponseWithHeaders, TweetyError>
Returns a variety of information about one or more users specified by their usernames. Required string A comma separated list of user IDs. Up to 100 are allowed in a single request. Make sure to not include a space between commas and fields.
Sourcepub async fn get_users_by_usernames(
&self,
user_names: &[&str],
params: Option<UserQueryParams>,
) -> Result<ResponseWithHeaders, TweetyError>
pub async fn get_users_by_usernames( &self, user_names: &[&str], params: Option<UserQueryParams>, ) -> Result<ResponseWithHeaders, TweetyError>
GET /2/users/by Returns a variety of information about one or more users specified by their usernames. usernames Required string A comma separated list of Twitter usernames (handles). Up to 100 are allowed in a single request. Make sure to not include a space between commas and fields.
Sourcepub async fn get_user_me(
&self,
params: Option<UserQueryParams>,
) -> Result<ResponseWithHeaders, TweetyError>
pub async fn get_user_me( &self, params: Option<UserQueryParams>, ) -> Result<ResponseWithHeaders, TweetyError>
Returns information about an authorized user. https://developer.x.com/en/docs/x-api/users/lookup/api-reference/get-users-me#