NodeJS wrapper for the Reddit API.
CoffeeScript JavaScript
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
api
src
.gitignore First OAuth API stuff, needs more testing. Mar 19, 2013
Gruntfile.coffee
README.md
index.js
package.json Bump Mar 8, 2013

README.md

Welcome!

This is a project to wrap and make the Reddit API easily accessible to your node.js applications.

See the Reddit API documentation for details on what to do.

Please note, this is not finished. I will be developing it as I go. I am working on my own projects to leverage the reddit API, so I started the effort. Pull requests are very welcome!

Example

Please don't mind the coffeescript example for the time being. Again, this is a work in prorgess. :)

You would launch this like: user=foo password=bar coffee test.coffee

Immediate mode (default):

Reddit = require 'reddit-api'

reddit = new Reddit 'cutebot v0.1 by /u/YOUR_REDDIT_USERNAME_HERE'

# Enable logging.
reddit.setIsLogging true

# Login operation.  
{user, password} = process.env
reddit.login user, password, (error) ->

    throw error if error?

	# Check the user's inbox.
	reddit.messages (error, messages) ->
		
		throw error if error?
		
		console.log messages

Deferred (burst) mode:

Reddit = require 'reddit-api'

reddit = new Reddit 'cutebot v0.1 by /u/YOUR_REDDIT_USERNAME_HERE'

# Enable logging.
reddit.setIsLogging true

# Login operation.  
{user, password} = process.env
reddit.login user, password, (error) ->

    throw error if error?

	# Deferred dispatching.
	reddit.setDispatchMode 'deferred'
	
	# Check the user's inbox.
	reddit.messages (error, messages) ->
		
		throw error if error?
		
		console.log messages

	console.log 'Chilling for 2 seconds before the burst!'
	setTimeout(
		-> reddit.burst()
		2000
	)

Rate-limited mode:

Reddit = require 'reddit-api'

reddit = new Reddit 'cutebot v0.1 by /u/YOUR_REDDIT_USERNAME_HERE'

# Enable logging.
reddit.setIsLogging true

# Rate-limited dispatching.
reddit.setDispatchMode 'limited'

# Login operation.  
{user, password} = process.env
reddit.login user, password, (error) ->

    throw error if error?

# Check the user's inbox.
reddit.messages (error, messages) ->
	
	throw error if error?
	
	console.log messages

# Notification when all queued operations are complete.
reddit.on 'drain', ->

    # Shut it down.
    reddit.setDispatchMode 'immediate'

TODO

  • Obviously, implement more of the API including OAuth