How to get a Reddit post's comments as JSON when .json returns 403
By Hayden Barnett · · 5 min read
- Comments
- Python
The old trick of adding .json to a Reddit post URL now returns a block page when the request comes from a script on a server. To get a public post and its comment tree as JSON, send the post URL to one GET instead:
export FETCHPROOF_API_KEY=fp_live_xxx
curl -s "https://api.fetchproof.com/v1/reddit/post/comments?url=https%3A%2F%2Fwww.reddit.com%2Fr%2FIAmA%2Fcomments%2Fz1c9z%2Fi_am_barack_obama_president_of_the_united_states%2F" \
--header "x-api-key: $FETCHPROOF_API_KEY"
That URL is the published example on the post comments endpoint. url is the only required parameter, and it is the normal post link from your browser bar, URL-encoded. You do not need a Reddit app, OAuth token or User-Agent string. The only key is the Fetchproof key in x-api-key.
Why the .json URL stops working
Every older tutorial sends a GET to https://www.reddit.com/r/<sub>/comments/<id>/<slug>/.json and reads the two listings that come back. Run that from a cloud machine today and you get something else. On 30 Nov 2026 we sent that request for the post above from a server, with a descriptive User-Agent. Reddit answered 403 with content-type: text/html, and the page says the request was “blocked by network security.”
The status matters less than the body. The response is HTML, not JSON, so response.json() throws and a loop over data["children"] never runs. Developers in r/redditdev report the same pattern: the script works on a laptop and breaks once it is deployed to Google Cloud or Vercel. Changing the User-Agent does not reliably fix it.
The official route is Reddit’s OAuth Data API, which PRAW wraps. As of Nov 2026 it has no self-service sign-up: new apps need Reddit’s approval under its Responsible Builder Policy. That is a long wait if all you want is the comments under a handful of public posts. The Reddit API alternative guide covers the wider set of calls (subreddit feeds, search and comments). This post goes deep on the comments.
What comes back
The body has three parts: post, comments and more. Field names below match the published schema. The example is shortened.
{
"success": true,
"credits_remaining": 99,
"credits_charged": 1,
"post": {
"id": "z1c9z",
"subreddit": "IAmA",
"title": "I am Barack Obama, President of the United States -- AMA",
"author": "PresidentObama",
"score": 14761,
"num_comments": 24213,
"created_utc": 1346270496,
"url": "http://www.reddit.com/r/IAmA/comments/z1c9z/i_am_barack_obama_president_of_the_united_states/"
},
"comments": [
{
"id": "hgri5xl",
"name": "t1_hgri5xl",
"parent_id": "t3_z1c9z",
"author": "invaderzz",
"body": "How's it going Obama?",
"score": 2,
"created_utc": 1634319533,
"created_at_iso": "2021-10-15T17:38:53.000Z",
"url": "https://www.reddit.com/r/IAmA/comments/z1c9z/i_am_barack_obama_president_of_the_united_states/hgri5xl/",
"replies": { "items": [] }
}
],
"more": { "has_more": false, "cursor": null }
}
comments holds the top-level comments. Each one carries its replies in replies.items, and each reply has its own replies.items, so the tree nests as deep as the thread does. parent_id tells you where a comment hangs: a t3_ prefix means it replies to the post, and a t1_ prefix means it replies to the comment with that name. Deleted comments keep their place in the tree with author set to [deleted] and a body such as [removed], so filter them out if you only want real text.
created_utc is Unix seconds, and created_at_iso is the same moment as an ISO 8601 string. Author flair is not included.
post.num_comments is Reddit’s own count for the thread. It can include removed comments and branches Reddit collapses behind “load more comments”, so the number of comments you collect can be lower than it.
If you only need the post (title, selftext, score, num_comments), the post endpoint returns it without the comments.
Python: flatten the tree into a CSV
The standard library is enough. This walks the tree depth first, keeps each comment’s depth and parent, and follows more.cursor while more.has_more is true. The samples on this page use the placeholder fp_live_xxx.
import csv
import json
import os
import urllib.parse
import urllib.request
POST_URL = "https://www.reddit.com/r/IAmA/comments/z1c9z/i_am_barack_obama_president_of_the_united_states/"
def fetch(cursor=None):
endpoint = "https://api.fetchproof.com/v1/reddit/post/comments?url=" + urllib.parse.quote(POST_URL, safe="")
if cursor:
endpoint += "&cursor=" + urllib.parse.quote(cursor, safe="")
request = urllib.request.Request(
endpoint,
headers={"x-api-key": os.environ["FETCHPROOF_API_KEY"]},
)
with urllib.request.urlopen(request, timeout=90) as response:
return json.load(response)
def walk(comments, depth=0):
for comment in comments:
yield depth, comment
yield from walk(comment["replies"]["items"], depth + 1)
rows, cursor = [], None
while True:
body = fetch(cursor)
for depth, c in walk(body["comments"]):
if c["author"] == "[deleted]":
continue
rows.append([c["id"], c["parent_id"], depth, c["author"], c["score"], c["created_at_iso"], c["body"]])
if not body["more"]["has_more"]:
break
cursor = body["more"]["cursor"]
with open("comments.csv", "w", newline="", encoding="utf-8") as handle:
writer = csv.writer(handle)
writer.writerow(["id", "parent_id", "depth", "author", "score", "created_at", "body"])
writer.writerows(rows)
print(len(rows), "comments written")
quote encodes the post link and the cursor for you. urlopen raises on a non-success status, so a bad key or an upstream failure stops the script instead of writing a half-empty file. Keep parent_id in the CSV and you can rebuild the conversation later, or feed one thread at a time to a model for summarising.
Node: top comments by score
Node 18 and later include fetch:
const postUrl = "https://www.reddit.com/r/IAmA/comments/z1c9z/i_am_barack_obama_president_of_the_united_states/";
const response = await fetch(
`https://api.fetchproof.com/v1/reddit/post/comments?url=${encodeURIComponent(postUrl)}`,
{ headers: { "x-api-key": process.env.FETCHPROOF_API_KEY } },
);
if (!response.ok) throw new Error(`Reddit comments failed: HTTP ${response.status}`);
const body = await response.json();
const flat = [];
const walk = (list, depth = 0) => {
for (const comment of list) {
flat.push({ ...comment, depth });
walk(comment.replies.items, depth + 1);
}
};
walk(body.comments);
const top = flat
.filter((comment) => comment.author !== "[deleted]")
.sort((a, b) => (b.score ?? 0) - (a.score ?? 0))
.slice(0, 10);
for (const comment of top) console.log(comment.score, comment.depth, comment.body.slice(0, 80));
score can be null on some comments, hence the ?? 0. To page, read body.more.cursor and repeat the request with &cursor=${encodeURIComponent(cursor)} added, exactly as the Python loop does.
Long cursors: use POST
The cursor is opaque. Send back exactly the one you received, and never join two. If a cursor gets long enough to be awkward in a URL, the POST version of the same operation takes the same fields as a JSON body:
curl -s -X POST "https://api.fetchproof.com/v1/reddit/post/comments?url=https%3A%2F%2Fwww.reddit.com%2Fr%2FIAmA%2Fcomments%2Fz1c9z%2F" \
--header "x-api-key: $FETCHPROOF_API_KEY" \
--header "content-type: application/json" \
--data '{"cursor": "PASTE_MORE_CURSOR_HERE"}'
The response has the same shape as the GET.
From n8n or an MCP client
In n8n, one HTTP Request node with the x-api-key header and a url query parameter does it. That setup is in the n8n post. From an MCP client the tool is reddit_post_comments, so an agent can read a thread when you paste a link. Server setup is in the MCP docs. Every Reddit route is on the Reddit API page.
What a call costs
Each post comments call costs 1 credit by default, so a thread that fits in one response costs one credit and each extra cursor page costs another. Errors, blocked or timed-out requests, invalid requests and cache hits cost nothing. A not-found or empty result is charged only where that operation’s published cost says so. For this operation the endpoint page lists a response with no comments at 0 credits. Read credits_charged on each body if you want to log spend.
New accounts get 100 free credits, with no card. Freelance is $27 for 25,000 credits. Business is $297 for 500,000 credits. Credits are prepaid and do not expire. Details are on the pricing page, and how that compares with a monthly plan is in prepaid credits vs monthly subscriptions.
FAQ
Do I need a Reddit account, app or OAuth token?
No. The request carries only the Fetchproof key in x-api-key. Nothing logs in to Reddit as you.
Does it expand every “load more comments” branch?
No. You get the tree as Reddit serves it for the post, with nested replies under replies.items. Branches Reddit collapses are not expanded, which is one reason your total can be lower than num_comments. When more top-level comments are available, more.has_more is true and more.cursor gets the next batch.
Can it read private subreddits?
It reads public posts only. A post in a private community does not come back.
Is it real time?
Close to it, but not guaranteed. Comments can arrive a little behind Reddit, so a comment posted seconds ago may not be in the response yet.
Can I pass an old.reddit.com or short link?
An old.reddit.com link works when it has the usual reddit.com/r/<subreddit>/comments/<id>/ form. Short redd.it links and app share links do not carry that path, so open them in a browser first and copy the full post link.
Related guides and endpoints
- Endpoint Reddit Post Comments GET /v1/reddit/post/comments
- Endpoint Reddit Post Comments POST /v1/reddit/post/comments
- Endpoint Reddit Post GET /v1/reddit/post
- Guide How to get Reddit posts and comments without the official API Read public subreddit posts, search a subreddit and pull full comment threads as JSON, with no Reddit app approval or OAuth. 1 credit per call.
- API Reddit API All 8 Reddit endpoints, with costs and sample responses.
Try it with 100 free credits
Sign up with an email address, no card. Credits never expire. Errors, invalid requests and cache hits cost 0 credits, and each endpoint page lists exactly what it charges.