Reddit api

A python wrapper for the Reddit API.

View the Project on GitHub mellort/reddit_api

Quick Intro

This is a Python wrapper for Reddit's API, aiming to be as easy to use as possible. Here's a quick peek, getting the first 10 submissions from the 'hot' section of the 'opensource' subreddit.

import reddit
r = reddit.Reddit(user_agent='my_cool_application')
submissions = r.get_subreddit('opensource').get_hot(limit=5)
[str(x) for x in submissions]

this will display something similar to the following:

['10 :: Debuts Group Funding for Open Source Projects\n',
 '24 :: Support the Free Software Foundation',
 '67 :: The 10 Most Important Open Source Projects of 2011',
  '2 :: Open-source webOS is dead on arrival ',
 '85 :: Plan 9 - A distributed OS with a unified communication protocol and I/O driver model.  Wow.']


The preferred way to install is via pip

pip install reddit

For the most up to date code, you can install via from a checkout of this repo

python install

A Few Short Examples

  1. Building the Reddit object (requires a user agent):

    r = reddit.Reddit(user_agent='example')
  2. Logging in:

    r.login('username', 'password')
  3. Send a message (requires login):

    r.compose_message('bboe', 'Subject Line', 'You are awesome!')
  4. Get the top submissions for r/python:

    submissions = r.get_subreddit('python').get_top(limit=10)
  5. Get comments from a given submission:

    submission =
  6. Comment on a submission (requires login):

  7. Voting (requires login):

    # item can be a comment or submission

For a more extensive set of examples, see the wiki.