6 releases

✓ Uses Rust 2018 edition

0.2.2 Nov 29, 2019
0.2.1 Jul 19, 2019
0.1.2 Jul 19, 2019

#37 in Authentication

49 downloads per month

MIT license

25KB
457 lines

Roux.rs

CircleCI Documentation Crate GitHub

A simple Reddit API wrapper implemented in Rust.

Disclaimer

Roux is still in very early development, lots of documentation and features are missing. In the mean time it's probably better to use one of these alternatives:


lib.rs:

roux.rs

This crate provides simple access to the Reddit API.

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();

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. linux:rawr:v0.0.1 (by /u/Aurora0001).

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();

let me = client.unwrap();

me.submit_text("TEXT_TITLE", "TEXT_BODY", "SUBREDDIT");

Submit A Link Post

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");

Dependencies

~16MB
~390K SLoC