Redditor

class praw.models.Redditor(reddit, name=None, _data=None)

A class representing the users of reddit.

__init__(reddit, name=None, _data=None)

Initialize a Redditor instance.

Parameters:
  • reddit – An instance of Reddit.
  • name – The name of the redditor.
block()

Block the Redditor.

comments

Provide an instance of SubListing for comment access.

For example, to output the first line of all new comments by /u/spez try:

for comment in reddit.redditor('spez').comments.new(limit=None):
    print(comment.body.split('\n', 1)[0][:79])
controversial(time_filter=’all’, **generator_kwargs)

Return a ListingGenerator for controversial submissions.

Parameters:time_filter – Can be one of: all, day, hour, month, week, year (default: all).

Raise ValueError if time_filter is invalid.

Additional keyword arguments are passed in the initialization of ListingGenerator.

This method can be used like:

reddit.domain('imgur.com').controversial('week')
reddit.multireddit('samuraisam', 'programming').controversial('day')
reddit.redditor('spez').controversial('month')
reddit.redditor('spez').comments.controversial('year')
reddit.redditor('spez').submissions.controversial('all')
reddit.subreddit('all').controversial('hour')
downvoted(**generator_kwargs)

Return a ListingGenerator for items the user has downvoted.

May raise prawcore.Forbidden after issuing the request if the user is not authorized to access the list. Note that because this function returns a ListingGenerator the exception may not occur until sometime after this function has returned.

Additional keyword arguments are passed in the initialization of ListingGenerator.

friend(note=None)

Friend the Redditor.

Parameters:note – A note to save along with the relationship. Requires reddit Gold (default: None).

Calling this method subsequent times will update the note.

friend_info()

Return a Redditor instance with specific friend-related attributes.

Returns:A Redditor instance with fields date, id, and possibly note if the authenticated user has reddit Gold.
classmethod from_data(reddit, data)

Return an instance of Redditor, or None from data.

fullname

Return the object’s fullname.

A fullname is an object’s kind mapping like t3 followed by an underscore and the object’s base36 ID, e.g., t1_c5s96e0.

gild(months=1)

Gild the Redditor.

Parameters:months – Specifies the number of months to gild up to 36 (default: 1).
gilded(**generator_kwargs)

Return a ListingGenerator for gilded items.

Additional keyword arguments are passed in the initialization of ListingGenerator.

gildings(**generator_kwargs)

Return a ListingGenerator for items the user has gilded.

May raise prawcore.Forbidden after issuing the request if the user is not authorized to access the list. Note that because this function returns a ListingGenerator the exception may not occur until sometime after this function has returned.

Additional keyword arguments are passed in the initialization of ListingGenerator.

hidden(**generator_kwargs)

Return a ListingGenerator for items the user has hidden.

May raise prawcore.Forbidden after issuing the request if the user is not authorized to access the list. Note that because this function returns a ListingGenerator the exception may not occur until sometime after this function has returned.

Additional keyword arguments are passed in the initialization of ListingGenerator.

hot(**generator_kwargs)

Return a ListingGenerator for hot items.

Additional keyword arguments are passed in the initialization of ListingGenerator.

This method can be used like:

reddit.domain('imgur.com').hot()
reddit.multireddit('samuraisam', 'programming').hot()
reddit.redditor('spez').hot()
reddit.redditor('spez').comments.hot()
reddit.redditor('spez').submissions.hot()
reddit.subreddit('all').hot()
message(subject, message, from_subreddit=None)

Send a message to a redditor or a subreddit’s moderators (mod mail).

Parameters:
  • subject – The subject of the message.
  • message – The message content.
  • from_subreddit – A Subreddit instance or string to send the message from. When provided, messages are sent from the subreddit rather than from the authenticated user. Note that the authenticated user must be a moderator of the subreddit and have mail permissions.

For example, to send a private message to /u/spez, try:

reddit.redditor('spez').message('TEST', 'test message from PRAW')

To send a message to u/spez from the moderators of r/test try:

reddit.redditor('spez').message('TEST', 'test message from r/test',
                                from_subreddit='test')

To send a message to the moderators of /r/test, try:

reddit.subreddit('test').message('TEST', 'test PM from PRAW')
multireddits()

Return a list of the redditor’s public multireddits.

new(**generator_kwargs)

Return a ListingGenerator for new items.

Additional keyword arguments are passed in the initialization of ListingGenerator.

This method can be used like:

reddit.domain('imgur.com').new()
reddit.multireddit('samuraisam', 'programming').new()
reddit.redditor('spez').new()
reddit.redditor('spez').comments.new()
reddit.redditor('spez').submissions.new()
reddit.subreddit('all').new()
parse(data, reddit)

Return an instance of cls from data.

Parameters:
  • data – The structured data.
  • reddit – An instance of Reddit.
saved(**generator_kwargs)

Return a ListingGenerator for items the user has saved.

May raise prawcore.Forbidden after issuing the request if the user is not authorized to access the list. Note that because this function returns a ListingGenerator the exception may not occur until sometime after this function has returned.

Additional keyword arguments are passed in the initialization of ListingGenerator.

stream

Provide an instance of RedditorStream.

Streams can be used to indefinitely retrieve new comments made by a redditor, like:

for comment in reddit.redditor('spez').stream.comments():
    print(comment)

Additionally, new submissions can be retrieved via the stream. In the following example all submissions are fetched via the redditor spez:

for submission in reddit.redditor('spez').stream.submissions():
    print(submission)
submissions

Provide an instance of SubListing for submission access.

For example, to output the title’s of top 100 of all time submissions for /u/spez try:

for submission in reddit.redditor('spez').submissions.top('all'):
    print(submission.title)
top(time_filter=’all’, **generator_kwargs)

Return a ListingGenerator for top submissions.

Parameters:time_filter – Can be one of: all, day, hour, month, week, year (default: all).

Raise ValueError if time_filter is invalid.

Additional keyword arguments are passed in the initialization of ListingGenerator.

This method can be used like:

reddit.domain('imgur.com').top('week')
reddit.multireddit('samuraisam', 'programming').top('day')
reddit.redditor('spez').top('month')
reddit.redditor('spez').comments.top('year')
reddit.redditor('spez').submissions.top('all')
reddit.subreddit('all').top('hour')
unblock()

Unblock the Redditor.

unfriend()

Unfriend the Redditor.

upvoted(**generator_kwargs)

Return a ListingGenerator for items the user has upvoted.

May raise prawcore.Forbidden after issuing the request if the user is not authorized to access the list. Note that because this function returns a ListingGenerator the exception may not occur until sometime after this function has returned.

Additional keyword arguments are passed in the initialization of ListingGenerator.