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
Redditinstance 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
ListingGeneratormapped to the comments endpoint. - new: ListingGenerator
- Returns an instance of
ListingGeneratormapped to the new submissions endpoint. - hot: ListingGenerator
- Returns an instance of
ListingGeneratormapped to the hot submissions endpoint. - rising: ListingGenerator
- Returns an instance of
ListingGeneratormapped to the rising submissions endpoint. - top: ListingGenerator
- Returns an instance of
ListingGeneratormapped 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
aPRAWBaseclass and may vary depending on the status of the response and expected objects.Attribute Description accounts_active_is_fuzzedboolaccounts_activenullactive_user_countThe number of active users on the subreddit. advertiser_categorystringall_original_contentWhether the subreddit requires all content to be OC. allow_discoveryWhether the subreddit can be discovered. allow_imagesWhether images are allowed as submissions. allow_videogifsWhether GIFs are allowed as submissions. allow_videosWhether videos are allowed as submissions. banner_background_colorThe banner’s background color if applicable, otherwise empty. banner_background_imageA URL to the subreddit’s banner image. banner_imgA URL to the subreddit’s banner image if applicable. banner_sizeThe subreddit’s banner size if applicable. can_assign_link_flairWhether submission flairs can be assigned. can_assign_user_flairWhether the user can assign their own flair on the subreddit. collapse_deleted_commentsWhether deleted comments should be deleted by clients. comment_score_hide_minsThe minimum comment score to hide. community_iconA URL to the subreddit’s community icon if applicable. created_utcThe date on which the subreddit was created in UTC datetime.createdThe time the subreddit was created on. description_htmlThe subreddit’s description as HTML. descriptionThe subreddit’s short description. disable_contributor_requestsbooldisplay_name_prefixedThe subreddit’s display name prefixed with ‘r/’. display_nameThe subreddit’s display name. emojis_custom_sizeThe custom size set for emojis. emojis_enabledWhether emojis are enabled on this subreddit. free_form_reportsWhether it’s possible to submit free form reports. has_menu_widgetWhether the subreddit has menu widgets. header_imgA URL to the subreddit’s header image of applicable. header_sizeThe subreddit’s header size. header_titleThe subreddit’s header title. hide_adsWhether ads are hidden on this subreddit. icon_imgA URL to the subreddit’s icon image of applicable. icon_sizeThe subreddit’s icon size. idThe subreddit’s ID. is_enroled_in_new_modmailWhether the subreddit is enrolled in new modmail. key_colorstringlangThe subreddit’s language. link_flair_enabledWhether link flairs have been enabled for the subreddit. link_flair_positionThe position of link flairs. mobile_banner_sizeA URL to the subreddit’s mobile banner if applicable. nameThe subreddit’s fullname (t5_ID). notification_leveloriginal_content_tag_enabledWhether the subreddit has the OC tag enabled. over18Whether the subreddit is NSFW. primary_colorThe subreddit’s primary color. public_description_htmlThe subreddit’s public description as HTML. public_descriptionThe subreddit’s public description string. public_trafficboolquarantineWhether the subreddit is quarantined. restrict_commentingWhether comments by users are restricted on the subreddit. restrict_postingWhether posts to the subreddit are restricted. show_media_previewWhether media previews should be displayed by clients. show_mediaspoilers_enabledWhether the spoiler tag is enabled on the subreddit. submission_typeThe types of allowed submissions. Default is “any”. submit_link_labelThe subreddit’s submit label if applicable. submit_text_htmlThe HTML submit text if a custom one is set on the subreddit. submit_text_labelThe text used for the submit button. submit_textThe markdown submit text if a custom one is set on the subreddit. subreddit_typeThe subreddit type, either “public”, “restricted” or “private”. subscribersThe number of subreddit subscribers. suggested_comment_sortThe suggested comment sort algorithm, can be null.titleThe subreddit’s banner title. urlThe subreddit’s display name prepended with “/r/”. user_can_flair_in_srWhether the user can assign custom flairs (nullable). user_flair_background_colorThe logged in user’s flair background color if applicable. user_flair_css_classThe logged in user’s flair CSS class. user_flair_enabled_in_srWhether the logged in user’s subreddit flair is enabled. user_flair_positionThe position of user flairs on the subreddit (right or left). user_flair_richtextThe logged in user’s flair text if applicable. user_flair_template_idThe logged in user’s flair template ID if applicable. user_flair_text_colorThe logged in user’s flair text color. user_flair_textThe logged in user’s flair text. user_flair_typeThe logged in user’s flair type. user_has_favoritedWhether the logged in user has favorited the subreddit. user_is_bannedWhether the logged in user is banned from the subreddit. user_is_contributorWhether the logged in user has contributed to the subreddit. user_is_moderatorWhether the logged in user is a moderator on the subreddit. user_is_mutedWhether the logged in user has been muted by the subreddit. user_is_subscriberWhether the logged in user is subscribed to the subreddit. user_sr_flair_enabledWhether the logged in user’s subreddit flair is enabled. user_sr_theme_enabledWhether the logged in user has enabled the custom subreddit theme. videostream_links_countThe number of submissions with videostream links. whitelist_statuswiki_enabledWhether the subreddit has the wiki enabled. wlsnull-
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.