Expand description
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
ⓘ
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.