
Reddit User Scraper for JavaScript and Node.js: profile history as JSON objects
Use this repository to fetch a Reddit account's public history from Node.js. It is one ES module around the official apify-client package that runs the Reddit User Scraper and returns each post or comment as a plain object with its kind, subreddit, text, score, permalink and timestamps. The Actor does the paging, proxy routing and retrying on Apify's side, so your backend, worker or serverless handler only starts a run and reads rows; no Reddit OAuth app, refresh tokens or client secrets live in your code. It is the sort of chore we are happy to take off your hands, horns and all. Run the script directly and the rows also land in results.json and results.csv.
Actor: Reddit User Scraper — Profile Export · Publisher: Devil Scrapes · Also in Python: reddit-user-scraper-python
🔥 What you get
- Posts and comments in one row shape: a
kind column tells submissions from comments, and fields that only make sense for posts, such as the title, comment count and NSFW flag, are simply null on comments.
- Several accounts per run: list usernames or paste full profile URLs, and each one is collected in turn.
- Paging handled for you: the Actor follows Reddit's listing pages until it reaches your per-user limit or Reddit's own ceiling of about 1,000 items per listing.
- Sort and time window controls: request
new, hot, top or controversial, and narrow top or controversial to the past hour, day, week, month or year.
- Two timestamp formats:
created_utc as Unix seconds for arithmetic and posted_at as ISO-8601 for humans, plus a scraped_at time on every row.
- Missing accounts do not stop the batch: a deleted or suspended username is logged and skipped while the rest finish, and throttled requests are retried with backoff.
🎯 Use cases
Power a profile lookup in your own app
Expose an endpoint such as /reddit/:username that starts a run, waits for it and returns a summary to your frontend. The kind field lets the UI render posts and comments with different components.
Feed a trust and safety queue
When a report names a Reddit account, a worker can collect its recent public activity and attach the rows to the case in your moderation tool. Reviewers then see subreddits, scores and permalinks without leaving the ticket.
Watch an official or bot account for new activity
Schedule the module in a cron container, keep the last seen id per account and forward anything newer to Slack, Discord or a webhook. It suits keeping an eye on a brand account, a subreddit's bot or your own team's posts.
Ship public activity into a warehouse
A queue consumer can push each row into Postgres, BigQuery or a search index keyed on id, which stays unique across posts and comments. Re-running the same usernames simply upserts what changed.
⚡ Quick start
You need an Apify account and an API token from Console → Settings → Integrations. Apify's free plan includes monthly usage credit; this Actor's event prices are listed under Pricing below.
git clone https://github.com/devilscrapes/reddit-user-scraper-javascript.git
cd reddit-user-scraper-javascript
npm install
export APIFY_TOKEN=your_token_here
node index.js # uses input.json
node index.js my-input.json --out data --max-charge 2
The script starts the Reddit User Scraper — Profile Export, waits for it to finish, prints a link to the run in Apify Console and saves every result to results.json and results.csv. It exits with code 1 and the run's status message if the run fails.
🧩 The core call
The whole integration fits in four statements. call() resolves once the run is over and listItems() hands back the items from the run's default dataset.
import { ApifyClient } from 'apify-client';
const client = new ApifyClient({ token: 'YOUR_APIFY_TOKEN' });
const run = await client.actor('DevilScrapes/reddit-user-scraper').call({"usernames": ["AutoModerator"], "what": "both", "sortBy": "new", "maxResultsPerUser": 5, "proxyConfiguration": {"useApifyProxy": true, "apifyProxyGroups": ["RESIDENTIAL"]}});
const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log(items);
📥 Input
index.js forwards input.json unchanged. The example reads Reddit's AutoModerator bot with both enabled and a limit of five per user, which yields up to ten rows because posts and comments are collected in two separate passes. Keep the residential proxy group in the request; it matches the Actor's own default.
{
"usernames": [
"AutoModerator"
],
"what": "both",
"sortBy": "new",
"maxResultsPerUser": 5,
"proxyConfiguration": {
"useApifyProxy": true,
"apifyProxyGroups": [
"RESIDENTIAL"
]
}
}
| Field |
Type |
Required |
Default |
Allowed values |
usernames |
array |
yes |
["spez"] |
— |
what |
string |
no |
"submitted" |
submitted, comments, both |
sortBy |
string |
no |
"new" |
new, top, hot, controversial |
timeFilter |
string |
no |
"all" |
hour, day, week, month, year, all |
maxResultsPerUser |
integer |
no |
100 |
— |
proxyConfiguration |
object |
no |
{"useApifyProxy": true, "apifyProxyGroups": ["RESIDENTIAL"]} |
— |
📤 Output
You receive an array of objects, one per post or comment by the requested account. created_utc is an integer in seconds, title, url, num_comments and over_18 are null for comments, and body is Markdown text or null.
| Field |
Type |
Always present |
kind |
string |
yes |
id |
string |
yes |
username |
string |
yes |
subreddit |
string |
no |
title |
string or null |
no |
body |
string or null |
no |
url |
string or null |
no |
permalink |
string |
yes |
score |
integer |
no |
num_comments |
integer or null |
no |
over_18 |
boolean or null |
no |
created_utc |
integer |
yes |
posted_at |
string |
no |
scraped_at |
string |
no |
💰 Pricing
| Event |
Price (USD) |
| Actor start |
$0.2 |
| Result emitted |
$0.001 |
Prices as configured on 2026-08-20. The Actor page always shows the current price. Runs are billed to the Apify account that owns the token. Use --max-charge to cap what a single run can cost.
🛠️ Working with the data in JavaScript
The following snippet reads the saved rows, groups them by user and subreddit, and prints a table with counts, total score and the most recent activity date. It relies on Node.js built-ins only.
import { readFile } from 'node:fs/promises';
const rows = JSON.parse(await readFile('results.json', 'utf8'));
const groups = new Map();
for (const row of rows) {
const key = `${row.username} / r/${row.subreddit ?? 'unknown'}`;
const g = groups.get(key) ?? { posts: 0, comments: 0, score: 0, latest: 0 };
if (row.kind === 'submission') g.posts += 1;
else g.comments += 1;
g.score += row.score ?? 0;
g.latest = Math.max(g.latest, row.created_utc);
groups.set(key, g);
}
const table = [...groups]
.sort((a, b) => b[1].posts + b[1].comments - (a[1].posts + a[1].comments))
.map(([where, g]) => ({ where, ...g, latest: new Date(g.latest * 1000).toISOString() }));
console.table(table);
❓ FAQ
How is this different from Reddit's official API?
The official route means registering an app, storing a client secret and handling tokens and rate limits yourself. Here your service holds only an Apify token, and the Actor returns the same public profile items as typed rows.
Can my Lambda or Vercel handler run it?
Yes, if the handler may stay alive until the run finishes. Under strict time limits, begin the run with start() and collect the dataset later through an Apify webhook pointed at another endpoint.
How do I pass profile links instead of usernames?
Put them straight into usernames. The Actor accepts full profile URLs as well as bare names, so text pasted by your users usually works without cleanup.
How can I cap spend when users trigger runs?
Keep maxResultsPerUser small and pass --max-charge, or maxTotalChargeUsd in the call options of your own code. A run costs its start fee plus one result charge per item written.
Are there accounts it cannot read?
Deleted or suspended accounts are skipped with a log entry, and anything posted in private subreddits is invisible on public profiles. Items other people wrote on the user's posts are out of scope.
🧯 Troubleshooting
Set APIFY_TOKEN first: export the token in the same shell, or put it in a local .env file your shell loads. Never commit it.
- Run finished with
FAILED or ABORTED: open the printed Console link; the run log says why. Input validation errors name the field.
- Fewer rows than expected: a
--max-charge cap also limits how many results can be charged. Raise the cap or lower the limits in your input.
- Something looks wrong in the data: open an issue on the Actor page so the maintainers see it.
🔗 More from Devil Scrapes
Related Actors:
MIT licensed example code. The Actor itself runs on Apify and is maintained by Devil Scrapes. Not affiliated with Reddit, Inc..