How to fetch Reddit subreddit posts by sort order
Use Purrkey's Reddit subreddit_posts tool to fetch one page of hot, new, or top posts with scores, comment counts, and links, then continue with a cursor for a second page
On this page
You have a newsletter shortlist to fill from one subreddit and need 50 posts of the week, with titles, scores, comment counts and permalinks, so you can choose five discussion threads from them. One call to anyapi.reddit.subreddit_posts returns a single page of a subreddit listing, and the cursor in that response fetches the page after it
No run has been executed for this guide. The worksheet below is a design and its values are placeholders
Example request and the worksheet design
Example inputs for the task. The subreddit name goes in without the r/ prefix
| Field | Value |
|---|---|
subreddit | programming |
sort | top |
timeframe | week |
limit | 50 |
cursor | omitted, so this is the first page |
The deliverable is one row per post, then a note that marks the five threads worth writing about. Values here are placeholders showing the shape
| id | title | author | score | numComments | createdUtc | permalink | url | subreddit | shortlist_note |
|---|---|---|---|---|---|---|---|---|---|
| (post id) | (post title) | (username) | (net score) | (comment total) | (epoch seconds) | /r/programming/comments/... | (destination link) | programming | keep, review or skip, with a one-line reason |
What the call takes
subreddit is the one required field, entered without the r/ prefix. sort accepts hot, new or top and defaults to hot. limit takes an integer from 1 to 100 and defaults to 25. timeframe applies only when sort is top, taking hour, day, week, month, year or the widest option in the contract; it is ignored for hot and new, and omitting it defaults top to the current day. cursor is the opaque string from a previous response's nextCursor, omitted for the first page. after is a legacy pagination alias marked deprecated, so leave both it and cursor out on the opening call
requireFields is optional. Omit it and routing is unchanged, with the cheapest source serving. Name output fields such as isArchived, isLocked or selftext and the request is served only by a source that returns each named field. That can raise your price: when the cheapest source cannot return a named field, a dearer source serves and you are quoted and charged its price. A combination no single source returns together is refused as invalid input, with no charge
Treat this list as what the task needs rather than a closed description of the schema. Check the current input definition before sending anything outside it
Step 1: one page, then the cursor
limit is a request, not a promise. Some sources honor it; others always return their whole page of about 25 posts. A page is never trimmed after the call, so a request for 50 can come back with roughly 25 rows
The lever sits next to that limit: read nextCursor from the response and pass it back as cursor to continue exactly where the response ended. nextCursor is null when there are no more results. At about 25 rows per page, a three-call walk reaches roughly 75 rows, which leaves headroom for 50. A larger limit does not change what a source returns; the cursor is the mechanism for more rows
If you name requireFields on a walk, it applies to the first page only. Later pages stay with the source that the first page chose, at the price that page was quoted
Reading the output for the shortlist
The response has found and data. found is false with reason set to not_found when there is no result, and the contract states that a found: false answer is a successful call, not an error
When data is present it holds posts and nextCursor. Each post carries id, title, author, score, numComments, createdUtc, permalink, url and subreddit, plus authorId, upvoteRatio, nsfw, selftext and, where the serving source reports them, isArchived and isLocked
Four fields drive the shortlist. score is the net score at fetch time, so it depends on when you pulled the page. numComments is the total comment count. createdUtc is a UTC epoch timestamp in seconds, so multiply by 1000 for a JS Date. permalink is the canonical thread path on reddit.com, while url is the post's destination link, which is the external URL for a link post and the thread URL for a self post. A newsletter that sends readers to the discussion uses permalink; one that sends them to whatever the post links to uses url
isArchived and isLocked are worth naming only if your note depends on them. Absent means unknown rather than false, because the source that served the request may not report them. If a thread's openness to new comments matters, name them in requireFields and accept the price change
For the comments on a thread you shortlist, the companion guide at https://purrkey.app/blog/list-reddit-post-comments covers that step
The agent prompt
Set up https://purrkey.app/SKILL.md, then use Purrkey to fetch the week's
top posts from r/programming and build a shortlist table. Check the
current inputs and price of anyapi.reddit.subreddit_posts before running
anything. Call it with subreddit "programming", sort "top", timeframe
"week" and limit 50, with no cursor and no after field. If the response
returns fewer than 50 rows and nextCursor is not null, call again with
the nextCursor value as cursor, up to three calls in total. Return a
table with id, title, author, score, numComments, createdUtc, permalink,
url, subreddit and shortlist_note. Set shortlist_note to a one-line
reason to keep, review or skip the post for a programming newsletter.
Do not invent posts, and leave a field empty when the response did not
return it.Replace that subreddit value with your own subreddit. Keep the first run to one call so you can see the page size the serving source returns before planning a walk
Estimated tool cost
The tool is anyapi.reddit.subreddit_posts called through POST /v1/runs with toolId anyapi.reddit.subreddit_posts. Prices are read through the Purrkey catalog on November 13, 2026, price revision anyapi-catalog-2026-11-05. The unit is max_call: "Maximum per call. Successful runs settle at the actual AnyAPI charge." The totals below are ceilings
| Step | Formula | Unit price | Planned quantity | Total |
|---|---|---|---|---|
| First page | 1 call x max price | $0.0012 per call | 1 | $0.0012 |
| Three-page cursor walk | 3 calls x max price | $0.0012 per call | 3 | $0.0036 |
The two rows are alternative plans, not a sum. Both assume no requireFields, since a named field the cheapest source cannot return routes to a dearer source whose price is quoted and charged instead. Model fees for the agent are not counted
Fetch the first page
Make one call for the week's top posts in your subreddit, then decide from the row count and nextCursor whether a second page is needed. The tool page is https://purrkey.app/tools/reddit?q=subreddit_posts
Get started by giving this to your agent
- Claude Code
- Codex
- Gemini CLI
- Cursor
- GitHub Copilot
Set up https://purrkey.app/SKILL.md, then use Purrkey to show me what I can do with Reddit.FAQ
How do I fetch the top posts of the week from a subreddit?
Call anyapi.reddit.subreddit_posts with subreddit set to the name without the leading r/, sort set to top and timeframe set to week. The response returns a page of posts with titles, scores, comment counts and permalinks.
What inputs does anyapi.reddit.subreddit_posts take?
subreddit is required. Optional fields are sort (hot, new or top, default hot), limit (1 to 100, default 25), timeframe when sort is top, cursor copied from a previous response's nextCursor, and requireFields naming isArchived, isLocked or selftext.
How do I get a second page of subreddit posts?
Pass the nextCursor value from the first response back as cursor. nextCursor is null when there are no more results, and after is a deprecated pagination alias to omit.
Why did a limit of 50 return only about 25 posts?
Some sources honor the requested limit while others always return their whole page of about 25 posts, and a page is never trimmed after the call. Continue from nextCursor rather than raising the limit.
What is the difference between permalink and url in the output?
permalink is the canonical reddit.com thread path, while url is the post's destination link: the external URL for a link post and the thread URL for a self post.
How much does it cost to fetch subreddit posts?
The catalog lists anyapi.reddit.subreddit_posts at up to $0.0012 per call under the max_call unit, which is a maximum that settles at the actual AnyAPI charge. One page is one call, and a three-page cursor walk is three calls at most $0.0036.
What does found false mean in the response?
It means there is no result, with reason set to not_found, and the contract states that this is a successful call rather than an error.
Next step
Try this with Reddit
The tool directory lists every endpoint with its current price. Inspect the inputs there, then let your agent run a small batch before scaling up.