Redditor¶
-
class
praw.models.Redditor(reddit: Reddit, name: Optional[str] = None, fullname: Optional[str] = None, _data: Optional[Dict[str, Any]] = None)¶ A class representing the users of reddit.
Typical Attributes
This table describes attributes that typically belong to objects of this class. Since attributes are dynamically provided (see Determine Available Attributes of an Object), there is not a guarantee that these attributes will always be present, nor is this list necessarily complete.
Note
Shadowbanned accounts are treated the same as non-existent accounts, meaning that they will not have any attributes.
Note
Suspended/banned accounts will only return the
nameandis_suspendedattributes.Attribute
Description
comment_karmaThe comment karma for the Redditor.
commentsProvide an instance of
SubListingfor comment access.created_utcTime the account was created, represented in Unix Time.
has_verified_emailWhether or not the Redditor has verified their email.
icon_imgThe url of the Redditors’ avatar.
idThe ID of the Redditor.
is_employeeWhether or not the Redditor is a Reddit employee.
is_friendWhether or not the Redditor is friends with the authenticated user.
is_modWhether or not the Redditor mods any subreddits.
is_goldWhether or not the Redditor has active Reddit Premium status.
is_suspendedWhether or not the Redditor is currently suspended.
link_karmaThe link karma for the Redditor.
nameThe Redditor’s username.
subredditIf the Redditor has created a user-subreddit, provides a dictionary of additional attributes. See below.
subreddit["banner_img"]The URL of the user-subreddit banner.
subreddit["name"]The fullname of the user-subreddit.
subreddit["over_18"]Whether or not the user-subreddit is NSFW.
subreddit["public_description"]The public description of the user-subreddit.
subreddit["subscribers"]The number of users subscribed to the user-subreddit.
subreddit["title"]The title of the user-subreddit.
-
__init__(reddit: Reddit, name: Optional[str] = None, fullname: Optional[str] = None, _data: Optional[Dict[str, Any]] = None)¶ Initialize a Redditor instance.
- Parameters
reddit – An instance of
Reddit.name – The name of the redditor.
fullname – The fullname of the redditor, starting with
t2_.
Exactly one of
name,fullnameor_datamust be provided.
-
block()¶ Block the Redditor.
For example, to block Redditor
spez:reddit.redditor("spez").block()
-
comments()¶ Provide an instance of
SubListingfor comment access.For example, to output the first line of all new comments by
u/speztry:for comment in reddit.redditor("spez").comments.new(limit=None): print(comment.body.split("\n", 1)[0][:79])
-
controversial(time_filter: str = 'all', **generator_kwargs: Union[str, int, Dict[str, str]]) → Iterator[Any]¶ Return a
ListingGeneratorfor controversial submissions.- Parameters
time_filter – Can be one of: all, day, hour, month, week, year (default: all).
- Raises
ValueErroriftime_filteris 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: Union[str, int, Dict[str, str]]) → Iterator[Any]¶ Return a
ListingGeneratorfor items the user has downvoted.- Raises
prawcore.Forbiddenif the user is not authorized to access the list.Note
Since this function returns a
ListingGeneratorthe exception may not occur until sometime after this function has returned.
Additional keyword arguments are passed in the initialization of
ListingGenerator.For example, to get all downvoted items of the authenticated user:
for item in reddit.user.me().downvoted(): print(item.id)
-
friend(note: Optional[str] = None)¶ Friend the Redditor.
- Parameters
note – A note to save along with the relationship. Requires Reddit Premium (default: None).
Calling this method subsequent times will update the note.
For example, to friend Redditor
spez:reddit.redditor("spez").friend()
To add a note to the friendship (requires Reddit Premium):
reddit.redditor("spez").friend(note="My favorite admin")
-
friend_info() → praw.models.reddit.redditor.Redditor¶ Return a Redditor instance with specific friend-related attributes.
- Returns
A
Redditorinstance with fieldsdate,id, and possiblynoteif the authenticated user has Reddit Premium.
For example, to get the friendship information of Redditor
spez:info = reddit.redditor("spez").friend_info friend_data = info.date
-
classmethod
from_data(reddit, data)¶ Return an instance of Redditor, or None from
data.
-
property
fullname¶ Return the object’s fullname.
A fullname is an object’s kind mapping like
t3followed by an underscore and the object’s base36 ID, e.g.,t1_c5s96e0.
-
gild(months: int = 1)¶ Gild the Redditor.
- Parameters
months – Specifies the number of months to gild up to 36 (default: 1).
For example, to gild Redditor
spezfor 1 month:reddit.redditor("spez").gild(months=1)
-
gilded(**generator_kwargs: Union[str, int, Dict[str, str]]) → Iterator[Any]¶ Return a
ListingGeneratorfor gilded items.Additional keyword arguments are passed in the initialization of
ListingGenerator.For example, to get gilded items in subreddit
r/test:for item in reddit.subreddit("test").gilded(): print(item.id)
-
gildings(**generator_kwargs: Union[str, int, Dict[str, str]]) → Iterator[Any]¶ Return a
ListingGeneratorfor items the user has gilded.- Raises
prawcore.Forbiddenif the user is not authorized to access the list.Note
Since this function returns a
ListingGeneratorthe exception may not occur until sometime after this function has returned.
Additional keyword arguments are passed in the initialization of
ListingGenerator.For example, to get all gilded items of the authenticated user:
for item in reddit.user.me().gildings(): print(item.id)
Return a
ListingGeneratorfor items the user has hidden.- Raises
prawcore.Forbiddenif the user is not authorized to access the list.Note
Since this function returns a
ListingGeneratorthe exception may not occur until sometime after this function has returned.
Additional keyword arguments are passed in the initialization of
ListingGenerator.For example, to get all hidden items of the authenticated user:
for item in reddit.user.me().hidden(): print(item.id)
-
hot(**generator_kwargs: Union[str, int, Dict[str, str]]) → Iterator[Any]¶ Return a
ListingGeneratorfor 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: str, message: str, from_subreddit: Optional[Union[Subreddit, str]] = 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
Subredditinstance or string to send the message from. When provided, messages are sent from the subreddit rather than from the authenticated user.Note
The authenticated user must be a moderator of the subreddit and have the
mailmoderator permission.
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/spezfrom the moderators ofr/testtry: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")
-
moderated() → List[Subreddit]¶ Return a list of the redditor’s moderated subreddits.
- Returns
A
listofSubredditobjects. Return[]if the redditor has no moderated subreddits.
Note
The redditor’s own user profile subreddit will not be returned, but other user profile subreddits they moderate will be returned.
Usage:
for subreddit in reddit.redditor("spez").moderated(): print(subreddit.display_name) print(subreddit.title)
-
multireddits() → List[Multireddit]¶ Return a list of the redditor’s public multireddits.
For example, to to get Redditor
spez’s multireddits:multireddits = reddit.redditor("spez").multireddits()
-
new(**generator_kwargs: Union[str, int, Dict[str, str]]) → Iterator[Any]¶ Return a
ListingGeneratorfor 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()
-
classmethod
parse(data: Dict[str, Any], reddit: Reddit) → Any¶ Return an instance of
clsfromdata.- Parameters
data – The structured data.
reddit – An instance of
Reddit.
-
saved(**generator_kwargs: Union[str, int, Dict[str, str]]) → Iterator[Any]¶ Return a
ListingGeneratorfor items the user has saved.- Raises
prawcore.Forbiddenif the user is not authorized to access the list.Note
Since this function returns a
ListingGeneratorthe exception may not occur until sometime after this function has returned.
Additional keyword arguments are passed in the initialization of
ListingGenerator.For example, to get all saved items of the authenticated user:
for item in reddit.user.me().saved(limit=None): print(item.id)
-
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
SubListingfor submission access.For example, to output the title’s of top 100 of all time submissions for
u/speztry:for submission in reddit.redditor("spez").submissions.top("all"): print(submission.title)
-
top(time_filter: str = 'all', **generator_kwargs: Union[str, int, Dict[str, str]]) → Iterator[Any]¶ Return a
ListingGeneratorfor top submissions.- Parameters
time_filter – Can be one of: all, day, hour, month, week, year (default: all).
- Raises
ValueErroriftime_filteris 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")
-
trophies() → List[Trophy]¶ Return a list of the redditor’s trophies.
- Returns
A
listofTrophyobjects. Return an empty list ([]) if the redditor has no trophies.- Raises
RedditAPIExceptionif the redditor doesn’t exist.
Usage:
for trophy in reddit.redditor("spez").trophies(): print(trophy.name) print(trophy.description)
-
unblock()¶ Unblock the Redditor.
For example, to unblock Redditor
spez:reddit.redditor("spez").unblock()
-
unfriend()¶ Unfriend the Redditor.
For example, to unfriend Redditor
spez:reddit.redditor("spez").unfriend()
-
upvoted(**generator_kwargs: Union[str, int, Dict[str, str]]) → Iterator[Any]¶ Return a
ListingGeneratorfor items the user has upvoted.- Raises
prawcore.Forbiddenif the user is not authorized to access the list.Note
Since this function returns a
ListingGeneratorthe exception may not occur until sometime after this function has returned.
Additional keyword arguments are passed in the initialization of
ListingGenerator.For example, to get all upvoted items of the authenticated user:
for item in reddit.user.me().upvoted(): print(item.id)
-