Roux is a simple, asynchronous Reddit API wrapper implemented in Rust.
To create an OAuth client with the Reddit API, use the Reddit
class.
```rust
use roux::Reddit;
let client = Reddit::new("USERAGENT", "CLIENTID", "CLIENT_SECRET")
.username("USERNAME")
.password("PASSWORD")
.login()
.await;
let me = client.unwrap();
``
It is important that you pick a good user agent. The ideal format is
platform:program:version (by /u/yourname), e.g.
macos:roux:v0.3.0 (by /u/beanpup_py)`.
This will authticate you as the user given in the username function.
Using the OAuth client, you can:
```rust use roux::Reddit; let client = Reddit::new("USERAGENT", "CLIENTID", "CLIENT_SECRET") .username("USERNAME") .password("PASSWORD") .login() .await;
let me = client.unwrap(); me.submittext("TEXTTITLE", "TEXT_BODY", "SUBREDDIT"); ```
```rust use roux::Reddit; let client = Reddit::new("USERAGENT", "CLIENTID", "CLIENT_SECRET") .username("USERNAME") .password("PASSWORD") .login() .await;
let me = client.unwrap(); me.submitlink("LINKTITLE", "LINK", "SUBREDDIT"); ```
There are also read-only modules that don't need authentication:
tokio_new
- use tokio 1.1.0 based reqwesttokio_back_compat
- use tokio 0.2 based reqwestRoux is still being actively maintained and currently covers the most common and useful endpoints. If you see something missing or encounter a bug, feel free to open an issue or create a pull request.
Roux is licensed under the MIT license (see LICENSE file).