Comment¶
Besides retrieving comments similarly to submissions using their ID or fetching them through a subreddit’s listings, comments can be obtained from the submission they were made in like so:
submission = await reddit.submission("h7mna9")
async for comment in submission.comments():
print(comment)
-
class
apraw.models.Comment(reddit: Reddit, data: Dict, submission: Submission = None, author: apraw.models.redditor.Redditor = None, subreddit: apraw.models.subreddit.Subreddit = None, replies: List[Comment] = None)¶ The model representing comments.
- reddit: Reddit
- The
Redditinstance with which requests are made. - data: Dict
- The data obtained from the /about endpoint.
- mod: CommentModeration
- The
CommentModerationinstance to aid in moderating the comment. - kind: str
- The item’s kind / type.
- url: str
- The URL pointing to this comment.
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 all_awardingsA list of awardings added to the comment. approved_at_utcThe UTC timestamp at which the comment was approved by the moderators. approved_byThe moderator who approved this comment if applicable. approvedWhether the comment has been approved by the moderators. archivedWhether the comment has been archived. author_flair_background_colorThe comment author’s flair background color if applicable. author_flair_css_classThe comment author’s flair CSS class if applicable. author_flair_richtextThe comment author’s flair text if applicable. author_flair_template_idThe comment author’s flair template ID if applicable. author_flair_text_colorThe comment author’s flair text color if applicable. author_flair_textThe comment author’s flair text if applicable. author_flair_typeThe comment author’s flair type if applicable. author_fullnameThe comment author’s ID prepended with t2_.author_patreon_flairThe comment author’s Patreon flair if applicable. authorThe comment author’s username. banned_at_utcNonebanned_byNonebody_htmlThe HTML version of the comment’s body. bodyThe comment’s markdown body. can_gildWhether the logged-in user can gild the comment. can_mod_postboolcollapsed_reasonNonecollapsedWhether the comment should be collapsed by clients. controversialityA score on the comment’s controversiality based on its up- and downvotes. created_utcThe parsed UTC datetimeon which the comment was made.createdA timestamp on which the comment was created. distinguishedThe type of distinguishment the comment hsa received. downsThe number of downvotes the comment has received. editedWhether the comment has been edited from its original state. gildedThe number of awards this comment has received. gildingsA dictionary of gilds the comment has received. idThe comment’s ID. ignore_reportsWhether reports should be ignored on this comment. is_submitterWhether the logged-in user is the submitter of this comment. likesThe overall upvote score on this comment. link_authorThe username of the comment submission’s author. link_idThe ID of the submission this comment was made in. link_permalink/link_urlA URL to the comment’s submission. link_titleThe comment’s submission title. lockedWhether the comment has been locked by the moderators. mod_noteNotes added to the comment by moderators if applicable. mod_reason_byThe moderator who added a removal reason if applicable. mod_reason_titleThe mod reason’s title if applicable. mod_reportsA list of reports made on this comment filed by moderators. nameThe comment’s ID prepended with t1_.no_followboolnum_commentsThe number of replies made in this submission. num_reportsThe number of reports on this comment. over_18Whether the comment has been marked NSFW. parent_idThe comment’s parent ID, either link_idor the ID of another comment.permalinkThe comment’s permalink. quarantineboolremoval_reasonA removal reason set by moderators if applicable. removedWhether the comment has been removed by the moderators of the subreddit. repliesA list of replies made under this comment, usually empty at first. report_reasonsReport reasons added to the comment. savedWhether the logged-in user has saved this comment. score_hiddenWhether clients should hide the comment’s score. scoreThe overall upvote score on this comment. send_repliesWhether the OP has enabled reply notifications. spamWhether the comment has been flagged as spam. stickiedWhether the comment has been stickied by the moderators. subreddit_idThe comment subreddit’s ID prepended with t5_.subreddit_name_prefixedThe comment’s subreddit name prefixed with “r/”. subreddit_typeThe type of the subreddit the submission was posted on (public, restricted, private). subredditThe name of the subreddit this comment was made in. total_awards_receivedThe number of awards this comment has received. upsThe number of upvotes this comment has received. user_reportsA list of user reports filed for this comment. Note
Many of these attributes are only available if the logged-in user has moderator access to the item.
-
clear_vote()¶ Clear user up- and downvotes on the item.
Returns: resp – The API response JSON. Return type: Dict
-
delete()¶ Delete the item.
Returns: resp – The API response JSON. Return type: Dict
-
downvote()¶ Downvote the item.
Returns: resp – The API response JSON. Return type: Dict
-
full_data(refresh: bool = False) → Dict¶ Retrieve the submission’s full data from the /r/{sub}/comments/{submission}/_/{id} endpoint.
Returns: full_data – The full data retrieved from the API. Return type: Dict
-
hide()¶ Hide the item.
Returns: resp – The API response JSON. Return type: Dict
-
refresh()¶ Reload the comment’s data and replies.
Warning
Refresh methods will be replaced by refreshables in future releases of aPRAW, and these methods will not be available in post-alpha releases.
-
replies(refresh: bool = False) → AsyncIterator[apraw.models.comment.Comment]¶ Retrieve this comment’s replies.
Note
Replies are returned as
Commentand already have their_repliesrecursively filled with data retrieved from the request made originally. Fetching replies at a further depth will not result in further calls unless specifically specified with therefreshargument.Parameters: refresh (bool) – Whether to force a refresh of previously fetched comments.
Warning
reloadandrefresharguments will be replaced by refreshables in future releases of aPRAW, as they are alpha features.Yields: reply (Comment) – A reply to this comment.
-
save(category: str = '')¶ Save the item in a category.
Parameters: category (str, optional) – The category name. Returns: resp – The API response JSON. Return type: Dict
-
submission() → Submission¶ Retrieve the submission this comment was made in as a
Submission.Returns: submission – The submission this comment was made in. Return type: Submission
-
subreddit() → apraw.models.subreddit.Subreddit¶ Retrieve the subreddit this item was made in as a
Subreddit.Returns: subreddit – The subreddit this item was made in. Return type: Subreddit
-
unhide()¶ Unhide the item.
Returns: resp – The API response JSON. Return type: Dict
-
unsave()¶ Unsave the item.
Returns: resp – The API response JSON. Return type: Dict
-
upvote()¶ Upvote the item.
Returns: resp – The API response JSON. Return type: Dict