RsReddit is lightweight wrapper for the Reddit Web API. The goal is to cover some useful endpoints like browsing subreddits, creating posts, commenting on posts. For a complete reference, see the official documentation. As this is a toy project, not all endpoints are expected to be implemented
Implemented endpoints:
- Get sorted posts of subreddit or frontpage
- Top posts
- Hot posts
- Best posts
- Rising posts
- New posts
- Controversial posts
- Comment on thread
- Reply to comments
- Get Thread comment tree
OAuth2 specific implementations:
- Authorize Client with Reddit UI ( Installed APP type. See here )
- Refresh bearer token
- Revoke bearer token
Add to your Cargo.toml
:
[dependencies]
rsreddit = "0.1.3"
Or get it from GitHub.
Currently only Installed Apps are supported.
A script using this library has to register an installed app, or authorize an existing one.
To use an existing App, or set your own app, set the environment variable CLIENT_ID as the app's ID, and CLIENT_SECRET as base64 encoded CLIENT_ID.
You can also set these values in a .env
file, for example as shown here.
If you want to use your own installed app, create one over here. It is important to choose installed app. See the official documentation
- Reddit API endpoints
- Authorization Examples
See changelog for release history
Pull requests, code reviews, general feedback are welcome!