twapi-v2-rs

Twitter API v2 library.

Documentation

Features

default

rustls-tls

retry

oauth

oauth10a

Changes

CHANGELOG.md

Test status

TEST.md

Examples

API(bearer)

```rust use twapiv2::api::{get2tweetsid, BearerAuthentication};

[tokio::main]

async fn main() { let bearercode = std::env::var("BEARERCODE").unwrap(); let auth = BearerAuthentication::new(bearercode); let tweetid = std::env::var("TWEETID").unwrap(); let res = get2tweetsid::Api::open(&tweetid) .execute(&auth) .await; if let Some((val, ratelimit)) = res { println!("{:?}", val); } } ```

API(OAuth1.0a)

```rust use twapiv2::api::{get2tweetsid, BearerAuthentication}; use twapi_v2::oauth10a::OAuthAuthentication;

[tokio::main]

async fn main() { let auth = OAuthAuthentication::new( std::env::var("CONSUMERKEY").unwrapordefault(), std::env::var("CONSUMERSECRET").unwrapordefault(), std::env::var("ACCESSKEY").unwrapordefault(), std::env::var("ACCESSSECRET").unwrapordefault(), ); let tweetid = std::env::var("TWEETID").unwrap(); let res = get2tweetsid::Api::open(&tweetid) .execute(&auth) .await; if let Some((val, rate_limit)) = res { println!("{:?}", val); } } ```

Twitter OAuth Web

cd examples/oauth-web API_KEY_CODE=XXXX API_SECRET_CODE=XXXX cargo run http://localhost:3000/

Streaming

cd examples/streaming BEARER_CODE=XXXXX cargo run