How to search Reddit subreddit posts by keyword and timeframe
Search one subreddit's posts by query, sort and timeframe, then shortlist threads from a table of titles, scores, comment counts and permalinks
On this page
You need to scan 30 r/Fitness discussions about push ups to decide which threads merit a roundup. One call to anyapi.reddit.subreddit_search takes a subreddit name, a query, a sort order and a timeframe, and returns post metadata you can shortlist from
The deliverable is a worksheet with one row per post and these columns: title, author, score, numComments, createdUtc, permalink, url and a shortlist note you write yourself. Values here are placeholders showing the shape, since no run has been executed for this guide
| Title | Author | Score | numComments | createdUtc | permalink | url | shortlist_note |
|---|---|---|---|---|---|---|---|
| (post title) | (username) | (integer) | (integer) | (epoch seconds) | (thread path) | (destination link) | (your note) |
Sort the finished sheet by score or by numComments, and record in that note why a thread made the cut
What the search takes
subreddit is the one required field and it goes in without the r/ prefix, so the community URL reddit.com/r/Fitness becomes Fitness. The contract also documents query, sort, timeframe, cursor and requireFields. sort accepts relevance, hot, top, new or comments. timeframe narrows the window to hour, day, week, month or year, and the schema has one setting beyond those for no time limit. cursor comes from a previous response, and requireFields names output fields the request must be able to return
The catalog listing shows the tool, which is called through POST /v1/runs with toolId anyapi.reddit.subreddit_search.
Example values, invented for this guide and replaced by your own on the real run:
| Field | Example value |
|---|---|
subreddit | Fitness |
query | push ups |
sort | top |
timeframe | month |
The pagination limit on the first request
Include nextCursor in requireFields on the first request only if you will fetch more than the first page. Leave it out and a cheaper source that cannot paginate may serve, and its nextCursor is null, so there is no next page to ask for. Naming it can raise the price: when the cheapest source cannot return a named field, a dearer source serves, and you are quoted and charged its price. A combination that no single source returns together is refused as invalid input, with no charge
That setting applies to the first page only. Later pages stay with the source that the first page chose, at the price it was quoted. For a 30-thread scan, start without nextCursor in requireFields and look at how many rows the first page returns before planning a walk
Reading the output fields that drive the shortlist
found says whether the source returned a result. When it is false, reason carries not_found, the source returned nothing for the target, and the call counts as a success rather than an error. When it is true, data.posts holds the rows and data.nextCursor holds an opaque cursor or null
Five fields drive the decision:
score: net score, upvotes minus downvotes, at fetch timenumComments: total comments on the postcreatedUtc: creation time as UTC epoch seconds, multiplied by 1000 for a JS Datepermalink: the canonical reddit.com thread path to open and readurl: the destination link, external for a link post and the thread URL for a self post
title, author, id, subreddit and nsfw fill the rest of the row. isLocked, isArchived and selftext are optional. They are absent when the serving source does not report them, which means unknown rather than false, so a missing isLocked field is not the same as an open thread. A true isLocked blocks new comments, and a true isArchived blocks new comments and votes
If a shortlisted thread needs its replies, the guide on listing Reddit post comments covers that call
The agent prompt
Set up https://purrkey.app/SKILL.md, then use Purrkey to search posts in
one subreddit and return a shortlist table. Check the current inputs and
price of anyapi.reddit.subreddit_search before running anything. Make one
call with subreddit Fitness, query "push ups", sort top and timeframe
month. Leave nextCursor out of requireFields because this run reads the
first page only. Return a table with title, author, score, numComments,
createdUtc, permalink, url and an empty shortlist_note column. Sort the
rows by score, highest first, and stop if found is false.Replace the subreddit, query, sort and timeframe in the prompt with your own. Thirty threads is the target for the roundup scan, so raise the call count in the prompt if the first page comes back short
Estimated tool cost
Prices come from the Purrkey catalog, price revision anyapi-catalog-2026-11-05, read on November 13, 2026. The unit is max_call: "Maximum per call. Successful runs settle at the actual AnyAPI charge." The totals are ceilings, not settled charges
| Step | Formula | Unit price | Planned quantity | Total |
|---|---|---|---|---|
| Single subreddit search | calls x max price | $0.0012 per call | 1 | $0.0012 |
| Ten subreddit searches | calls x max price | $0.0012 per call | 10 | $0.012 |
Model fees for the agent are not counted. A request that names a field the cheapest source cannot return is served by a dearer source at its quoted price, above the figure in the table
Next action
Open the Reddit tools page and check the current input schema and price for anyapi.reddit.subreddit_search before the first call
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 search posts inside one subreddit by keyword?
Pass subreddit without the r/ prefix and add query. sort and timeframe narrow the result set, and the response returns post metadata under data.posts.
What inputs does anyapi.reddit.subreddit_search take?
subreddit is required. The contract also documents query, sort, timeframe, cursor and requireFields.
How do I get the next page of subreddit search results?
Include nextCursor in requireFields on the first request, then pass the returned nextCursor back as cursor. If you leave it out, a cheaper source that cannot paginate may serve and return nextCursor as null.
What do the score and numComments fields mean?
score is the net score, upvotes minus downvotes, at fetch time. numComments is the total number of comments on the post.
What does a found false answer mean?
It means the source returned nothing for the target. The response carries reason as not_found, and the call is a success rather than an error.
How much does it cost to run ten subreddit searches?
At most $0.012 at $0.0012 per call. The figures are ceilings, and agent model fees are not counted.
Why is isLocked missing from some rows?
It is absent when the serving source does not report it, which means unknown rather than false.
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.