Giter VIP home page Giter VIP logo

jreddit's Introduction

jReddit

Build Status Maven Central Coverage Status

What is jReddit?

jReddit is a wrapper for the Reddit API written in Java. Project started by Omer Elnour. Taken over for further development and maintenance by Karan Goel, Andrei Sfat, and Simon Kassing.

How to use jReddit?

We are currently in the transitional phase between cookie-based authentication and OAuth2. The previous version of jReddit (1.0.3), which uses the former, will no longer be supported by reddit beginning August. The latter is supported by the latest version of jReddit (1.0.4).

Latest version: 1.0.4

The latest version (1.0.4) can only be included by forking or directly copying source. When the build is stable, we will distribute it via Maven (as done with previous versions).

Old version (deprecated): 1.0.3

At the moment, jReddit 1.0.3 can be included in your project using:

Maven
<dependency>
        <groupId>com.github.jreddit</groupId>
        <artifactId>jreddit</artifactId>
        <version>1.0.3</version>
</dependency>
Gradle
dependencies {
    compile group: 'com.github.jreddit', name: 'jreddit', version: '1.0.3'
}

What can it do?

jReddit supports the creation of clients and bots using the Java language. It communicates using the reddit api, and all its actions are limited by the functionality offered there. It can for example authenticate apps using OAuth2, retrieve subreddits, submissions and comments, and perform various actions such as flairing, hiding and saving.

Examples

Examples can be found in Examples package. A full example Gradle (Android) project can be found in the Gradle example folder. To give you an impression, here is a code snippet for a simple example:

Connect a user

// Information about the app
String userAgent = "jReddit: Reddit API Wrapper for Java";
String clientID = "JKJF3592jUIisfjNbZQ";
String redirectURI = "https://www.example.com/auth";

// Reddit application
RedditApp redditApp = new RedditInstalledApp(clientID, redirectURI);
RedditOAuthAgent agent = new RedditOAuthAgent(userAgent, redditApp);    
RedditClient client = new RedditHttpClient(userAgent, HttpClientBuilder.create().build());

// Create a application-only token (will be valid for 1 hour)
RedditToken token = agent.tokenAppOnly(false);

// Create parser for request
SubmissionsListingParser parser = new SubmissionsListingParser();

// Create the request
SubmissionsOfSubredditRequest request = (SubmissionsOfSubredditRequest) new SubmissionsOfSubredditRequest("programming", SubmissionSort.HOT).setLimit(100);

// Perform and parse request, and store parsed result
List<Submission> submissions = parser.parse(client.get(token, request));

// Now print out the result (don't care about formatting)
System.out.println(submissions);

Note: please see the reddit OAuth2 information page for more information on acquiring a client identifier, secret, and redirect URI.

What's next for jReddit?

The plan is to implement every feature documented here. To see which methods have been implemented, and which have not, see this file.

How to contribute?

It is recommend to start with forking and reading through the source code, in oder to understand the general structure and standards used. Then check the implemented_methods.md file to see which methods have not yet been implemented. Choose the ones you'd like to contribute to. When you implement a new request, make sure it is fully covered by testing (via JUnit), and that all other tests pass as well. Thorough documentation of your addition is appreciated.

Send in a pull request, including test, and it will be gladly merged to improve the library! :-)

Dependencies

  1. JSON-simple

  2. Apache HttpComponents

  3. SLF4J

  4. Apache OLTU

jreddit's People

Contributors

aliakhtar avatar anseriform avatar arocketman avatar beresfordt avatar c-ameron avatar corgibyte avatar dincciftci avatar eduardog3000 avatar evinugur avatar flightofstairs avatar hainna01 avatar immatt avatar jamesgold23 avatar jasonsimpson avatar jonnykry avatar mattbdean avatar mleef avatar mrcorporate avatar mtt88 avatar naduse avatar player1537 avatar raulrene avatar rvanbaarle avatar sfat avatar snkas avatar sudocurse avatar trentrand avatar vafada avatar vitineth avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.