JRAW
The Java Reddit API Wrapper
Install / Use
/learn @mattbdean/JRAWREADME
repositories {
jcenter()
}
dependencies {
implementation "net.dean.jraw:JRAW:$jrawVersion"
}
Documentation
The full documentation is available on GitBooks, but here's a sneak peek:
// Assuming we have a 'script' reddit app
Credentials oauthCreds = Credentials.script(username, password, clientId, clientSecret);
// Create a unique User-Agent for our bot
UserAgent userAgent = new UserAgent("bot", "my.cool.bot", "1.0.0", "myRedditUsername");
// Authenticate our client
RedditClient reddit = OAuthHelper.automatic(new OkHttpNetworkAdapter(userAgent), oauthCreds);
// Get info about the user
Account me = reddit.me().about();
Javadoc
JRAW uses JitPack to host its Javadoc.
https://jitpack.io/com/github/mattbdean/JRAW/VERSION/javadoc/index.html
VERSION can be a specific commit hash (like d6843bf), a tag (like v1.0.0), or the HEAD of a branch (like master-SNAPSHOT).
JitPack produces Javadoc only when necessary, so the first time someone accesses the Javadoc for a specific build it may take a little bit.
Android
JRAW doesn't target Android specifically, but there is an extension library that solves some quality of life issues. Also be sure to check out the example app that shows how to get users logged in.
Contributing
To get started you'll need to create two reddit OAuth2 apps, one script and one installed, and then create a subreddit.
To have this done automatically for you, run this command:
$ ./gradlew :meta:credentials --no-daemon --console plain
Your testing account should have at least 100 karma, otherwise you'll run into issues when trying to create a subreddit.
lib/src/test/resources/credentials.json:
{
"script": {
"username": "...",
"password": "...",
"clientId": "...",
"clientSecret": "..."
},
"app": {
"clientId": "...",
"redirectUrl": "..."
},
"moderationSubreddit": "..."
}
Then you can go ahead and run the tests
$ ./gradlew test
Tests are written with Spek and assertions are done with Expekt.
In order to get the integration tests of the docs module to pass, you'll need gitbook-cli installed globally. You shouldn't have to worry about this, as most of the contributions are likely to be towards the core library and not its accessory modules.
Code Style
Kotlin code follows the official conventions provided by JetBrains (with a few exceptions).
A few hard and fast rules:
- UTF-8 everywhere
- 4 spaces for indentation
- 120 line length
Releasing
Define these variables in gradle.properties:
# Go to gitbook.com -> Account Settings -> Applications/Tokens to get an API key
gitbookUsername=<gitbook username>
gitbookPassword=<gitbook API key or password>
# Go to bintray.com -> Edit Profile -> API Key to get your account's API key
bintrayUser=<bintray username>
bintrayKey=<bintray API key>
# If this property doesn't match the target release, all release-related tasks
# will be disabled
authorizeRelease=<version to release>
Update the version in the root build.gradle and then run the :lib:release task to perform a release.
$ ./gradlew release --no-daemon --console plain
This task will:
- Clean everything and run
:lib's tests - Run
:meta:update(see here for what this does) - Creates a commit for the version. This commit must be pushed manually later.
- Updates the GitBook site and creates a new tag in the Git repo.
- Uploads artifacts (sources, Javadoc, and compiled) to Bintray
After running the task:
- Push the newly-created commit
- Create a GitHub release targeting that commit. Attach all jars generated in
lib/build/libs. - Publish the uploaded jars on Bintray
Related Skills
gh-issues
340.2kFetch GitHub issues, spawn sub-agents to implement fixes and open PRs, then monitor and address PR review comments. Usage: /gh-issues [owner/repo] [--label bug] [--limit 5] [--milestone v1.0] [--assignee @me] [--fork user/repo] [--watch] [--interval 5] [--reviews-only] [--cron] [--dry-run] [--model glm-5] [--notify-channel -1002381931352]
node-connect
340.2kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
oracle
340.2kBest practices for using the oracle CLI (prompt + file bundling, engines, sessions, and file attachment patterns).
tmux
340.2kRemote-control tmux sessions for interactive CLIs by sending keystrokes and scraping pane output.
