[][src]Crate redbot

This crate is used to query the Reddit API.

First, create a Config struct. Then, use it to create an Api struct, which exposes several methods for querying the API, including the models module, which contains structs that map to Reddit objects, simplifying the interaction with the Reddit API.

Example

This example is not tested
use redbot::{Api, Config, Value};

fn main() {
    let config = Config::load_config("config.json").expect("Could not load confiog");
    let mut api = Api::new(config);
    api.do_login().expect("Could not perform login");

    let mut resp = match api.query("GET", "api/v1/me/karma", None, None) {
        Ok(resp) => resp,
        Err(err) => panic!(err),
    };
    let karma_breakdown: Value = match resp.json() {
        Ok(data) => data,
        Err(err) => panic!(err),
    };

    println!("{:?}", karma_breakdown);
}

Modules

errors

Error handling.

models

Struct-oriented access to the Reddit API.

query_listing

Structs for use in making and viewing listing requests and responses.

Structs

Api

Reddit API access. This is the struct that you'll be using to interact with the API.

Config

Program configuration - contains the required values to communicate with the Reddit OAuth API for a token.