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
Reddit
instance with which requests are made. - data: Dict
- The data obtained from the /about endpoint.
- mod: CommentModeration
- The
CommentModeration
instance 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
aPRAWBase
class and may vary depending on the status of the response and expected objects.Attribute Description all_awardings
A list of awardings added to the comment. approved_at_utc
The UTC timestamp at which the comment was approved by the moderators. approved_by
The moderator who approved this comment if applicable. approved
Whether the comment has been approved by the moderators. archived
Whether the comment has been archived. author_flair_background_color
The comment author’s flair background color if applicable. author_flair_css_class
The comment author’s flair CSS class if applicable. author_flair_richtext
The comment author’s flair text if applicable. author_flair_template_id
The comment author’s flair template ID if applicable. author_flair_text_color
The comment author’s flair text color if applicable. author_flair_text
The comment author’s flair text if applicable. author_flair_type
The comment author’s flair type if applicable. author_fullname
The comment author’s ID prepended with t2_
.author_patreon_flair
The comment author’s Patreon flair if applicable. author
The comment author’s username. banned_at_utc
None
banned_by
None
body_html
The HTML version of the comment’s body. body
The comment’s markdown body. can_gild
Whether the logged-in user can gild the comment. can_mod_post
bool
collapsed_reason
None
collapsed
Whether the comment should be collapsed by clients. controversiality
A score on the comment’s controversiality based on its up- and downvotes. created_utc
The parsed UTC datetime
on which the comment was made.created
A timestamp on which the comment was created. distinguished
The type of distinguishment the comment hsa received. downs
The number of downvotes the comment has received. edited
Whether the comment has been edited from its original state. gilded
The number of awards this comment has received. gildings
A dictionary of gilds the comment has received. id
The comment’s ID. ignore_reports
Whether reports should be ignored on this comment. is_submitter
Whether the logged-in user is the submitter of this comment. likes
The overall upvote score on this comment. link_author
The username of the comment submission’s author. link_id
The ID of the submission this comment was made in. link_permalink
/link_url
A URL to the comment’s submission. link_title
The comment’s submission title. locked
Whether the comment has been locked by the moderators. mod_note
Notes added to the comment by moderators if applicable. mod_reason_by
The moderator who added a removal reason if applicable. mod_reason_title
The mod reason’s title if applicable. mod_reports
A list of reports made on this comment filed by moderators. name
The comment’s ID prepended with t1_
.no_follow
bool
num_comments
The number of replies made in this submission. num_reports
The number of reports on this comment. over_18
Whether the comment has been marked NSFW. parent_id
The comment’s parent ID, either link_id
or the ID of another comment.permalink
The comment’s permalink. quarantine
bool
removal_reason
A removal reason set by moderators if applicable. removed
Whether the comment has been removed by the moderators of the subreddit. replies
A list of replies made under this comment, usually empty at first. report_reasons
Report reasons added to the comment. saved
Whether the logged-in user has saved this comment. score_hidden
Whether clients should hide the comment’s score. score
The overall upvote score on this comment. send_replies
Whether the OP has enabled reply notifications. spam
Whether the comment has been flagged as spam. stickied
Whether the comment has been stickied by the moderators. subreddit_id
The comment subreddit’s ID prepended with t5_
.subreddit_name_prefixed
The comment’s subreddit name prefixed with “r/”. subreddit_type
The type of the subreddit the submission was posted on (public, restricted, private). subreddit
The name of the subreddit this comment was made in. total_awards_received
The number of awards this comment has received. ups
The number of upvotes this comment has received. user_reports
A 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
Comment
and already have their_replies
recursively 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 therefresh
argument.Parameters: refresh (bool) – Whether to force a refresh of previously fetched comments.
Warning
reload
andrefresh
arguments 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