Crates.io | new-rawr |
lib.rs | new-rawr |
version | 0.0.1 |
source | src |
created_at | 2021-03-29 15:35:00.017924 |
updated_at | 2021-03-29 15:35:00.017924 |
description | An updated Rust API Wrapper for Reddit |
homepage | |
repository | https://github.com/wherkamp/new-rawr |
max_upload_size | |
id | 375241 |
size | 150,306 |
Welcome to new-rawr, the new Rust API Wrapper for Reddit. This library provides simple, pain-free access to the Reddit API in Rust. If you want to create a Reddit bot, scrape data from the API or create a web application powered by Reddit's API, rawr can help to do this simply and effectively.
This updates all the depends, and the rust version to the latest version.
extern crate new - rawr;
use rawr::prelude::*;
fn main() {
// Creates a new client to access the reddit API. You need to set a user agent so Reddit knows
// who is using this client.
let client = RedditClient::new("your user agent here", AnonymousAuthenticator::new());
// Access the subreddit /r/rust.
let subreddit = client.subreddit("rust");
// Gets the hot listing of /r/rust. If the API request fails, we will panic with `expect`.
let mut hot_listing = subreddit.hot(ListingOptions::default()).expect("Could not fetch post listing!");
// Iterates through the top 50 posts of /r/rust. If you do not `take(n)`, this iterator will
// continue forever!
for post in hot_listing.take(50) {
println!("{}", post.title());
}
}