RedditapisRedditapis
Posts

Get Every Reddit Comment, Including Collapsed Replies

Read a Reddit thread with its "load more comments" and "continue this thread" replies expanded, as JSON, in one call.

GET/api/reddit/post/{id}/comments/expanded$0.02 / call

The comment tree of a post with Reddit's collapsed replies read in.

Reddit never sends a big thread whole. Where it stops, it leaves a kind: "more" stub in the tree: "load more comments" (a list of the hidden comment ids) or "continue this thread" (a branch cut at Reddit's depth limit). /api/reddit/post/{id}/comments returns the tree as Reddit sent it, stubs included. This endpoint reads those stubs and puts the comments back where the stubs were.

Measured on a 3,117-comment thread: one read of the tree returned 3 comments and a stub hiding 2,864. Each expansion read here brings in up to 100 of those.

Path Parameters

ParameterTypeRequiredDescription
idstringYesReddit post id (e.g. 1sgjld3). A t3_ prefix is optional.

Query Parameters

ParameterTypeRequiredDescription
limitnumberNoTop-level comments in the first read, 1-500 (default 100)
sortstringNoconfidence, top, new, controversial, old or qa, applied to the thread and to every expansion read
max_expansionsnumberNoMost expansion reads this call may make, 1-9 (default 9). Each reads up to 100 hidden comments or one "continue this thread" branch.
afterstringNoThe after cursor from a previous answer for the same post. The call then reads only the comments that were still collapsed. limit and sort come from the cursor and cannot be sent with it.

depth is not accepted here: a depth cap asks Reddit to collapse branches, which is the opposite of this endpoint. Use /api/reddit/post/{id}/comments for a depth-capped tree.

meta.sort_used names the sort the tree was read in; when no sort was sent it is the post's suggested sort, else confidence, and meta.sort_defaulted is true.

Example

curl -H "Authorization: Bearer $TOKEN" \
  "https://api.redditapis.com/api/reddit/post/1sgjld3/comments/expanded?sort=top"
const response = await fetch(
  "https://api.redditapis.com/api/reddit/post/1sgjld3/comments/expanded?sort=top",
  { headers: { Authorization: "Bearer TOKEN" } }
);
const { post, comments, expansion } = await response.json();
import requests

response = requests.get(
    "https://api.redditapis.com/api/reddit/post/1sgjld3/comments/expanded",
    params={"sort": "top"},
    headers={"Authorization": "Bearer TOKEN"},
)
data = response.json()

Response Shape

{
  "post": { "...": "same shape as /api/reddit/post/{id}" },
  "comments": [
    { "kind": "t1", "data": { "...": "Reddit's comment, with replies nested as Reddit nests them" } }
  ],
  "meta": { "limit_used": 100, "depth_used": null, "sort_used": "top", "max_expansions": 9 },
  "expansion": {
    "upstream_calls": 9,
    "max_expansions": 9,
    "stubs_expanded": 4,
    "comments_added": 812,
    "remaining_more_stubs": 1,
    "remaining_more_comments": 2052,
    "complete": false,
    "stopped_reason": "call_cap"
  },
  "after": null,
  "listing_status": "truncated"
}

comments has the same tree shape as /api/reddit/post/{id}/comments, so code that walks that tree walks this one. A stub this call did not reach stays where it was, so kind: "more" still means "there is more here".

expansion fieldMeaning
completetrue when no more stub is left in the tree. On a tree read from the post's page (X-Read-Source: html_thread) it also needs the tree to reach the post's own comment count
unaccounted_commentsOnly on a tree read from the post's page with no stub left: how many comments Reddit counts that the tree does not show. Reddit counts removed and deleted comments it never shows, so this is usually not a cut, but the tree cannot prove that
remaining_more_commentsHow many comments the stubs still left in the tree hide, by Reddit's own count
stopped_reasoncall_cap (the call used all of max_expansions), upstream_error (an expansion read failed), budget (the call's time budget ran low, so no further read was started), unreadable_stub (the stubs left carry no ids Reddit can expand) or null when complete

A thread larger than one call can expand still comes back usable and says how much is left. With the default max_expansions of 9, one call reads in up to about 900 hidden comments (9 reads of up to 100). On a very large thread the rest stay in their more stubs, and remaining_more_comments says how many. To read the rest, call again with after set to the answer's after cursor, and repeat until after is null. sort decides the order of the visible thread: top brings the most-voted branches, new the latest replies (without sort, Reddit's own default order applies). Inside one collapsed part, hidden comments are read oldest first (by comment id), so a later call resumes exactly where the last one stopped, however Reddit reshuffles that part in between. The completeness fields (listing_status, exhausted_reason) read the same way as on the comment tree page.

Reading a very large thread

Each call with after costs the same $0.02 and reads up to max_expansions more stubs, starting from a fresh read of the thread. Its comments holds only the comments it newly read, not the whole tree again. Each top-level item carries the parent_id it belongs under (the post's t3_ id or a comment's t1_ id from an earlier answer), so you attach them where they go. Its expansion adds continued_from_cursor: true. Two more fields appear only when they apply:

expansion fieldMeaning
stubs_gone_since_cursorCollapsed parts named by the cursor that are no longer in the thread (removed, or re-collapsed differently by Reddit)
cursor_truncatedThe list of collapsed parts was too long to fit one cursor, so the last few were left out of after
moved_from_stubComments that left a collapsed part since the cursor (Reddit moved them into the visible replies) and are returned in this call so none is missed. One of them can be a comment an earlier call already returned: dedupe by id
progressfalse when a continuation read nothing new (an upstream failure, or a time budget spent before the first read). Wait and retry with the after it returns; a loop that repeats until after is null must stop on this

The cursor is opaque and holds no comment text. Use it only with the post it came from. Any other value is refused with 400 (field: "after") before Reddit is called.

Errors

StatusWhen
400The id is not a valid post id, depth was sent, sort is not one of the listed values, or limit or max_expansions is out of range; after is not a cursor from this endpoint, belongs to another post, or was sent with limit or sort
404No post with that id exists
429EXPANDED_COMMENTS_CONCURRENCY: your account already has 2 expanded reads running; a third waits up to 3 seconds, then gets this with Retry-After: 2. Not billed. See Rate limits

Price

A flat $0.02 per call: the thread read plus up to 9 expansion reads, the same per-read basis as deep comment search. If an expansion read fails, or the call runs low on time, you get the partial tree with stopped_reason: "upstream_error" or "budget" and the call is not billed. A tree left with unreadable_stub is billed, because every read the call could make was made, unless the tree came from the post's page (X-Read-Source: html_thread) and the call added no comment: it only re-read the same tree, so it is not billed. For a thread with no stubs, /api/reddit/post/{id}/comments returns the same tree at the standard read price, so check that first when you do not know the thread's size.

Independent third-party API for developers and researchers. Not affiliated with, endorsed by, or sponsored by Reddit, Inc.

On this page