Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tesaguri/twitter-stream-rs
A Rust library for listening on Twitter Streaming API.
https://github.com/tesaguri/twitter-stream-rs
rust rust-library twitter twitter-api twitter-streaming-api
Last synced: about 2 months ago
JSON representation
A Rust library for listening on Twitter Streaming API.
- Host: GitHub
- URL: https://github.com/tesaguri/twitter-stream-rs
- Owner: tesaguri
- License: mit
- Created: 2016-12-22T12:57:53.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2021-11-14T10:28:05.000Z (about 3 years ago)
- Last Synced: 2023-11-20T16:20:39.193Z (about 1 year ago)
- Topics: rust, rust-library, twitter, twitter-api, twitter-streaming-api
- Language: Rust
- Homepage:
- Size: 578 KB
- Stars: 68
- Watchers: 3
- Forks: 10
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Twitter Stream
[![Build Status](https://github.com/tesaguri/twitter-stream-rs/workflows/CI/badge.svg)](https://github.com/tesaguri/twitter-stream-rs/actions)
[![Current Version](https://img.shields.io/crates/v/twitter-stream.svg)](https://crates.io/crates/twitter-stream)
[![Documentation](https://docs.rs/twitter-stream/badge.svg)](https://docs.rs/twitter-stream/)A Rust library for listening on Twitter Streaming API.
## Usage
Add this to your `Cargo.toml`:
```toml
[dependencies]
futures = "0.3"
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
twitter-stream = "0.13"
```Here is a basic example that prints public mentions to @Twitter in JSON format:
```rust no_run
use futures::prelude::*;
use twitter_stream::{Token, TwitterStream};#[tokio::main]
async fn main() {
let token = Token::from_parts("consumer_key", "consumer_secret", "access_key", "access_secret");TwitterStream::track("@Twitter", &token)
.try_flatten_stream()
.try_for_each(|json| {
println!("{}", json);
future::ok(())
})
.await
.unwrap();
}
```## Alternatives
[`egg-mode`], a Twitter API client crate, implements a Streaming API client as well. The following table shows key differences between `twitter-stream` and `egg-mode`.
[`egg-mode`]: https://crates.io/crates/egg-mode
| | `twitter-stream` | `egg-mode` |
| ------------------------ | ------------------------------------------------ | -------------------------------------- |
| Streaming message type | `string::String` (raw JSON string) | `StreamMessage` (deserialized message) |
| REST API integration | No | Yes |
| Customizable HTTP client | Yes | No |If your application don't require explicit control over the raw JSON strings or underlying HTTP client, `egg-mode` may be a better choice.
## License
This project is licensed under the MIT license ([LICENSE](LICENSE) or https://opensource.org/licenses/MIT) unless explicitly stated otherwise.