redditwarp.siteprocs.comment_tree.ASYNC#

class redditwarp.siteprocs.comment_tree.ASYNC.CommentTreeProcedures(client: Client)[source]#

Bases: object

low: Low#

Low level calls for efficiency.

async get(submission_id: _YIntOrStr, comment_id: _YIntOrStr | None = None, *, sort: str = 'confidence', limit: int | None = None, depth: int | None = None, context: int | None = None) SubmissionTreeNode | None[source]#

Get the comment tree for a submission.

Behaves similarly to fetch().

Returns None instead of raises on StatusCodeException(404) and RejectedResultException.

async fetch(submission_id: _YIntOrStr, comment_id: _YIntOrStr | None = None, *, sort: str = 'confidence', limit: int | None = None, depth: int | None = None, context: int | None = None) SubmissionTreeNode[source]#

Get the comment tree for a submission.

Parameters:
  • submission_id (_YIntOrStr) – Submission ID.

  • comment_id (Optional[_YIntOrStr]) – Optional comment ID to start the tree at that comment.

  • sort (str) –

    Either: confidence (‘best’), top, new, controversial, old, random, qa, live.

    If not given or not a valid sort value (including empty string), the default is the ‘sort comments by’ preference of the logged in user. Otherwise, if there is no user context the default is confidence.

  • limit (Optional[int]) –

    Limit the number of comments to retrieve.

    The effective default seems to be 200, and the max value appears to be 500.

  • depth (Optional[int]) –

    The number of levels deep to retrieve comments for.

    A value of 0 is ignored. A value of 1 means to only retrieve top-level comments. A value of 2 means to retrieve comments one level deep. And so on.

    The maximum is 10, which is also the default. Any value higher than 10 is treated the same as 10.

  • context (Optional[int]) –

    If comment_id is specified, the number of parent comments to include.

    Specify an integer from 0 to 8. Any number higher than 8 is treated the same as 8.

Return type:

SubmissionTreeNode

Raises:
  • redditwarp.exceptions.RejectedResultException

    When specifying a comment using the comment_id parameter and the returned comment list is empty, so the specified comment was not returned.

    This happens when the comment existed at one point but is no longer available anymore and no trace of the comment exists in the comment tree whatsoever. This can occur when a deleted comment has no replies but your program still has a reference to the comment and tried to retrieve it.

  • redditwarp.http.exceptions.StatusCodeException

    • 404:
      • The specified submission ID does not exist.

      • The specified comment ID does not exist or the comment belongs to a submission other than the one specified.

async fetch_lenient(submission_id: _YIntOrStr, comment_id: _YIntOrStr | None = None, *, sort: str = 'confidence', limit: int | None = None, depth: int | None = None, context: int | None = None) SubmissionTreeNode[source]#

Get the comment tree for a submission.

Behaves similarly to fetch().

This method does the same thing as fetch() but doesn’t reject with a RejectedResultException when the specified comment ID could not be retrieved.

async more_children(submission_id: _YIntOrStr, child_ids: Iterable[_YIntOrStr], *, sort: str = '', depth: int | None = None, exact: bool = False) MoreCommentsTreeNode[source]#

Retrieve comments omitted from a comment tree.

When a comment tree is rendered, the most relevant comments are selected for display and the remaining comments are stubbed out with more-comment links: either ‘load more comments’ or ‘continue this thread’. This procedure is used to retrieve the comments represented by the ‘load more comments’ stubs.

You may only make one request at a time to this API endpoint. Higher concurrency will result in an error being returned.

Parameters:
  • submission_id (_YIntOrStr) –

  • child_ids (Iterable[_YIntOrStr]) – A list of comment IDs.

  • sort (str) – Same as on fetch().

  • depth (Optional[int]) – Same as on fetch().

  • exact (bool) –

    If true, only return the children requested, and not their sub-comments.

    This is kind of the same as specifying depth=1 but more-comment objects won’t be present.

    If this is specified with the depth parameter, this parameter will take precedence.

Return type:

MoreCommentsTreeNode

Raises:

redditwarp.http.exceptions.StatusCodeException

  • 403:

    The specified submission does not exist.