Struct kuon::TwitterAPI[][src]

pub struct TwitterAPI { /* fields omitted */ }

Implementations

impl TwitterAPI[src]

pub fn encode(target: &str) -> PercentEncode<'_>[src]

impl TwitterAPI[src]

pub fn followers_ids(&self) -> FollowersIds<'_>[src]

Example

let api = kuon::TwitterAPI::new_using_env().await?;
let res = api.followers_ids().screen_name("rustlang").count(100).send().await?;

GET followers/ids

Returns a cursored collection of user IDs for every user following the specified user. At this time, results are ordered with the most recent following first — however, this ordering is subject to unannounced change and eventual consistency issues. Results are given in groups of 5,000 user IDs and multiple “pages” of results can be navigated through using the next_cursor value in subsequent requests. See Using cursors to navigate collections for more information. This method is especially powerful when used in conjunction with GET users / lookup, a method that allows you to convert user IDs into full user objects in bulk.

Resource Information

Q.A.
Response formatsJSON
Requires authentication?Yes
Rate limited?Yes
Requests / 15-min window (user auth)15
Requests / 15-min window (app auth)15

https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/follow-search-get-users/api-reference/get-followers-ids

impl TwitterAPI[src]

pub fn builder() -> ClientBuilder<(), (), (), ()>[src]

Creates ClientBuilder that helps construct a configured TwitterAPI.

This is exactly equivalent to ClientBuilder::new.

pub async fn new_using_env() -> Result<Self>[src]

pub fn oauth_token(&self) -> OAuthToken[src]

impl TwitterAPI[src]

pub async fn raw_get<T>(
    &self,
    endpoint: &str,
    params: &HashMap<&str, String>
) -> Result<T, Error> where
    T: DeserializeOwned
[src]

pub async fn raw_post<T>(
    &self,
    endpoint: &str,
    params: &HashMap<&str, String>
) -> Result<T, Error> where
    T: DeserializeOwned
[src]

impl TwitterAPI[src]

pub fn favorite(&self) -> Favorite<'_, ()>[src]

Example

let api = kuon::TwitterAPI::new_using_env().await?;
let res = api.favorite().id(0).include_entities(true).send().await?;

POST favorites/create

Note: favorites are now known as likes. Favorites (likes) the Tweet specified in the ID parameter as the authenticating user. Returns the favorite Tweet when successful. The process invoked by this method is asynchronous. The immediately returned Tweet object may not indicate the resultant favorited status of the Tweet. A 200 OK response from this method will indicate whether the intended action was successful or not.

Resource Information

Q.A.
Requires authentication?Yes (user context only)
Rate limited?Yes
Requests / 24-hour window1000 per user; 1000 per app

https://developer.twitter.com/en/docs/twitter-api/v1/tweets/post-and-engage/api-reference/post-favorites-create

impl TwitterAPI[src]

pub fn home_timeline(&self) -> HomeTimeline<'_>[src]

Example

let api = kuon::TwitterAPI::new_using_env().await?;
let res = api.home_timeline().count(10).send().await?;
for tweet in res {
    println!("{}", tweet.text);
}

GET statuses/home_timeline

Returns a collection of the most recent Tweets and Retweets posted by the authenticating user and the users they follow. The home timeline is central to how most users interact with the Twitter service. Up to 800 Tweets are obtainable on the home timeline. It is more volatile for users that follow many users or follow users who Tweet frequently.

See Working with Timelines for instructions on traversing timelines efficiently.

Resource Information

Q.A.
Requires authentication?Yes (user context only)
Rate limited?Yes
Requests / 15-min window (user auth)15

https://developer.twitter.com/en/docs/twitter-api/v1/tweets/timelines/api-reference/get-statuses-home_timeline

impl TwitterAPI[src]

pub fn retweet(&self) -> Retweet<'_, ()>[src]

Example

let api = kuon::TwitterAPI::new_using_env().await?;
let res = api.retweet().id(1367127631175499779u64).trim_user(true).send().await?;

POST statuses/retweet/:id

Retweets a tweet. Returns the original Tweet with Retweet details embedded.

Usage Notes:

  • This method is subject to update limits. A HTTP 403 will be returned if this limit as been hit.
  • Twitter will ignore attempts to perform duplicate retweets.
  • The retweet_count will be current as of when the payload is generated and may not reflect the exact count. It is intended as an approximation.

Resource Information

Q.A.
Requires authentication?Yes (user context only)
Rate limited?Yes
Requests / 3-hour window300* per user; 300* per app

https://developer.twitter.com/en/docs/twitter-api/v1/tweets/post-and-engage/api-reference/post-statuses-retweet-id

impl TwitterAPI[src]

pub fn search_tweets(&self) -> SearchTweets<'_, ()>[src]

Example

let api = kuon::TwitterAPI::new_using_env().await?;
let res = api.search_tweets().q("rust").count(100).send().await?;
for tweet in res.statuses {
    println!("{}", tweet.text);
}

Standard search API

Returns a collection of relevant Tweets matching a specified query.

Please note that Twitter’s search service and, by extension, the Search API is not meant to be an exhaustive source of Tweets. Not all Tweets will be indexed or made available via the search interface.

To learn how to use Twitter Search effectively, please see the Standard search operators page for a list of available filter operators. Also, see the Working with Timelines page to learn best practices for navigating results by since_id and max_id.

Q.A.
Requires authentication?Yes
Rate limited?Yes
Requests / 15-min window (user auth)180
Requests / 15-min window (app auth)450

https://developer.twitter.com/en/docs/twitter-api/v1/tweets/search/api-reference/get-search-tweets

impl TwitterAPI[src]

pub fn show_tweet(&self) -> ShowTweet<'_, ()>[src]

Example

let api = kuon::TwitterAPI::new_using_env().await?;
let tweet = api.show_tweet().id(1283742285381816320u64).send().await?;

GET statuses/show/:id

Returns a single Tweet, specified by the id parameter. The Tweet’s author will also be embedded within the Tweet.

See GET statuses / lookup for getting Tweets in bulk (up to 100 per call). See also Embedded Timelines, Embedded Tweets, and GET statuses/oembed for tools to render Tweets according to Display Requirements.

About Geo

If there is no geotag for a status, then there will be an empty <geo></geo> or "geo" : {}. This can only be populated if the user has used the Geotagging API to send a statuses/update.

The JSON response mostly uses conventions laid out in GeoJSON. The coordinates that Twitter renders are reversed from the GeoJSON specification (GeoJSON specifies a longitude then a latitude, whereas Twitter represents it as a latitude then a longitude), eg: "geo": { "type":"Point", "coordinates":[37.78029, -122.39697] }

Q.A.
Requires authentication?Yes
Rate limited?Yes
Requests / 15-min window (user auth)900
Requests / 15-min window (app auth)900

https://developer.twitter.com/en/docs/twitter-api/v1/tweets/post-and-engage/api-reference/get-statuses-show-id

impl TwitterAPI[src]

pub fn tweet(&self) -> Tweet<'_, ()>[src]

Example

let api = kuon::TwitterAPI::new_using_env().await?;
let res = api.tweet().status("this is test tweet from kuon.").send().await?;

POST statuses/update

Updates the authenticating user’s current status, also known as Tweeting.

For each update attempt, the update text is compared with the authenticating user’s recent Tweets. Any attempt that would result in duplication will be blocked, resulting in a 403 error. A user cannot submit the same status twice in a row.

While not rate limited by the API, a user is limited in the number of Tweets they can create at a time. If the number of updates posted by the user reaches the current allowed limit this method will return an HTTP 403 error.

About Geo

  • Any geo-tagging parameters in the update will be ignored if geo_enabled for the user is false (this is the default setting for all users, unless the user has enabled geolocation in their settings)
  • The number of digits after the decimal separator passed to lat (up to 8) is tracked so that when the lat is returned in a status object it will have the same number of digits after the decimal separator.
  • Use a decimal point as the separator (and not a decimal comma) for the latitude and the longitude - usage of a decimal comma will cause the geo-tagged portion of the status update to be dropped.
  • For JSON, the response mostly uses conventions described in GeoJSON. However, the geo object coordinates that Twitter renders are reversed from the GeoJSON specification. GeoJSON specifies a longitude then a latitude, whereas Twitter represents it as a latitude then a longitude: “geo”: { “type”:“Point”, “coordinates”:[37.78217, -122.40062] }
  • The coordinates object is replacing the geo object (no deprecation date has been set for the geo object yet) – the difference is that the coordinates object, in JSON, is now rendered correctly in GeoJSON.
  • If a place_id is passed into the status update, then that place will be attached to the status. If no place_id was explicitly provided, but latitude and longitude are, the API attempts to implicitly provide a place by calling geo/reverse_geocode.
  • Users have the ability to remove all geotags from all their Tweets en masse via the user settings page. Currently there is no method to remove geotags from individual Tweets.
Q.A.
Requires authentication?Yes (user context only)
Rate limited?Yes
Requests / 3-hour window300* per user; 300* per app

https://developer.twitter.com/en/docs/twitter-api/v1/tweets/post-and-engage/api-reference/post-statuses-update

impl TwitterAPI[src]

pub fn user_timeline(&self) -> UserTimeline<'_>[src]

Example

let api = kuon::TwitterAPI::new_using_env().await?;
let res = api.user_timeline().screen_name("rustlang").count(10).send().await?;
for tweet in res {
    println!("{}", tweet.text);
}

GET statuses/user_timeline

Important notice: On June 19, 2019, we began enforcing a limit of 100,000 requests per day to the /statuses/user_timeline endpoint, in addition to existing user-level and app-level rate limits. This limit is applied on a per-application basis, meaning that a single developer app can make up to 100,000 calls during any single 24-hour period.

Returns a collection of the most recent Tweets posted by the user indicated by the screen_name or user_id parameters.

User timelines belonging to protected users may only be requested when the authenticated user either “owns” the timeline or is an approved follower of the owner.

The timeline returned is the equivalent of the one seen as a user’s profile on Twitter.

This method can only return up to 3,200 of a user’s most recent Tweets. Native retweets of other statuses by the user is included in this total, regardless of whether include_rts is set to false when requesting this resource.

See Working with Timelines for instructions on traversing timelines.

See Embedded Timelines, Embedded Tweets, and GET statuses/oembed for tools to render Tweets according to Display Requirements.

Resource Information

Q.A.
Requires authentication?Yes
Rate limited?Yes
Requests / 15-min window (user auth)900
Requests / 15-min window (app auth)1500
Requests / 24-hour window100,000

https://developer.twitter.com/en/docs/twitter-api/v1/tweets/timelines/api-reference/get-statuses-user_timeline

Trait Implementations

impl Clone for TwitterAPI[src]

fn clone(&self) -> TwitterAPI[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for TwitterAPI[src]

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

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T> Instrument for T[src]

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

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

fn in_current_span(self) -> Instrumented<Self>[src]

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

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

Performs the conversion.