Subreddit¶
- class asyncpraw.models.Subreddit(reddit, display_name=None, _data=None)¶
A class for Subreddits.
To obtain an instance of this class for r/test execute:
subreddit = await reddit.subreddit("test")
To obtain a lazy instance of this class for subreddit
r/testexecute:subreddit = await reddit.subreddit("test")
While r/all is not a real subreddit, it can still be treated like one. The following outputs the titles of the 25 hottest submissions in r/all:
subreddit = await reddit.subreddit("all") async for submission in subreddit.hot(limit=25): print(submission.title)
Multiple subreddits can be combined with a
+like so:subreddit = await reddit.subreddit("redditdev+learnpython") async for submission in subreddit.top(time_filter="all"): print(submission)
Subreddits can be filtered from combined listings as follows.
Note
These filters are ignored by certain methods, including
comments, andSubredditStream.comments().subreddit = await reddit.subreddit("all-redditdev") async for submission in subreddit.new(): print(submission)
Typical Attributes
Note
This table describes attributes that typically belong to objects of this class. Async PRAW dynamically provides the attributes that Reddit returns via the API. Since those attributes are subject to change on Reddit’s end, Async PRAW makes no effort to document any new/removed/changed attributes, other than to instruct you on how to discover what is available. As a result, this table of attributes may not be complete. See Determine Available Attributes of an Object for detailed information.
If you would like to add an attribute to this table, feel free to open a pull request.
Attribute
Description
can_assign_link_flairWhether users can assign their own link flair.
can_assign_user_flairWhether users can assign their own user flair.
created_utcTime the subreddit was created, represented in Unix Time.
descriptionSubreddit description, in Markdown.
description_htmlSubreddit description, in HTML.
display_nameName of the subreddit.
icon_imgThe URL of the subreddit icon image.
idID of the subreddit.
nameFullname of the subreddit.
over18Whether the subreddit is NSFW.
public_descriptionDescription of the subreddit, shown in searches and on the “You must be invited to visit this community” page (if applicable).
spoilers_enabledWhether the spoiler tag feature is enabled.
subscribersCount of subscribers.
user_is_bannedWhether the authenticated user is banned.
user_is_moderatorWhether the authenticated user is a moderator.
user_is_subscriberWhether the authenticated user is subscribed.
Note
Trying to retrieve attributes of quarantined or private subreddits will result in a 403 error. Trying to retrieve attributes of a banned subreddit will result in a 404 error.
- Parameters:
reddit (asyncpraw.Reddit)
display_name (str | None)
- __init__(reddit, display_name=None, _data=None)¶
Initialize a
Subredditinstance.- Parameters:
- Return type:
None
Note
This class should not be initialized directly. Instead, obtain an instance via:
# to lazily load a subreddit instance await reddit.subreddit("test") # to fully load a subreddit instance await reddit.subreddit("test", fetch=True)
- banned()¶
Provide an instance of
SubredditRelationship.For example, to ban a user try:
subreddit = await reddit.subreddit("test") await subreddit.banned.add("spez", ban_reason="...")
To list the banned users along with any notes, try:
subreddit = await reddit.subreddit("test") async for ban in subreddit.banned(): print(f"{ban}: {ban.note}")
- Return type:
- collections()¶
Provide an instance of
SubredditCollections.To see the permalinks of all
Collections that belong to a subreddit, try:subreddit = await reddit.subreddit("test") async for collection in subreddit.collections: print(collection.permalink)
To get a specific
Collectionby its UUID or permalink, use one of the following:subreddit = await reddit.subreddit("test") collection = subreddit.collections("some_uuid") collection = subreddit.collections( permalink="https://reddit.com/r/test/collection/some_uuid" )
- Return type:
- comments()¶
Provide an instance of
CommentHelper.For example, to output the author of the 25 most recent comments of r/test execute:
subreddit = await reddit.subreddit("test") async for comment in subreddit.comments(limit=25): print(comment.author)
- Return type:
- contributor()¶
Provide an instance of
ContributorRelationship.Contributors are also known as approved submitters.
To add a contributor try:
subreddit = await reddit.subreddit("test") await subreddit.contributor.add("spez")
- Return type:
- controversial(*, time_filter='all', **generator_kwargs)¶
Return a
ListingGeneratorfor controversial items.- Parameters:
time_filter (
str) – Can be one of:"all","day","hour","month","week", or"year"(default:"all").generator_kwargs (Unpack[ListingGeneratorKwargs])
- Raises:
ValueErroriftime_filteris invalid.- Return type:
Additional keyword arguments are passed in the initialization of
ListingGenerator.This method can be used like:
reddit.domain("imgur.com").controversial(time_filter="week") multireddit = await reddit.multireddit(redditor="samuraisam", name="programming") multireddit.controversial(time_filter="day") redditor = await reddit.redditor("spez") redditor.controversial(time_filter="month") redditor = await reddit.redditor("spez") redditor.comments.controversial(time_filter="year") redditor = await reddit.redditor("spez") redditor.submissions.controversial(time_filter="all") subreddit = await reddit.subreddit("all") subreddit.controversial(time_filter="hour")
- property created_datetime: datetime¶
Return the creation time as a timezone-aware
datetime.datetime.The returned object is localized to the system’s timezone.
- emoji()¶
Provide an instance of
SubredditEmoji.This attribute can be used to discover all emoji for a subreddit:
subreddit = await reddit.subreddit("test") async for emoji in subreddit.emoji: print(emoji)
A single emoji can be lazily retrieved via:
subreddit = await reddit.subreddit("test") emoji = await subreddit.emoji.get_emoji("emoji_name")
Note
Attempting to access attributes of a nonexistent emoji will result in a
ClientException.- Return type:
- filters()¶
Provide an instance of
SubredditFilters.For example, to add a filter, run:
subreddit = await reddit.subreddit("all") await subreddit.filters.add("test")
- Return type:
- flair()¶
Provide an instance of
SubredditFlair.Use this attribute for interacting with a
Subreddit’s flair. For example, to list all the flair for a subreddit which you have theflairmoderator permission on try:subreddit = await reddit.subreddit("test") async for flair in subreddit.flair(): print(flair)
Flair templates can be interacted with through this attribute via:
subreddit = await reddit.subreddit("test") async for template in subreddit.flair.templates: print(template)
- Return type:
- property fullname: str¶
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.
- hot(**generator_kwargs)¶
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() multireddit = await reddit.multireddit(redditor="samuraisam", name="programming") multireddit.hot() redditor = await reddit.redditor("spez") redditor.hot() redditor = await reddit.redditor("spez") redditor.comments.hot() redditor = await reddit.redditor("spez") redditor.submissions.hot() subreddit = await reddit.subreddit("all") subreddit.hot()
- Return type:
- Parameters:
generator_kwargs (Unpack[ListingGeneratorKwargs])
- await load()¶
Re-fetches the object.
This is used to explicitly fetch or re-fetch the object from reddit. This method can be used on any
RedditBaseobject.await reddit_base_object.load()
- Return type:
- await message(*, from_subreddit=None, message, subject)¶
Send a message to a
Redditoror aSubreddit’s moderators (modmail).- Parameters:
from_subreddit (
Subreddit|str|None) –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.message (
str) – The message content.subject (
str) – The subject of the message.
- Return type:
For example, to send a private message to u/spez, try:
redditor = await reddit.redditor("spez", fetch=False) await redditor.message(subject="TEST", message="test message from Async PRAW")
To send a message to u/spez from the moderators of r/test try:
redditor = await reddit.redditor("spez", fetch=False) await redditor.message( subject="TEST", message="test message from r/test", from_subreddit="test" )
To send a message to the moderators of r/test, try:
subreddit = await reddit.subreddit("test") await subreddit.message(subject="TEST", message="test PM from Async PRAW")
- mod()¶
Provide an instance of
SubredditModeration.For example, to accept a moderation invite from r/test:
subreddit = await reddit.subreddit("test") await subreddit.mod.accept_invite()
- Return type:
- moderator()¶
Provide an instance of
ModeratorRelationship.For example, to add a moderator try:
subreddit = await reddit.subreddit("test") await subreddit.moderator.add("spez")
To list the moderators along with their permissions try:
subreddit = await reddit.subreddit("test") async for moderator in subreddit.moderator: print(f"{moderator}: {moderator.mod_permissions}")
- Return type:
- modmail()¶
Provide an instance of
Modmail.For example, to send a new modmail from r/test to u/spez with the subject
"test"along with a message body of"hello":subreddit = await reddit.subreddit("test") await subreddit.modmail.create(subject="test", body="hello", recipient="spez")
- Return type:
- muted()¶
Provide an instance of
SubredditRelationship.For example, muted users can be iterated through like so:
subreddit = await reddit.subreddit("test") async for mute in subreddit.muted(): print("{mute}: {mute.date}")
- Return type:
- new(**generator_kwargs)¶
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() multireddit = await reddit.multireddit(redditor="samuraisam", name="programming") multireddit.new() redditor = await reddit.redditor("spez") redditor.new() redditor = await reddit.redditor("spez") redditor.comments.new() redditor = await reddit.redditor("spez") redditor.submissions.new() subreddit = await reddit.subreddit("all") subreddit.new()
- Return type:
- Parameters:
generator_kwargs (Unpack[ListingGeneratorKwargs])
- classmethod parse(data, reddit)¶
Return an instance of
clsfromdata.
- await post_requirements()¶
Get the post requirements for a subreddit.
The returned dict contains the following keys:
domain_blacklistbody_restriction_policydomain_whitelisttitle_regexesbody_blacklisted_stringsbody_required_stringstitle_text_min_lengthis_flair_requiredtitle_text_max_lengthbody_regexeslink_repost_agebody_text_min_lengthlink_restriction_policybody_text_max_lengthtitle_required_stringstitle_blacklisted_stringsguidelines_textguidelines_display_policy
For example, to fetch the post requirements for r/test:
subreddit = await reddit.subreddit("test") post_requirements = await subreddit.post_requirements print(post_requirements)
- quaran()¶
Provide an instance of
SubredditQuarantine.This property is named
quaranbecausequarantineis a subreddit attribute returned by Reddit to indicate whether or not a subreddit is quarantined.To opt-in into a quarantined subreddit:
subreddit = await reddit.subreddit("test") await subreddit.quaran.opt_in()
- Return type:
- rising(**generator_kwargs)¶
Return a
ListingGeneratorfor rising submissions.Additional keyword arguments are passed in the initialization of
ListingGenerator.For example, to get rising submissions for r/test:
subreddit = await reddit.subreddit("test") async for submission in subreddit.rising(): print(submission.title)
- Return type:
- Parameters:
generator_kwargs (Unpack[ListingGeneratorKwargs])
- rules()¶
Provide an instance of
SubredditRules.Use this attribute for interacting with a
Subreddit’s rules.For example, to list all the rules for a subreddit:
subreddit = await reddit.subreddit("test") async for rule in subreddit.rules: print(rule)
Moderators can also add rules to the subreddit. For example, to make a rule called
"No spam"in r/test:subreddit = await reddit.subreddit("test") await subreddit.rules.mod.add( short_name="No spam", kind="all", description="Do not spam. Spam bad" )
- Return type:
- search(query, *, sort='relevance', syntax='lucene', time_filter='all', **generator_kwargs)¶
Return a
ListingGeneratorfor items that matchquery.- Parameters:
query (
str) – The query string to search for.sort (
str) – Can be one of:"relevance","hot","top","new", or"comments". (default:"relevance").syntax (
str) – Can be one of:"cloudsearch","lucene", or"plain"(default:"lucene").time_filter (
str) – Can be one of:"all","day","hour","month","week", or"year"(default:"all").generator_kwargs (Any)
- Return type:
For more information on building a search query see: https://www.reddit.com/wiki/search
For example, to search all subreddits for
"praw"try:subreddit = await reddit.subreddit("all") async for submission in subreddit.search("praw"): print(submission.title)
- await sticky(*, number=1)¶
Return a
Submissionobject for a sticky of the subreddit.- Parameters:
number (
int) – Specify which sticky to return. 1 appears at the top (default:1).- Raises:
asyncprawcore.NotFoundif the sticky does not exist.- Return type:
For example, to get the stickied post on r/test:
subreddit = await reddit.subreddit("test") await subreddit.sticky()
- stream()¶
Provide an instance of
SubredditStream.Streams can be used to indefinitely retrieve new comments made to a subreddit, like:
subreddit = await reddit.subreddit("test") async for comment in subreddit.stream.comments(): print(comment)
Additionally, new submissions can be retrieved via the stream. In the following example all submissions are fetched via the special r/all:
subreddit = await reddit.subreddit("all") async for submission in subreddit.stream.submissions(): print(submission)
- Return type:
- stylesheet()¶
Provide an instance of
SubredditStylesheet.For example, to add the css data
.test{color:blue}to the existing stylesheet:subreddit = await reddit.subreddit("test") stylesheet = await subreddit.stylesheet() stylesheet.stylesheet += ".test{color:blue}" await subreddit.stylesheet.update(stylesheet.stylesheet)
- Return type:
- await submit(title, *, collection_id=None, discussion_type=None, draft_id=None, flair_id=None, flair_text=None, gallery=None, image=None, inline_media=None, nsfw=False, poll=None, resubmit=True, selftext=None, send_replies=True, spoiler=False, timeout=10, url=None, video=None, without_websockets=False)¶
- Overloads:
self, title (str), collection_id (str | None), discussion_type (str | None), draft_id (str | None), flair_id (str | None), flair_text (str | None), inline_media (dict[str, asyncpraw.models.InlineMedia] | None), nsfw (bool), resubmit (bool), selftext (str), send_replies (bool), spoiler (bool) → asyncpraw.models.Submission
self, title (str), collection_id (str | None), discussion_type (str | None), draft_id (str | None), flair_id (str | None), flair_text (str | None), nsfw (bool), resubmit (bool), selftext (str | None), send_replies (bool), spoiler (bool), url (str) → asyncpraw.models.Submission
self, title (str), collection_id (str | None), discussion_type (str | None), flair_id (str | None), flair_text (str | None), image (asyncpraw.models.PostMedia), nsfw (bool), resubmit (bool), selftext (str | None), send_replies (bool), spoiler (bool), timeout (int), without_websockets (bool) → asyncpraw.models.Submission | None
self, title (str), collection_id (str | None), discussion_type (str | None), flair_id (str | None), flair_text (str | None), gallery (list[asyncpraw.models.PostMedia | dict[str, str | asyncpraw.models.PostMedia]]), nsfw (bool), selftext (str | None), send_replies (bool), spoiler (bool) → asyncpraw.models.Submission
self, title (str), collection_id (str | None), discussion_type (str | None), flair_id (str | None), flair_text (str | None), nsfw (bool), poll (dict[str, int | list[str]]), resubmit (bool), selftext (str | None), send_replies (bool), spoiler (bool) → asyncpraw.models.Submission
self, title (str), collection_id (str | None), discussion_type (str | None), flair_id (str | None), flair_text (str | None), nsfw (bool), resubmit (bool), selftext (str | None), send_replies (bool), spoiler (bool), timeout (int), video (asyncpraw.models.PostMedia | dict[str, bool | asyncpraw.models.PostMedia]), without_websockets (bool) → asyncpraw.models.Submission | None
- Parameters:
title (str)
collection_id (str | None)
discussion_type (str | None)
draft_id (str | None)
flair_id (str | None)
flair_text (str | None)
gallery (list[PostMedia | dict[str, str | PostMedia]] | None)
image (PostMedia | None)
inline_media (dict[str, InlineMedia] | None)
nsfw (bool)
resubmit (bool)
selftext (str | None)
send_replies (bool)
spoiler (bool)
timeout (int)
url (str | None)
without_websockets (bool)
- Return type:
Submission | None
Add a submission to the
Subreddit.- Parameters:
title (
str) – The title of the submission.collection_id (
str|None) – The UUID of aCollectionto add the newly-submitted post to.discussion_type (
str|None) – Set to"CHAT"to enable live discussion instead of traditional comments (default:None).draft_id (
str|None) – The ID of a draft to submit. Only applies to text and link submissions.flair_id (
str|None) – The flair template to select (default:None).flair_text (
str|None) – If the template’sflair_text_editablevalue isTrue, this value will set a custom text (default:None).flair_idis required whenflair_textis provided.gallery (
list[PostMedia|dict[str,str|PostMedia]] |None) – A list of images to post as a gallery. Each item is either aPostMediaor adictwith the structure{"media": PostMedia("path"), "caption": "caption", "outbound_url": "url"}, where onlymediais required.image (
PostMedia|None) – ThePostMediaimage to upload and post.inline_media (
dict[str,InlineMedia] |None) – A dict ofInlineMediaobjects where the key is the placeholder name inselftext. Only supported for text submissions.nsfw (
bool) – Whether the submission should be marked NSFW (default:False).poll (
dict[str,int|list[str]] |None) – Adictwith the structure{"duration": 3, "options": ["Yes", "No"]}, wheredurationis the number of days the poll should accept votes (between1and7, inclusive) andoptionsis a list of two to six poll options asstr. Both keys are required.resubmit (
bool) – WhenFalse, an error will occur if the URL has already been submitted (default:True).selftext (
str|None) – The Markdown formatted content for atextsubmission or optional Markdown-formatted body text for any other kind of submission. Use an empty string,"", to make a title-only submission.send_replies (
bool) – WhenTrue, messages will be sent to the submission author when comments are made to the submission (default:True).spoiler (
bool) – Whether the submission should be marked as a spoiler (default:False).timeout (
int) – Specifies a particular timeout, in seconds, for the WebSockets connection used byimageandvideosubmissions. Use to avoid “Websocket error” exceptions (default:10).video (
PostMedia|dict[str,bool|PostMedia] |None) – The video to upload and post. Either aPostMediaor adictwith the structure{"media": PostMedia("path"), "gif": True, "thumbnail": PostMedia("path")}, where onlymediais required. Set"gif"toTrueto submit the video as a videogif, which is essentially a silent video (default:False). When"thumbnail"is not provided, the PRAW logo will be used as the thumbnail.without_websockets (
bool) – Set toTrueto disable use of WebSockets forimageandvideosubmissions (see note below for an explanation). IfTrue, this method doesn’t return anything (default:False).
- Returns:
A
Submissionobject for the newly created submission, unlesswithout_websocketsisTruefor animageorvideosubmission.- Raises:
ClientExceptionifimageor agalleryitem’smediarefers to a file that is not an image, or if thevideo(or itsmedia) refers to a file that is not a video.- Return type:
Submission | None
At least one of
gallery,image,poll,selftext,url, orvideomust be provided.gallery,image,poll,url, andvideoare mutually exclusive, whileselftextmay accompany any of them as optional Markdown-formatted body text.selftextthat accompanies another kind of submission does not supportinline_media.For example, to submit a URL to r/test do:
title = "Async PRAW documentation" url = "https://asyncpraw.readthedocs.io" subreddit = await reddit.subreddit("test") await subreddit.submit(title, url=url)
To submit an image to r/test do:
from asyncpraw.models import PostMedia title = "My favorite picture" image = PostMedia("/path/to/image.png") subreddit = await reddit.subreddit("test") await subreddit.submit(title, image=image)
To submit an image gallery to r/test do:
from asyncpraw.models import PostMedia title = "My favorite pictures" gallery = [ PostMedia("/path/to/image.png"), { "media": PostMedia("/path/to/image2.png"), "caption": "Image caption 2", }, { "media": PostMedia("/path/to/image3.png"), "caption": "Image caption 3", "outbound_url": "https://example.com/link3", }, ] subreddit = await reddit.subreddit("test") await subreddit.submit(title, gallery=gallery)
To submit a video to r/test do:
from asyncpraw.models import PostMedia title = "My favorite movie" video = PostMedia("/path/to/video.mp4") subreddit = await reddit.subreddit("test") await subreddit.submit(title, video=video)
To submit a videogif with a custom thumbnail instead, do:
from asyncpraw.models import PostMedia title = "My favorite gif" video = { "gif": True, "media": PostMedia("/path/to/video.mp4"), "thumbnail": PostMedia("/path/to/thumbnail.png"), } subreddit = await reddit.subreddit("test") await subreddit.submit(title, video=video)
To submit a poll to r/test do:
title = "Do you like Async PRAW?" poll = {"duration": 3, "options": ["Yes", "No"]} subreddit = await reddit.subreddit("test") await subreddit.submit(title, poll=poll)
To submit a self post with inline media do:
from asyncpraw.models import InlineGif, InlineImage, InlineVideo, PostMedia gif = InlineGif(caption="optional caption", media=PostMedia("path/to/image.gif")) image = InlineImage(caption="optional caption", media=PostMedia("path/to/image.jpg")) video = InlineVideo(caption="optional caption", media=PostMedia("path/to/video.mp4")) selftext = "Text with a gif {gif1} an image {image1} and a video {video1} inline" media = {"gif1": gif, "image1": image, "video1": video} subreddit = await reddit.subreddit("test") await subreddit.submit("title", inline_media=media, selftext=selftext)
Note
Inserted media will have a padding of
\\n\\nautomatically added. This is due to the weirdness with Reddit’s API. Using the example above, the result selftext body will look like so:Text with a gif  an image  and video  inline
Note
For
imageandvideosubmissions, Reddit’s API uses WebSockets to respond with the link of the newly created post. If this fails, the method will raiseWebSocketException. Occasionally, the Reddit post will still be created. More often, there is an error with the media file. If you frequently get exceptions but successfully created posts, try setting thetimeoutparameter to a value above 10.To disable the use of WebSockets, set
without_websockets=True. This will make the method returnNone, though the post will still be created. You may wish to do this if you are running your program in a restricted network environment, or using a proxy that doesn’t support WebSockets connections.Note
To submit a post to a subreddit with the
"news"flair, you can get the flair id like this:choices = [template async for template in subreddit.flair.link_templates.user_selectable()] template_id = next(x for x in choices if x["flair_text"] == "news")["flair_template_id"] await subreddit.submit("title", flair_id=template_id, url="https://www.news.com/")
Note
If you need to access any attributes of the submission after submitting it, you must re-fetch the submission, like so:
submission = await subreddit.submit(title, url=url) await submission.load()
- await subscribe(*, other_subreddits=None)¶
Subscribe to the subreddit.
- Parameters:
other_subreddits (
list[Subreddit] |None) – When provided, also subscribe to the provided list of subreddits.- Return type:
For example, to subscribe to r/test:
subreddit = await reddit.subreddit("test") await subreddit.subscribe()
- top(*, time_filter='all', **generator_kwargs)¶
Return a
ListingGeneratorfor top items.- Parameters:
time_filter (
str) – Can be one of:"all","day","hour","month","week", or"year "``(default: ``"all").generator_kwargs (Unpack[ListingGeneratorKwargs])
- Raises:
ValueErroriftime_filteris invalid.- Return type:
Additional keyword arguments are passed in the initialization of
ListingGenerator.This method can be used like:
reddit.domain("imgur.com").top(time_filter="week") multireddit = await reddit.multireddit(redditor="samuraisam", name="programming") multireddit.top(time_filter="day") redditor = await reddit.redditor("spez") redditor.top(time_filter="month") redditor = await reddit.redditor("spez") redditor.comments.top(time_filter="year") redditor = await reddit.redditor("spez") redditor.submissions.top(time_filter="all") subreddit = await reddit.subreddit("all") subreddit.top(time_filter="hour")
- await traffic()¶
Return a dictionary of the
Subreddit’s traffic statistics.- Raises:
asyncprawcore.NotFoundwhen the traffic stats aren’t available to the authenticated user, that is, they are not public and the authenticated user is not a moderator of the subreddit.- Return type:
The traffic method returns a dict with three keys. The keys are
day,hourandmonth. Each key contains a list of lists with 3 or 4 values. The first value is a timestamp indicating the start of the category (start of the day for thedaykey, start of the hour for thehourkey, etc.). The second, third, and fourth values indicate the unique pageviews, total pageviews, and subscribers, respectively.Note
The
hourkey does not contain subscribers, and therefore each sub-list contains three values.For example, to get the traffic stats for r/test:
subreddit = await reddit.subreddit("test") stats = await subreddit.traffic()
- await unsubscribe(*, other_subreddits=None)¶
Unsubscribe from the subreddit.
- Parameters:
other_subreddits (
list[Subreddit] |None) – When provided, also unsubscribe from the provided list of subreddits.- Return type:
To unsubscribe from r/test:
subreddit = await reddit.subreddit("test") await subreddit.unsubscribe()
- widgets()¶
Provide an instance of
SubredditWidgets.Example usage
Get all sidebar widgets:
subreddit = await reddit.subreddit("test") async for widget in subreddit.widgets.sidebar: print(widget)
Get ID card widget:
subreddit = await reddit.subreddit("test") widget = await subreddit.widgets.id_card() print(widget)
- Return type:
- wiki()¶
Provide an instance of
SubredditWiki.This attribute can be used to discover all wikipages for a subreddit:
subreddit = await reddit.subreddit("test") async for wikipage in subreddit.wiki: print(wikipage)
To fetch the content for a given wikipage try:
subreddit = await reddit.subreddit("test") wikipage = await subreddit.wiki.get_page("proof") print(wikipage.content_md)
- Return type: