Batch Operations
Run many Reddit reads efficiently
ReddGrow has no single "batch" endpoint. Every Reddit read is an async job, so the efficient way to fetch many things at once is to create all the jobs up front and then poll them together.
How it works
Each read call returns 202 Accepted with a jobId right away, so creating jobs does not block. Poll GET /v1/reddit/jobs/{id} (free, 0 credits) for each one until it is completed or failed.
| Approach | Wall time | Cost |
|---|---|---|
| 5 reads, create then wait, one at a time | about 5 jobs in sequence | 5 calls at their normal price |
| 5 reads, create all, poll all | about the slowest single job | same credits |
Parallel jobs do not change what you pay. They change how long you wait.
Create many jobs, then poll
# Create three jobs
for sub in typescript javascript webdev; do
curl -s -H "x-api-key: $REDDGROW_API_KEY" \
"https://api.reddgrow.ai/agent/subreddits/$sub/posts?sort=new&limit=25"
done# --no-wait prints the jobId and exits
reddgrow reddit subreddits posts typescript --sort new --no-wait
reddgrow reddit subreddits posts javascript --sort new --no-wait
reddgrow reddit subreddits posts webdev --sort new --no-waitParallel reads in Node.js
const headers = { "x-api-key": process.env.REDDGROW_API_KEY };
async function readJob(url) {
const { jobId } = await fetch(url, { headers }).then((r) => r.json());
while (true) {
await new Promise((r) => setTimeout(r, 3000));
const job = await fetch(
`https://api.reddgrow.ai/v1/reddit/jobs/${jobId}`,
{ headers }
).then((r) => r.json());
if (job.status === "completed") return job.result;
if (job.status === "failed") throw new Error(job.error.message);
}
}
const subs = ["typescript", "javascript", "webdev"];
const results = await Promise.all(
subs.map((sub) =>
readJob(`https://api.reddgrow.ai/agent/subreddits/${sub}/posts?sort=new&limit=25`)
)
);Jobs and results are kept for 24 hours, so you can also create jobs now and collect them later.
Common pattern: search then read comments
A typical agent workflow is to search for relevant posts (1 credit per 7 results, so limit=20 is 3 credits), pick the best threads, then read their comments (2 credits each).
// Step 1: Search (3 credits for 20 results)
const search = await readJob(
"https://api.reddgrow.ai/agent/posts/search?q=typescript+generics&limit=20"
);
// Step 2: Read comments for the top 3 threads in parallel (6 credits)
const threads = await Promise.all(
search.data.children.slice(0, 3).map(({ data: p }) =>
readJob(
`https://api.reddgrow.ai/agent/posts/${p.subreddit}/${p.id}/comments?limit=50`
)
)
);Tips
- Creating a job reserves credits for the pages your
limitcan need, and unused pages are refunded when it finishes (seecreditsChargedon the job). A job that fails on ReddGrow's side (503) is refunded in full; on a Reddit403,404or429you pay for the pages fetched (at least 1) - Polling is free, so poll every 3 seconds rather than re-creating a job that looks slow
- Cost scales with pages, so set
limitto what you need. Post comments and subreddit feeds are a flat 2 credits whatever the limit