All Projects β†’ egg-mode-rs β†’ Egg Mode

egg-mode-rs / Egg Mode

Licence: mpl-2.0
a twitter api crate for rust

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to Egg Mode

Harpy
A Twitter app built with Flutter
Stars: ✭ 211 (-15.26%)
Mutual labels:  twitter-api, twitter
Twitterdelete
πŸ’€ Delete your old, unpopular tweets.
Stars: ✭ 231 (-7.23%)
Mutual labels:  twitter-api, twitter
Twitterbot
Several PHP scripts for making Twitter bots that retweet certain terms, or post from a data source (rss, database, markov body, picture folder).
Stars: ✭ 106 (-57.43%)
Mutual labels:  twitter-api, twitter
21 Recipes
πŸ“• An R/rtweet edition of Matthew A. Russell's Python Twitter Recipes Book
Stars: ✭ 69 (-72.29%)
Mutual labels:  twitter-api, twitter
Twitter Api Php
The simplest PHP Wrapper for Twitter API v1.1 calls
Stars: ✭ 1,808 (+626.1%)
Mutual labels:  twitter-api, twitter
Tweetview
This project is an example Android Twitter feed reader app from the Codehenge Android development tutorials.
Stars: ✭ 75 (-69.88%)
Mutual labels:  twitter-api, twitter
Twitter Python Ads Sdk
A Twitter supported and maintained Ads API SDK for Python.
Stars: ✭ 114 (-54.22%)
Mutual labels:  twitter-api, twitter
Talon For Twitter Android
The most powerful and beautiful Twitter client available.
Stars: ✭ 1,022 (+310.44%)
Mutual labels:  twitter-api, twitter
Csscreatures
Make a creature by tweeting to @csscreatures
Stars: ✭ 144 (-42.17%)
Mutual labels:  twitter-api, twitter
Twitwork
Monitor twitter stream
Stars: ✭ 133 (-46.59%)
Mutual labels:  twitter-api, twitter
Autohook
Automatically setup and serve webhooks for the Twitter Account Activity API
Stars: ✭ 67 (-73.09%)
Mutual labels:  twitter-api, twitter
Twitter To Sqlite
Save data from Twitter to a SQLite database
Stars: ✭ 203 (-18.47%)
Mutual labels:  twitter-api, twitter
Likelo
Twitter auto like bot, Under DevelopmentπŸ‘·, Pre Alpha
Stars: ✭ 64 (-74.3%)
Mutual labels:  twitter-api, twitter
Tia
Your Advanced Twitter stalking tool
Stars: ✭ 98 (-60.64%)
Mutual labels:  twitter-api, twitter
Twitter.jl
Julia package to access Twitter API
Stars: ✭ 58 (-76.71%)
Mutual labels:  twitter-api, twitter
Awesome Twitter Tools
A curated list of awesome twitter tools
Stars: ✭ 113 (-54.62%)
Mutual labels:  twitter-api, twitter
Rtweet Workshop
Slides and code for the rtweet workshop
Stars: ✭ 41 (-83.53%)
Mutual labels:  twitter-api, twitter
Tweepy
Twitter for Python!
Stars: ✭ 8,293 (+3230.52%)
Mutual labels:  twitter-api, twitter
Twurl
OAuth-enabled curl for the Twitter API
Stars: ✭ 1,648 (+561.85%)
Mutual labels:  twitter-api, twitter
Twitter Bot
Node js twitter bot to send auto welcome message for your new followers
Stars: ✭ 184 (-26.1%)
Mutual labels:  twitter-api, twitter

egg-mode

Twitter library for Rust Build Status

Documentation

This is a library for interacting with Twitter from Rust. You can see how much of the Public API is available in the file TODO.md. In addition to eventually implementing the entire Public API, an explicit goal for egg-mode is to make it as easy as possible for a client of this library to interact with the Twitter API. Parts of this library are added as a convenience on top of the API mechanisms; for example, cursored lists of users and tweets can be used as an iterator in addition to being able to manually load a page at a time.

Starting in version v0.14, egg-mode uses the async/await syntax and therefore requires Rust v1.39.0+.

NOTE: Previous versions of egg-mode contained a port of twitter-text to use for character counting and mention/hashtag/url extraction. That has since been extracted into its own crate, egg-mode-text.

To start using this library, put the following into your Cargo.toml:

[dependencies]
egg-mode = "0.15"

By default, egg-mode uses native-tls for encryption, but also supports rustls. This may be helpful if you wish to avoid linking against OpenSSL. To enable, modify your Cargo.toml entry:

egg-mode = { version = "0.15", features = ["rustls"], default-features = false }

If you also want to avoid using the root certificates on your operating system, the feature rustls_webpki can be used instead to enable rustls and compile the Mozilla root certificates into the final binary, bypassing the operating system's root certificates. To use this feature, put this in your Cargo.toml instead:

egg-mode = { version = "0.15", features = ["rustls_webpki"], default-features = false }

See available methods and tips to get started in the Documentation.

To authenticate a user and request an access token:

// NOTE: this assumes you are running inside an `async` function

let con_token = egg_mode::KeyPair::new("consumer key", "consumer secret");
// "oob" is needed for PIN-based auth; see docs for `request_token` for more info
let request_token = egg_mode::auth::request_token(&con_token, "oob").await.unwrap();
let auth_url = egg_mode::auth::authorize_url(&request_token);

// give auth_url to the user, they can sign in to Twitter and accept your app's permissions.
// they'll receive a PIN in return, they need to give this to your application

let verifier = "123456"; //read the PIN from the user here

// note this consumes con_token; if you want to sign in multiple accounts, clone it here
let (token, user_id, screen_name) =
    egg_mode::auth::access_token(con_token, &request_token, verifier).await.unwrap();

// token can be given to any egg_mode method that asks for a token
// user_id and screen_name refer to the user who signed in

As the last line shows, this also returns the User ID and username of the user that authenticated with your application. With this access token, all of the other Twitter functions become available.

With this token in hand, you can get a user's profile information like this:

let rustlang = egg_mode::user::show("rustlang", &token).await.unwrap();

println!("{} (@{})", rustlang.name, rustlang.screen_name);

For more examples of how to use this library, check the files in the examples folder. The authentication code for most of them is in examples/common/mod.rs, though that's also mostly wrapped up in code to write the access token to disk and load it back in. examples/bearer.rs is an example of using application-only authentication to get a Bearer token and use it to load a user's posts. Other examples showcase a handful of actions from their related module. To run any of the examples for yourself, see the notes in examples/common/mod.rs.

If you've found egg-mode useful, or just want to communicate your first impressions of it, please track me down on Twitter and let me know!

License

This library is licensed under the Mozilla Public License, version 2.0. See the LICENSE file for details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].