/JRAW

Java Reddit API Wrapper

Primary LanguageJavaMIT LicenseMIT

#Java Reddit API Wrapper

travis-ci build status Coverage Status Reddit API coverage

JRAW is currently in an experimental stage, and therefore subject to application-breaking API changes that could occur at any time before v1.0.

##Notable Features

  • Java 7 compatible
  • Mini HTTP framework that wraps OkHttp
  • Basic site actions (login, vote, submit, comment, read inbox, etc.)
  • Full multireddit support
  • Full captcha support
  • Get trending subreddits
  • Get random posts and subreddits
  • Incubating OAuth2 usage

##Getting Started ####Adding the Dependency

JRAW is hosted on Bintray's jCenter.

Gradle:

repositories {
    jcenter()
}

dependencies {
    compile 'net.dean.jraw:JRAW:0.6.1'
}

Maven:

Add jCenter to your repositories (see here and press "Set me up!" on the right hand side) and then add the repository:

<dependency>
    <groupId>net.dean.jraw</groupId>
    <artifactId>JRAW</artifactId>
    <version>0.6.1</version>
</dependency>

####Using the Library See the wiki to get you up and running

Javadoc can be found here

##Building

JRAW uses Gradle as its build system. If you're coming from a Maven background, you can read this StackOverflow question to help you get started.

./gradlew release will generate four Jar files in build/releases/: a normal jar with just the library, a "fat" jar with all of JRAW's runtime dependencies, a Javadoc jar, and a sources jar. See here for an example.

./gradlew test will run the unit tests

##Contributing

Before contributing, it is recommended that you have a decent knowledge of how the Reddit API works.

Some references:

####Want to contribute? Follow these steps:

  1. Fork the repository
  2. Put your testing user's credentials in /src/test/java/resources/credentials.json. It should be in this format
  3. Add your code. Implement an endpoint, make the code prettier, or even just fix up some whitespace or documentation.
  4. Write TestNG tests covering your changes
  5. Test your code by executing ./gradlew test
  6. Update ENDPOINTS.md and Endpoints.java by running ./gradlew endpoints:update
  7. Send the pull request

####Creating a user for unit testing

The :testingUser subproject is a script to help you get set up with JRAW. To run it, execute TERM=dumb ./gradlew testingUser:run. This script will:

  1. Register a new user
  2. Create an OAuth2 app
  3. Record the username, password, client ID, and client secret in credentials.json
  4. Create a subreddit
  5. Create a multireddit
  6. Submit a self post to /r/jraw_testing2