Announcing the first stable release of Reddit.NET!

Previous Thread

Latest Changes

  • Library now throws custom exceptions for ‘already submitted’ and ‘too long’ responses.

  • Automatic retry when API returns Service Unavailable response.

  • Due to popular demand, I created an OAuth Token Retriever utility you’ll want to check out if you’re looking for a quick and easy way to generate refresh tokens for your Reddit apps. See: https://www.youtube.com/watch?v=xlWhLyVgN2s

  • Made Things.User.PrefTopKarmaSubreddits nullable

  • Added limited support for custom monitoring delays

  • Various documentation updates

Introducing Reddit.NET

Reddit.NET is a .NET Standard library that provides easy access to the Reddit API with virtually no boilerplate code required. This library, written in C#, is FOSS (free and open source) with a standard MIT license.

Reddit.NET is a fully-featured managed library that works in any language/framework the supports .NET Standard.

Features include:

  • All common Reddit actions (accessing content, creating posts/comments/messages, changing settings, etc)

  • Asynchronous monitoring for new posts/comments/messages/etc

  • Support for both synchronous and asynchronous workflows

  • Custom exception types for when the API returns a non-success response

  • All API JSON returns are deserialized directly into custom types, eliminating the need to manually parse through JObjects

  • All endpoint methods support named parameters

Additionally, if you pull the solution from Github, you’ll be able to use the AuthTokenRetriever app contained within to quickly and easily generate Reddit OAuth tokens for your app.

Usage

Reddit.NET can be installed via NuGet. You can find it at: https://www.nuget.org/packages/Reddit

To install via the Visual Studio NuGet Package Manager Console (in VS 2017, you’ll find it under Tools->NuGet Package Manager->NuGet Package Manager Console):

PM> Install-Package Reddit 

To create a new API instance bound to a specific user’s refresh token in an installed app:

using Reddit; ... var reddit = new RedditAPI("YourRedditAppID", "YourBotUserRefreshToken"); 

If you’re using a “script”-type app instead, you’ll also need to pass your app secret:

using Reddit; ... // You can also pass them as named parameters. var reddit = new RedditAPI(appId: "YourRedditAppID", appSecret: "YourRedditAppSecret", refreshToken: "YourBotUserRefreshToken"); 

Please see the project README for more detailed usage instructions and code examples.

Reddit.NET on NuGet

Reddit.NET on Github

Please feel free to contact me if you have any questions/etc. Thanks!

submitted by /u/KrisCraig
[link] [comments]

Leave a Reply