Struct TweetyClient

Source
pub struct TweetyClient { /* private fields */ }

Implementations§

Source§

impl TweetyClient

§MANAGE BOOKMARKS

Docs

Source

pub async fn get_user_bookmark( self, user_id: &str, ) -> Result<ResponseWithHeaders, TweetyError>

Bookmarks lookup Lookup a user’s Bookmarks

Source

pub async fn bookmark_post( self, post_id: &str, ) -> Result<ResponseWithHeaders, TweetyError>

Bookmark a Post

Source

pub async fn delete_bookmark( self, user_id: &str, tweet_id: &str, ) -> Result<ResponseWithHeaders, TweetyError>

Remove a Bookmark of a Post

Source§

impl TweetyClient

Source

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",
);
Source

pub fn is_initialized(&self) -> bool

Source§

impl TweetyClient

Source

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

Source

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.

Source

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

Source

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

Source

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

Source

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

Source

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.

Source

pub async fn hide_tweet( self, tweet_id: &str, ) -> Result<ResponseWithHeaders, TweetyError>

Source§

impl TweetyClient

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

pub async fn fetch_retweeters( self, tweet_id: &str, ) -> Result<ResponseWithHeaders, TweetyError>

Users who have Retweeted a Post

Source

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.

Source

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

Source

pub async fn fetch_retweets( self, user_id: &str, params: Option<RetweetQueryParams>, ) -> Result<ResponseWithHeaders, TweetyError>

§Query Parameters

Docs Returns the Retweets for a given Tweet ID.

Source§

impl TweetyClient

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

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

Source

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

Source

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

Source

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

Source

pub async fn edit_tweet( self, message: &str, media_id: &str, ) -> Result<ResponseWithHeaders, TweetyError>

UPDATE/EDIT TWEET

Source

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

Source

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

Source

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(())
}
Source

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.

Source

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.

Source

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.

Source

pub async fn get_user_me( &self, params: Option<UserQueryParams>, ) -> Result<ResponseWithHeaders, TweetyError>

Trait Implementations§

Source§

impl Debug for TweetyClient

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for TweetyClient

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for TweetyClient

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> ErasedDestructor for T
where T: 'static,