38 stable releases

2.2.13 Sep 20, 2024
2.2.12 Mar 6, 2024
2.2.11 Jan 9, 2024
2.2.9 Jun 7, 2023
0.2.1 Jul 19, 2019

#287 in Web programming

Download history 64/week @ 2024-07-25 32/week @ 2024-08-01 32/week @ 2024-08-08 22/week @ 2024-08-15 14/week @ 2024-08-22 15/week @ 2024-08-29 21/week @ 2024-09-05 31/week @ 2024-09-12 235/week @ 2024-09-19 122/week @ 2024-09-26 80/week @ 2024-10-03 21/week @ 2024-10-10 23/week @ 2024-10-17 18/week @ 2024-10-24 29/week @ 2024-10-31 20/week @ 2024-11-07

92 downloads per month
Used in 6 crates (4 directly)

MIT license

83KB
1.5K SLoC

Roux

Build Documentation Crate GitHub

Roux is a simple, (a)synchronous Reddit API wrapper implemented in Rust.

Usage

Using OAuth

To create an OAuth client with the Reddit API, use the Reddit class.

use roux::Reddit;
let client = Reddit::new("USER_AGENT", "CLIENT_ID", "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:v2.0.0 (by /u/beanpup_py). This will authticate you as the user given in the username function.

Usage

Using the OAuth client, you can:

Submit A Text Post

use roux::Reddit;
let client = Reddit::new("USER_AGENT", "CLIENT_ID", "CLIENT_SECRET")
    .username("USERNAME")
    .password("PASSWORD")
    .login()
    .await;

let me = client.unwrap();
me.submit_text("TEXT_TITLE", "TEXT_BODY", "SUBREDDIT").await?;

Submit A Link Post

use roux::Reddit;
let client = Reddit::new("USER_AGENT", "CLIENT_ID", "CLIENT_SECRET")
    .username("USERNAME")
    .password("PASSWORD")
    .login()
    .await;

let me = client.unwrap();
me.submit_link("LINK_TITLE", "LINK", "SUBREDDIT").await?;

Read-Only Modules

There are also read-only modules that don't need authentication:

Blocking Client

You can use a blocking (synchronous) API instead of tokio by enabling the blocking feature.

[dependencies]
roux = { version = "2", features = ["blocking"] }
use roux::Reddit;
let client = Reddit::new("USER_AGENT", "CLIENT_ID", "CLIENT_SECRET")
    .username("USERNAME")
    .password("PASSWORD")
    .login();

let me = client.unwrap();
me.submit_link("LINK_TITLE", "LINK", "SUBREDDIT");

3rd-Party Libraries

  • roux-stream provides an API for continuously streaming new submissions and comments

Contributing

Roux is not in active development but is still being 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.

License

Roux is licensed under the MIT license (see LICENSE file).

Dependencies

~4–20MB
~226K SLoC