Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including reddit with all npm packages installed. Try it out:

var reddit = require("reddit")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

reddit v1.0.3

Simple Reddit API client

reddit travis npm downloads

Simple Reddit API client


npm install reddit

This package is used by BitMidi to post MIDI files to the /r/BitMidi subreddit.


  • Lightweight – no unecessary dependencies, easy-to-audit source code
  • Modern API – uses async/await and promises
  • Powered by the official Reddit API


First, create a Reddit App.

  • Click "Create app"
  • For simple scripts, you can select a type of "script".
  • You can enter anything in the "about URL" and "redirect URL" fields.
  • Note your app ID (appears below the app name) and your app secret.

Now, let's take an action on Reddit:

const Reddit = require('reddit')

const reddit = new Reddit({
  username: 'TODO',
  password: 'TODO',
  appId: 'TODO',
  appSecret: 'TODO',
  userAgent: 'MyApp/1.0.0 ('

// Submit a link to the /r/BitMidi subreddit
const res = await'/api/submit', {
  sr: 'WeAreTheMusicMakers',
  kind: 'link',
  resubmit: true,
  title: 'BitMidi – 100K+ Free MIDI files',
  url: ''

// Prints:
// {
//   json: {
//     errors: [],
//     data: {
//       url: '',
//       drafts_count: 0,
//       id: '96ak55',
//       name: 't3_96ak55'
//     }
//   }
// }


reddit = new Reddit(opts)

Create a new Reddit API client.

You must provide opts, an object with the following required properties:

  • username - Username of the reddit user
  • password - Password of the reddit user
  • appId - Reddit App ID
  • appSecret - Reddit App Secret

The following opts properties are optional:

  • opts.userAgent - String to use as the User-Agent header in http requests

reddit.get(url, data)

Invoke the Reddit API using the GET HTTP method.

The url parameter is used to specify which API to invoke. For example, /api/submit or /api/vote. A complete listing of possible APIs is available in the Reddit API documentation.

The data parameter is used to specify relevant data for the selected API. The necessary data varies depending on which API is being used. Again, see the Reddit API documentation., data)

Invoke the Reddit API using the POST HTTP method.

reddit.patch(url, data)

Invoke the Reddit API using the PATCH HTTP method.

reddit.put(url, data)

Invoke the Reddit API using the PUT HTTP method.

reddit.delete(url, data)

Invoke the Reddit API using the DELETE HTTP method.


The Prosperity Public License. Copyright (c) Feross Aboukhadijeh.

To obtain a commercial license, visit


RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free