9 releases

0.1.8 Oct 25, 2022
0.1.7 Aug 6, 2022
0.1.6 Jun 19, 2022
0.1.5 Apr 25, 2022
0.1.0 Mar 27, 2022

#147 in HTTP client

Download history 217/week @ 2023-11-18 784/week @ 2023-11-25 908/week @ 2023-12-02 592/week @ 2023-12-09 662/week @ 2023-12-16 695/week @ 2023-12-23 616/week @ 2023-12-30 646/week @ 2024-01-06 361/week @ 2024-01-13 260/week @ 2024-01-20 337/week @ 2024-01-27 268/week @ 2024-02-03 276/week @ 2024-02-10 289/week @ 2024-02-17 284/week @ 2024-02-24 165/week @ 2024-03-02

1,058 downloads per month

MIT/Apache

130KB
4K SLoC

twitter-v2

v2

Supports all of the Twitter v2 API endpoints, but many remain fairly untested due to the complexity of the API and time restraints. PRs and Issues are very welcome! As this repo currently has limited documentation, please check out the amazing Twitter API v2 Docs for information.

Features

  • oauth2: Included by default. See the examples for how to use.
  • native-tls: Use native-tls as TLS backend (default)
  • rustls-tls: Use rustls as TLS backend

Example

use twitter_v2::TwitterApi;
use twitter_v2::authorization::{Oauth2Token, BearerToken};
use twitter_v2::query::{TweetField, UserField};

let auth = BearerToken::new(std::env::var("APP_BEARER_TOKEN").unwrap());
let tweet = TwitterApi::new(auth)
    .get_tweet(1261326399320715264)
    .tweet_fields([TweetField::AuthorId, TweetField::CreatedAt])
    .send()
    .await?
    .into_data()
    .expect("this tweet should exist");
assert_eq!(tweet.id, 1261326399320715264);
assert_eq!(tweet.author_id.unwrap(), 2244994945);
assert_eq!(tweet.created_at.unwrap(), datetime!(2020-05-15 16:03:42 UTC));

let auth: Oauth2Token = serde_json::from_str(&stored_oauth2_token)?;
let my_followers = TwitterApi::new(auth)
    .with_user_ctx()
    .await?
    .get_my_followers()
    .user_fields([UserField::Username])
    .max_results(20)
    .send()
    .await?
    .into_data();

License: MIT OR Apache-2.0

Dependencies

~10–24MB
~369K SLoC