Subreddit

This section describes the usage and members of the Subreddit model.

A subreddit can be instantiated as follows:

sub = await reddit.subreddit("aprawtest")
class apraw.models.Subreddit(reddit: Reddit, data: Dict)

The model representing subreddits.

reddit: Reddit
The Reddit instance with which requests are made.
data: Dict
The data obtained from the /about endpoint.
kind: str
The item’s kind / type.
mod: SubredditModeration
Returns an instance of SubredditModeration.
modmail: SubredditModmail
Returns an instance of SubredditModmail.
wiki: SubredditWiki
Returns an instance of SubredditWiki.
comments: ListingGenerator
Returns an instance of ListingGenerator mapped to the comments endpoint.
new: ListingGenerator
Returns an instance of ListingGenerator mapped to the new submissions endpoint.
hot: ListingGenerator
Returns an instance of ListingGenerator mapped to the hot submissions endpoint.
rising: ListingGenerator
Returns an instance of ListingGenerator mapped to the rising submissions endpoint.
top: ListingGenerator
Returns an instance of ListingGenerator mapped to the top submissions endpoint.

Warning

Using the streams of non-new endpoints may result in receiving items multiple times, as their positions can change and be returned by the API after they’ve been removed from the internal tracker.

Examples

To grab new submissions made on a subreddit:

sub = await reddit.subreddit("aprawtest")
async for submission in sub.new(): # use .new.stream() for endless polling
    print(submission.title, submission.body)

Typical Attributes

This table describes attributes that typically belong to objects of this class. Attributes are dynamically provided by the aPRAWBase class and may vary depending on the status of the response and expected objects.

Attribute Description
accounts_active_is_fuzzed bool
accounts_active null
active_user_count The number of active users on the subreddit.
advertiser_category string
all_original_content Whether the subreddit requires all content to be OC.
allow_discovery Whether the subreddit can be discovered.
allow_images Whether images are allowed as submissions.
allow_videogifs Whether GIFs are allowed as submissions.
allow_videos Whether videos are allowed as submissions.
banner_background_color The banner’s background color if applicable, otherwise empty.
banner_background_image A URL to the subreddit’s banner image.
banner_img A URL to the subreddit’s banner image if applicable.
banner_size The subreddit’s banner size if applicable.
can_assign_link_flair Whether submission flairs can be assigned.
can_assign_user_flair Whether the user can assign their own flair on the subreddit.
collapse_deleted_comments Whether deleted comments should be deleted by clients.
comment_score_hide_mins The minimum comment score to hide.
community_icon A URL to the subreddit’s community icon if applicable.
created_utc The date on which the subreddit was created in UTC datetime.
created The time the subreddit was created on.
description_html The subreddit’s description as HTML.
description The subreddit’s short description.
disable_contributor_requests bool
display_name_prefixed The subreddit’s display name prefixed with ‘r/’.
display_name The subreddit’s display name.
emojis_custom_size The custom size set for emojis.
emojis_enabled Whether emojis are enabled on this subreddit.
free_form_reports Whether it’s possible to submit free form reports.
has_menu_widget Whether the subreddit has menu widgets.
header_img A URL to the subreddit’s header image of applicable.
header_size The subreddit’s header size.
header_title The subreddit’s header title.
hide_ads Whether ads are hidden on this subreddit.
icon_img A URL to the subreddit’s icon image of applicable.
icon_size The subreddit’s icon size.
id The subreddit’s ID.
is_enroled_in_new_modmail Whether the subreddit is enrolled in new modmail.
key_color string
lang The subreddit’s language.
link_flair_enabled Whether link flairs have been enabled for the subreddit.
link_flair_position The position of link flairs.
mobile_banner_size A URL to the subreddit’s mobile banner if applicable.
name The subreddit’s fullname (t5_ID).
notification_level  
original_content_tag_enabled Whether the subreddit has the OC tag enabled.
over18 Whether the subreddit is NSFW.
primary_color The subreddit’s primary color.
public_description_html The subreddit’s public description as HTML.
public_description The subreddit’s public description string.
public_traffic bool
quarantine Whether the subreddit is quarantined.
restrict_commenting Whether comments by users are restricted on the subreddit.
restrict_posting Whether posts to the subreddit are restricted.
show_media_preview Whether media previews should be displayed by clients.
show_media  
spoilers_enabled Whether the spoiler tag is enabled on the subreddit.
submission_type The types of allowed submissions. Default is “any”.
submit_link_label The subreddit’s submit label if applicable.
submit_text_html The HTML submit text if a custom one is set on the subreddit.
submit_text_label The text used for the submit button.
submit_text The markdown submit text if a custom one is set on the subreddit.
subreddit_type The subreddit type, either “public”, “restricted” or “private”.
subscribers The number of subreddit subscribers.
suggested_comment_sort The suggested comment sort algorithm, can be null.
title The subreddit’s banner title.
url The subreddit’s display name prepended with “/r/”.
user_can_flair_in_sr Whether the user can assign custom flairs (nullable).
user_flair_background_color The logged in user’s flair background color if applicable.
user_flair_css_class The logged in user’s flair CSS class.
user_flair_enabled_in_sr Whether the logged in user’s subreddit flair is enabled.
user_flair_position The position of user flairs on the subreddit (right or left).
user_flair_richtext The logged in user’s flair text if applicable.
user_flair_template_id The logged in user’s flair template ID if applicable.
user_flair_text_color The logged in user’s flair text color.
user_flair_text The logged in user’s flair text.
user_flair_type The logged in user’s flair type.
user_has_favorited Whether the logged in user has favorited the subreddit.
user_is_banned Whether the logged in user is banned from the subreddit.
user_is_contributor Whether the logged in user has contributed to the subreddit.
user_is_moderator Whether the logged in user is a moderator on the subreddit.
user_is_muted Whether the logged in user has been muted by the subreddit.
user_is_subscriber Whether the logged in user is subscribed to the subreddit.
user_sr_flair_enabled Whether the logged in user’s subreddit flair is enabled.
user_sr_theme_enabled Whether the logged in user has enabled the custom subreddit theme.
videostream_links_count The number of submissions with videostream links.
whitelist_status  
wiki_enabled Whether the subreddit has the wiki enabled.
wls null
message(subject: str, text: str, from_sr: Union[str, Subreddit] = '') → Dict

Send a message to the subreddit.

Parameters:
  • subject (str) – The message subject.
  • text (str) – The message contents as markdown.
  • from_sr (str or Subreddit) – The subreddit the message is being sent from if applicable.
Returns:

response – The API response JSON as a dictionary.

Return type:

Dict

moderators(**kwargs) → AsyncIterator[apraw.models.subreddit.SubredditModerator]

Yields all the subreddit’s moderators.

Parameters:kwargs (**Dict) – The query parameters to be added to the GET request.
Yields:moderator (SubredditModerator) – An instance of the moderators as SubredditModerator.