Search Reddit threads in a subreddit, with post text
Automatically search Reddit threads in a subreddit, with post text on reddit.com. Search one subreddit for a query and get one page of matching threads in Reddit's order, each with title, subreddit, permalink, upvotes, comment count, creation time, flair and the post's full text. Sort and time window are configurable; pass the returned after value to read the next page (null on the last one). Requires being signed in to Reddit. A subreddit that refuses the search (private, banned) fails with its HTTP status. To search several subreddits or queries, run the script once per pair.
Input
query requiredSearch text, in Reddit's search syntax.
subreddit requiredSubreddit name, with or without the r/ prefix.
sort optionaltime optionalafter optionalPass the after value of the previous answer to read the next page.
limit optionalThreads per page.
Default: 25Output
after requiredCursor for the next page; null on the last page.
query requiredthreads requiredsubreddit requiredcount optionalFAQ
Get Reddit thread
Fetch a Reddit thread by its id or URL: the post (title, text, author, score, upvote ratio, comment count, type, link) and its comments in thread order, each with author, text, score, date, permalink and nesting depth. Needs a browser signed in to Reddit. By default it returns the first page of comments Reddit shows when the thread opens; set all_comments to expand every "more replies" and get the whole tree. num_comments counts deleted and removed comments too, so the list can be shorter than that number even when it is complete. sort picks Reddit's own comment order (best, top, new, controversial, old, Q&A).
Get Reddit subreddit threads
List a subreddit's threads by Reddit's native sort (best/hot/new/top/rising). "new" is chronological (filter with `since`); "top" takes a `time` window (hour…all); others paginate by `limit`. Returns url, title, author, score, num_comments, created, post_type, and body — the post's full text (never truncated; null for link/image posts). `limit` is a maximum, not a guarantee: fewer matching threads returns what exists.
Search Reddit
Search posts across all of Reddit, with Reddit's own sort and time window. Returns count and threads (id, url, title, author, subreddit, score, num_comments, created, nsfw, preview_text) in the order Reddit lists them. `limit` is a maximum: fewer matching posts return what exists, and no match returns count 0. Reddit matches loosely, so under the `top` sort a heavily upvoted post only loosely related to the query can come before closer matches; use the default `relevance` sort when on-topic results matter.
