The Java Reddit API Wrapper
All versions after v1.0.0 will try to minimize breaking changes until the next major release (v2.0.0). However, there are some cases in which breaking changes are required between minor versions.
RedditClient.subreddits()
returns a SubredditReference instead of a DefaultPaginator (#211)Submission.getThumbnail()
is now nullable (#241)for (c in redditClient.subreddit("RocketLeague").comments().build().stream()) {
// Do something with the newly-created comment
}
RedditClient.searchSubreddits()
(#212)RedditClient.searchSubredditsByName()
(#244)SubredditSort.BEST
(see here)SubredditReference.patchFlairList()
(767ff28
)SubmissionReference.flagAsSpoiler
and SubmissionReference.stickPost
(#235, thanks to @canaangifford!)switchToUserless()
(#210)StatefulAuthHelper.onUserChallenge
sometimes throwing a NPE (#231)Subreddit.getNsfw()
no longer always returns null (#239)Comment.getAuthorFlairText()
now works properly (#250)UserReference.about()
is deprecated in favor of UserReference.query()
for better handling of suspended/non-existent accountsBefore:
Account account;
try {
account = reddit.user("some username").about();
} catch (NullPointerException e) {
// suspended site-wide
} catch (ApiException e) {
// probably doesn't exist
}
After:
AccountQuery query = reddit.user("some username").query();
switch (query.getStatus()) {
case EXISTS:
Account account = query.getAccount();
// do something
case NON_EXISTENT:
// do something
case SUSPENDED:
// do something
}
Dependency | Before | After |
---|---|---|
Kotlin | 1.2.10 | 1.2.41 |
OkHttp | 3.9.1 | 3.10.0 |
Moshi | 1.5.0 | 1.6.0 |
AutoValue | 1.5.3 | 1.5.4 |
v1.0.0 is a total rewrite of the library in Kotlin. This is pretty much a brand new library, so I'd recommend checking out the documentation.
redditClient.subreddit("pics").subscribe();
RedditClient reddit = OAuthHelper.automatic(networkAdapter, credentials);
Thank you to all who contributed to this release! JRAW v0.9.0 contains several breaking changes as well as many bug fixes and enhancements.
net.dean.jraw.util
net.dean.jraw.managers.CaptchaHelper
getCreatedUtc()
methods have been removed. getCreated()
now returns UTC dates and functions the same way as getCreatedUtc()
AccountManager.updateSelfpost
renamed to updateContribution
, now takes a PublicContribution rather than a Submission
to allow for comment editingInboxManager.setRead()
now supports multiple messages to mark as read.RedditClient.getPreferences()
now accepts a List instead of varargsHttpLogger.Component.RESPONSE_BODY_ALWAYS_FULL
is now implemented as a property (setResponseBodyAlwaysFull()
)getSuggestedSort()
, isLocked()
, and getThumbnails()
to SubmissionaccumulateMergedAll()
methods for easily gathering a list of all of a user's subreddits (thanks to @worker8)Sorting.GILDED
RedditClient.getTrophies()
(thanks to @rubenmayayo)Submission.getThumbnailType()
now properly handles a null thumbnail (thanks to @zglazer)RedditClient.getSubreddit()
now throws an IllegalArgumentException when the subreddit is not viewable instead of failing later when trying to access JSON datanet.dean.jraw.auth
package. Helps manage OAuth2 flow, especially on mobile apps. See the updated OAuth2 wiki page for more.SubredditStream
now handles calls to /subreddits/default
Endpoints.USER_USERNAME_LIKED
renamed to USER_USERNAME_UPVOTED
. Likewise for USER_USERNAME_DISLIKED
.PublicContribution.getRemovalReason()
Submission.getPostHint()
OkHttpAdapter
now accepts an OkHttpClient
as a parameter in its constructorAccountPreferences
and AccountPreferencesEditor
AccountManager.save()
accepts a PublicContribution
instead of a Submission
OAuthData.getScopes()
was not returning the expected result.hashCode
and equals
methods to Thing
OAuthHelper
removed its own refresh token after the first refreshWhat's new in this release:
LiveThreadManager
class provides CRUD operations on live threads.TimePeriod.WEEK
constantThis is not a comprehensive change set. Changes from v0.7.0.x were not included.
NB: This is a time-based release. It is not to be considered stable but is provided for those who want the latest and greatest features of the library.
RedditClient.setRetryLimit()
.Credentials.installedApp()
and Credentials.webapp()
(#51)AccountPreferencesEditor
(see here for a full list)EmbeddedMedia
has been removed, as its only purpose was to feed the website data. API consumers should use oEmbed (Submission.getOEmbedMedia()
) instead.AllSubredditsPaginator
has been renamed to SubredditStream
CommentStream
CommentNode
now bears the responsibility of loading a Comment's children. Consequently, Comment.getReplies()
has been replaced by CommentNode.getChildren()
CommentNode.loadFully()
can fully expand a comment treeCommentNode
now implements Iterable
to iterate over direct childrenJrawUtils.isFullname()
now allows the ID to be alphanumericHttpLogger
now always logs at the correct levelNB: This is a time-based release. It is not to be considered stable but is provided for those who want the latest and greatest features of the library.
Main features in this release:
OAuthHelper.setRefreshToken()
InvalidScopeException
that is thrown when the client does not use the required scopeOAuthHelper.revokeAccessToken()
and revokeRefreshToken()
respectivelyMultiReddit
has changed accordingly. See here fore more.MultiRedditManager.getPublicMultis(String)
RedditClient.isLoggedIn()
renamed to isAuthenticated()
LoggedInAccount.getCreddits()
InboxPaginator
models
package cleaned up a great bit.NB: This is a time-based release. It is not to be considered stable but is provided for those who want the latest and greatest features of the library.
Main features in this release:
RedditOAuth2Client
has been merged with RedditClient
Submission.getComments()
now returns a CommentNode
, which provides the ability to easily traverse the comment tree.NetworkException
is now a RuntimeException
, meaning you no longer have to catch it if you don't want to.UserAgent
class, assists with standardizing the User-Agent
headerMore
was renamed to MoreChildren
AbstractManager
and Paginator
did not need to implement NetworkAccessible
, so they do not now.RedditClient.SubmissionRequest
is now its own class (net.dean.jraw.http.SubmissionRequest
) and properly implements the builder patternPaginators
class was removed since there is no reason to have factory methods for classes that have simple, public constructorsAlso, make sure to check out the new wiki pages on OAuth2 and getting started.
Main changes in this release:
ec88e60
for more.JrawUtils
methods renamed. See commit 0ce88cd
for more.Votable
's getUpvotes()
and getDownvotes()
. See commit 0c81a0e
Minor patch release