reddit 0.4.0

  • Installing
  • Versions
  • 44


A Reddit library for Dart, inspired by reddit.js (API) and raw.js (Auth).


See the Dart documentation.


Add the following to your pubspec.yaml:

  reddit: any

Creating a client

The top class Reddit takes a Client as parameter. This client can be constructed using thehttp package.

// in Dart VM
Reddit reddit = new Reddit(new Client());
// in browser
Reddit reddit = new Reddit(new BrowserClient());


To enable OAuth, you will need an app identifier and a secret. Get them here.

OAuth is required for some of the public endpoints (those marked OAuth-only) and will be required for all endpoints starting August 3, 2015 (see this announcement).

There are two options: App-only and User authorization.

  • App-only auth
reddit.authSetup(identifier, secret);
// with user info
await reddit.authFinish(username: "sroose", password: "correct horse battery staple");
// or without
await reddit.authFinish();

Note that not providing (developer) user info will result in getting 503 Service Unavailable responses after a while.

  • User-enabled auth
reddit.authSetup(identifier, secret);
Uri authUrl = reddit.authUrl("");
// redirect user to authUrl and gather the response from the auth server
await reddit.authFinish(response: authServerResponse);
// or if you already extracted the auth code from the response
await reddit.authFinish(code: authCode);

Queries, filters and listings

Most methods in the API construct a Query, which can be fetched to get a future with the results.

Most queries allow filtering. For the supported filters, we refer to the Reddit API docs or the documentation for this library.

// without filters
// filtered;

A lot of queries also are listings. Listings allow for browsing through content across multiple queries.

// using the regular fetch() method (not recommended)
reddit.sub("dartlang").top("day").fetch().then((result) {
  if (notEnough) {
    result.fetchMore().then((result) {
      if (stillNotEnough) {

// or using the dart:async API
reddit.sub("dartlang").top("month").listen((result) {
  if (notEnough) {

Browsing Reddit

You can use the standard read-only API to browse Reddit.

// the front page;
// or subreddits

Some examples using filters:



Fetching comments for a link:


Or a single comment:


Search through reddit:

reddit.sub("dartlang").search("reddit api").limit(5).sort("hot").fetch().then(print);


Find subreddits:



reddit.recommendedSubreddits(["dartlang", "reddit"]).fetch().then(print);


Get information about a subreddit:



Get information about a user:


Get listings from users:



Get a list of multi's from a user:



0.4.0 (2017-01-22)

  • Fix to restrict results to the subreddit

0.3.3 (2015-12-18)

  • Upgraded dependencies to latest versions
  • Adapted to breaking changes in oauth2 v1.0.0
  • Added better support for multireddits

0.3.2 (2015-04-03)

  • Updated RedditUri with official regex and extra test
  • Updated README
  • Constant constructor for Fullname
  • Improved exception handling in Query

0.3.1 (2015-04-02)

  • Added FullnameType enum
  • Added and Fullname.type getters
  • Bugfix in FilterableQuery.filter

0.3.0 (2015-04-01)

  • Added full OAuth2 support (app-only and user)
  • Changed auth interface
  • Expose RedditUri and Fullname classes

0.2.0 (2015-04-01)

  • Added App-only OAuth support, inspired by raw.js

0.1.0 (2015-03-31)

  • Initial version, inspired by reddit.js

1. Depend on it

Add this to your package's pubspec.yaml file:

  reddit: "^0.4.0"

2. Install it

You can install packages from the command line:

with pub:

$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:reddit/reddit.dart';
Version Uploaded Documentation Archive
0.4.0 Jan 22, 2017 Go to the documentation of reddit 0.4.0 Download reddit 0.4.0 archive
0.3.3 Dec 18, 2015 Go to the documentation of reddit 0.3.3 Download reddit 0.3.3 archive
0.3.2 May 14, 2015 Go to the documentation of reddit 0.3.2 Download reddit 0.3.2 archive
0.3.1 Apr 1, 2015 Go to the documentation of reddit 0.3.1 Download reddit 0.3.1 archive
0.3.0 Apr 1, 2015 Go to the documentation of reddit 0.3.0 Download reddit 0.3.0 archive
0.2.0 Apr 1, 2015 Go to the documentation of reddit 0.2.0 Download reddit 0.2.0 archive
0.1.0+1 Mar 31, 2015 Go to the documentation of reddit 0.1.0+1 Download reddit 0.1.0+1 archive
0.1.0 Mar 31, 2015 Go to the documentation of reddit 0.1.0 Download reddit 0.1.0 archive


This feature is new.
We welcome feedback.
More details: scoring.

We analyzed this package, and provided a score, details, and suggestions below.

  • tool failures on Feb 16, 2018
  • Dart: 2.0.0-dev.20.0
  • pana: 0.10.1


Describes how popular the package is relative to other packages. [more]
0 / 100
Code health derived from static analysis. [more]
90 / 100
Reflects how tidy and up-to-date the package is. [more]
84 / 100
Overall score:
Weighted score of the above. [more]


Detected platforms: web, other

Primary library: package:reddit/reddit.dart with components: mirrors.


  • Fix lib/src/listings.dart.

    Strong-mode analysis of lib/src/listings.dart failed with the following error:

    line: 9 col: 30
    Undefined name 'name'.

  • Fix lib/src/reddit.dart.

    Strong-mode analysis of lib/src/reddit.dart failed with the following error:

    line: 147 col: 65
    5 required argument(s) expected, but 4 found.

  • Fix issues reported by dartanalyzer.

    dartanalyzer reported 2 error(s) and 0 warning(s).

  • The description is too short.

    Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.

  • Maintain an example.

    Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use reddit.dart.


Package Constraint Resolved Available
Direct dependencies
http >=0.11.1+3 <0.12.0 0.11.3+16
json_object >=1.0.19 <2.0.0 1.0.19+1
logging >=0.11.0 <0.12.0 0.11.3+1
oauth2 >=1.0.1 <2.0.0 1.1.0
Transitive dependencies
async 2.0.3 2.0.4
charcode 1.1.1
collection 1.14.5
http_parser 3.1.1
path 1.5.1
source_span 1.4.0
string_scanner 1.0.2
typed_data 1.1.5
Dev dependencies
unittest any