ナビゲーションにスキップ

How do I turn a Reddit discussion into product questions backed by original comments?

To turn a Reddit discussion into product questions, take the post ID from the selected post link, add the t3_ prefix and fetch the comments with reddit.app.fetch_post_comments. Export the saved responses to CSV with exact wording, parent relationships and sources. After review, give the product or content team the actionable questions and the conditions under which each question arises.

For example, if someone says a phone edit did not appear on desktop, record both devices and the order of steps. If a reply adds a version or an offline condition, save the reply with the parent comment before anyone tries to reproduce the issue.

Run a research round

  1. Select the thread. Start from an existing permalink, or use the community shortlist to choose threads and record selection reasons.
  2. Read one comment page. Review the post and the returned replies, and save the sources. Decide which questions need replies or additional pages.
  3. Build the source table. Export comment text, identifiers, reply relationships and available counters. When merging saved pages, keep unique comments separate from repeated observations of the same comment.
  4. Review excerpts. For each selected comment, record a theme, a verbatim quotation and a review reason. Add the comment to the backlog after the quotation is confirmed in the original response.
  5. Choose next actions. Sort each issue into one of four groups: already answered in the thread, documentation work, reproduction, or verification.

To hand the review to an assistant connected to BeatAPI, use this instruction:

Review the saved comments for this thread and organize note-sync questions and experiences. Keep original wording, the thread link and parent context. Describe the conditions and verification needed. Give me actionable questions rather than only sentiment labels.

Match files to deliverables

FileUse
Per-page comment CSV and original responseReview text, relationships and sources
comments.csv / observations.csvDistinguish unique comments from repeated observations and later changes
review-labels.jsonHuman-selected themes, excerpts and review reasons
question-backlog.jsonReviewed questions and sources, with unreviewed counts retained
A separate action copyAdd proposed_action and verification_needed while preserving generated source records

For example, “Which setting supports offline use?” becomes a documentation question. A report of sync failure on one device starts as an experience to reproduce. Comment scores show engagement; a comment score does not establish a defect.

Steps 1–7 below cover retrieval, export, merge and excerpt review. The local steps reuse saved responses and add no charge; estimate new comment or reply retrieval with current pricing.

1. Confirm input and scope

Take the ID after /comments/ in the post URL and prefix the ID with t3_. Replace the syntax sample t3_abc123 with your real ID. Limit the first run to one page. Check the current inputs and price of data:reddit.app.fetch_post_comments with the free /v1/capabilities/inspect endpoint. Each platform call is charged at the current price; local conversion adds no charge.

If you copied a post or comment permalink, use the local request preparer to extract the post ID; the last ID in a comment permalink names a comment, not the post. The preparer writes a first-page request body and does not send the request.

2. Save one raw response

mkdir reddit-query-1 && \
curl --fail-with-body -sS https://api.beatapi.io/v1/social-data/call \
-H "Authorization: Bearer $BEATAPI_API_KEY" \
-H 'Content-Type: application/json' \
-d '{"action":"reddit.app.fetch_post_comments","params":{"post_id":"t3_abc123","sort_type":"NEW","need_format":false,"after":""}}' \
-D reddit-query-1/response.headers \
-o reddit-query-1/reddit-comments.json

If the HTTP request fails, keep the error and do not export. After an HTTP success, export_comments.py still checks the business status, the action and the tree shape. The request in step 2 reads the direct /v1/social-data/call response, not a capabilities execution wrapper.

3. Export text and reply relationships

Save the script below as export_comments.py and run the script with Python 3. The target CSV must not exist yet: the script checks the response structure before opening the target and never overwrites an existing export. A missing score stays empty, and a zero score stays zero. Text that starts with a formula character gets a leading apostrophe to reduce the risk that a spreadsheet app runs the text as a formula.

import csv, json, pathlib, sys
source, target = map(pathlib.Path, sys.argv[1:3])
r = json.loads(source.read_text(encoding="utf-8"))
if not isinstance(r, dict) or r.get("error") is not None or r.get("status") != "succeeded" or r.get("action") != "reddit.app.fetch_post_comments":
raise ValueError("Expected a successful Reddit comment response")
if not isinstance(r.get("request_id"), str) or not r["request_id"].strip():
raise ValueError("Missing request ID")
forest = r["data"]["postInfoById"]["commentForest"]
trees = forest["trees"]
if not isinstance(trees, list):
raise ValueError("commentForest.trees must be an array")
info = forest.get("pageInfo")
if not isinstance(info, dict) or type(info.get("hasNextPage")) is not bool:
raise ValueError("Expected an explicit pagination boolean")
rows, seen = [], {}
duplicate_nodes = 0
def cell(value):
if value is None: return ""
text = str(value)
return "'" + text if text.lstrip().startswith(("=", "+", "-", "@")) else text
for tree in trees:
if not isinstance(tree, dict):
raise ValueError("Each tree entry must be an object")
node = tree.get("node")
if node is None: continue # pagination marker, not a comment
if not isinstance(node, dict):
raise ValueError("Unusable or redacted node; do not treat it as an empty page")
key = node.get("id")
if not isinstance(key, str) or not key or key.startswith("[redacted"):
raise ValueError("Missing usable comment id")
if type(tree.get("depth")) is not int or tree["depth"] < 0:
raise ValueError("Expected nonnegative integer depth")
for name in ("childCount",):
if tree.get(name) is not None and (type(tree[name]) is not int or tree[name] < 0):
raise ValueError("Expected nonnegative integer child count or missing")
if node.get("score") is not None and (type(node["score"]) is not int or abs(node["score"]) > 9007199254740991):
raise ValueError("Expected safe integer score, including negative values, or missing")
if node.get("isRemoved") is not None and type(node["isRemoved"]) is not bool:
raise ValueError("Removal status must be boolean or missing")
content = node.get("content")
if content is None: content = {}
if not isinstance(content, dict) or (content.get("markdown") is not None and not isinstance(content["markdown"], str)):
raise ValueError("Expected comment text or missing")
if key in seen:
if seen[key] != tree:
raise ValueError("Conflicting duplicate comment within one page; preserve raw and review")
duplicate_nodes += 1
continue
seen[key] = tree
rows.append([key, tree.get("parentId"), tree.get("depth"), tree.get("childCount"),
content.get("markdown"), node.get("score"), node.get("createdAt"),
node.get("permalink"), node.get("isRemoved"), r.get("request_id")])
## Exclusive creation protects earlier exports; an empty valid page still gets a header.
with target.open("x", encoding="utf-8", newline="") as f:
writer = csv.writer(f)
writer.writerow(["id", "parent_id", "depth", "child_count", "markdown", "score",
"created_at", "permalink", "is_removed", "request_id"])
writer.writerows([[cell(v) for v in row] for row in rows])
more = trees[-1].get("more") if trees else None
cursor = more.get("cursor") if isinstance(more, dict) else None
if not isinstance(cursor, str) or not cursor.strip():
cursor = None
if not info["hasNextPage"]:
cursor = None
stop_reason = "provider_end" if not info["hasNextPage"] else ("next_page_available" if cursor else "missing_usable_cursor")
print(json.dumps({"rows": len(rows), "has_next_page": info.get("hasNextPage"),
"after": cursor, "duplicate_nodes": duplicate_nodes,
"stop_reason": stop_reason, "all_comments_collected": False}, ensure_ascii=False))

4. Check the export and continue deliberately

python3 export_comments.py reddit-query-1/reddit-comments.json reddit-comments-page-1.csv

Check that rows in the printed summary matches the CSV row count, and check for duplicate IDs. A valid empty page produces a header only. When merging pages, keep parent_id and depth and deduplicate by id. permalink is relative: prepend https://www.reddit.com to open the comment. score is not a like count, and missing text stays missing; do not reconstruct missing text.

The script prints has_next_page and after. Stop when has_next_page is false. Continue only when has_next_page is true, after is a new nonempty cursor and the next page fits your approved page budget; save the next page under new JSON and CSV filenames. Stop and inspect the response when the cursor is missing or repeated, the status is missing or the response is an error. The script never retries a paid query.

5. What does this export cover?

The export is a snapshot of the returned comment nodes, not a complete historical backup. A child_count value does not mean that many replies were received. Keep missing parents and removal flags, and do not promote orphan replies to top-level comments while merging. The FAQ linked below gives the exact paging boundaries.

The field paths come from the backend’s four historical production response structures and the gateway’s current renderer. The examples follow the documented structure, and t3_abc123 is a placeholder.

FAQ · Reddit

6. Merge saved pages without losing duplicate observations or missing parents

Do not concatenate per-page CSVs and treat the result as deduplicated. Create pages.json with the requested post_id and the actual collection time of each CSV, as in this example manifest:

{"pages":[{"post_id":"t3_abc123","file":"reddit-comments-page-1.csv","collected_at":"2026-11-16T10:00:00Z"},{"post_id":"t3_abc123","file":"reddit-comments-page-2.csv","collected_at":"2026-11-16T10:01:00Z"}]}

Save the script below as merge_pages.py and run python3 merge_pages.py pages.json merged-comments. The script runs offline, refuses an existing output directory and writes three files:

  • comments.csv: one row per post + comment ID, using the first observation in manifest order.
  • observations.csv: every observation, so later edits and score changes are not silently overwritten.
  • coverage.json: pages, unique comments, duplicate observations and replies with missing parents.

A reply whose parent is missing remains a reply, and a valid empty page still counts as a page.

import csv
import json
import sys
from datetime import datetime
from pathlib import Path
manifest_path, output_path = map(Path, sys.argv[1:])
manifest = json.loads(manifest_path.read_text(encoding="utf-8"))
pages = manifest.get("pages")
if not isinstance(pages, list) or not pages:
raise SystemExit("Expected at least one saved-page entry")
required = {"id", "parent_id", "depth", "child_count", "markdown", "score", "created_at", "permalink", "is_removed", "request_id"}
observations, chosen, seen_files = [], {}, set()
for page in pages:
post = page.get("post_id")
if not isinstance(post, str) or not post.startswith("t3_") or len(post) <= 3:
raise SystemExit("Expected the request's t3_ post ID")
file = manifest_path.parent / page["file"]
if file.resolve() in seen_files:
raise SystemExit("Duplicate page file")
seen_files.add(file.resolve())
try:
stamp = datetime.fromisoformat(page["collected_at"].replace("Z", "+00:00"))
if stamp.utcoffset() is None:
raise ValueError()
except (ValueError, KeyError, TypeError):
raise SystemExit("Collection time requires a timezone")
with file.open(encoding="utf-8-sig", newline="") as handle:
reader = csv.DictReader(handle)
if set(reader.fieldnames or []) != required:
raise SystemExit("Use CSVs from the exporter above")
for row in reader:
if not row["id"] or not row["depth"].isdigit():
raise SystemExit("Missing ID or invalid depth")
observation = {"post_id": post, **row, "source_csv": page["file"], "collected_at": page["collected_at"]}
observations.append(observation)
key = (post, row["id"])
if key not in chosen:
chosen[key] = observation
rows = []
for (post, key), first in chosen.items():
row = dict(first)
row["parent_in_sample"] = "not_applicable_root" if int(row["depth"]) == 0 else str((post, row["parent_id"]) in chosen).lower()
row["observations"] = sum(v["post_id"] == post and v["id"] == key for v in observations)
rows.append(row)
summary = {"pages": len(pages), "observations": len(observations), "unique_comments": len(rows),
"duplicate_observations": len(observations) - len(rows),
"replies_with_missing_parent": sum(v["parent_in_sample"] == "false" for v in rows),
"policy": "first observation in manifest order; all observations retained separately",
"scope": "saved returned nodes only, not a complete thread"}
output_path.mkdir(parents=False, exist_ok=False)
def write(name, values, columns):
with (output_path / name).open("x", encoding="utf-8-sig", newline="") as handle:
writer = csv.DictWriter(handle, fieldnames=columns)
writer.writeheader()
for row in values:
writer.writerow({k: ("'" + v if isinstance(v, str) and v.lstrip().startswith(("=", "+", "-", "@")) else v) for k, v in row.items()})
base_columns = ["post_id", "id", "parent_id", "depth", "child_count", "markdown", "score", "created_at", "permalink", "is_removed", "request_id", "source_csv", "collected_at"]
write("comments.csv", rows, base_columns + ["parent_in_sample", "observations"])
write("observations.csv", observations, base_columns)
(output_path / "coverage.json").write_text(json.dumps(summary, indent=2), encoding="utf-8")

7. Turn the saved discussion into an evidence-backed question backlog

Retrieving comments and interpreting praise, complaints and questions are separate steps. On Reddit, also keep the reply context: a reply to another reader is not automatically an independent product complaint. Use the merged comments from step 6 instead of buying the same pages again.

For a product team, deliver a short list of three kinds of items, each linked to exact evidence: questions to answer, recurring friction to investigate and praise to preserve. Read the thread context and assign at most one primary topic to each included comment. An AI model may propose labels; a reviewer checks every label. Mark ads, off-topic discussion and unsupported interpretation as excluded with a reason. Do not use removed comments, or comments with an unknown removal state, as support.

Create review-labels.json with real post and comment IDs and exact excerpts from the markdown text of the raw response. Replace the placeholders in this template:

[{"post_id":"t3_abc123","comment_id":"REPLACE_WITH_REAL_COMMENT_ID","decision":"include","kind":"question","topic":"Setup prerequisites","quote":"REPLACE_WITH_VERBATIM_EXCERPT"}]

For an included comment, set kind to question, complaint or praise. To exclude a comment, set decision to exclude and give a nonempty reason. Save the script below as reddit_review.py. The script checks that each reviewed comment is in the merged sample, that each quote appears verbatim in the raw text and that the comment is explicitly not removed. The script keeps parent and depth context and reports unreviewed comments, so a partial review does not look complete. The script does not check whether a user’s claim is true and does not publish anything.

Before you run the script, save raw-pages.json, which maps each source_csv of the merged table to the raw response and the requested post. CSV formula escaping can add an apostrophe that is not in the source text, so reddit_review.py checks quotes against the raw JSON instead of stripping apostrophes.

[{"post_id":"t3_abc123","csv_file":"reddit-comments-page-1.csv","raw_file":"reddit-query-1/reddit-comments.json"}]
import csv,hashlib,json,pathlib,sys
source,raw_manifest,review,target=map(pathlib.Path,sys.argv[1:5])
with source.open(encoding="utf-8-sig",newline="") as f:records=list(csv.DictReader(f))
comments={}
for row in records:
key=(row.get("post_id"),row.get("id"))
if not all(isinstance(value,str) and value.strip() for value in key) or key in comments:raise ValueError("Use deduplicated merged comments")
comments[key]=row
raw_entries=json.loads(raw_manifest.read_text(encoding="utf-8"))
if not isinstance(raw_entries,list):raise ValueError("Raw-page manifest required")
originals={};csv_pages=set()
for page in raw_entries:
csv_file=page["csv_file"];post=page["post_id"]
if csv_file in csv_pages:raise ValueError("Ambiguous CSV to raw-page mapping")
csv_pages.add(csv_file)
path=pathlib.Path(page["raw_file"])
if not path.is_absolute():path=raw_manifest.parent/path
raw=path.read_bytes();response=json.loads(raw)
if not isinstance(response,dict) or response.get("error") is not None or response.get("status")!="succeeded" or response.get("action")!="reddit.app.fetch_post_comments":raise ValueError("Wrong raw response")
if not isinstance(response.get("request_id"),str) or not response["request_id"].strip():raise ValueError("Missing raw request ID")
trees=response["data"]["postInfoById"]["commentForest"]["trees"]
if not isinstance(trees,list):raise ValueError("Raw tree required")
for tree in trees:
if not isinstance(tree,dict):raise ValueError("Invalid raw tree entry")
node=tree.get("node")
if node is None:continue
if not isinstance(node,dict):raise ValueError("Unusable raw comment object")
ident=node.get("id")
if not isinstance(ident,str) or not ident.strip() or ident.startswith("[redacted"):raise ValueError("Missing raw comment ID")
key=(post,ident,csv_file)
if key in originals:
if originals[key]["tree"]!=tree:raise ValueError("Conflicting raw duplicate; do not select a favorable version")
continue
originals[key]={"node":node,"tree":tree,"request_id":response["request_id"],"raw_file":str(path),"sha256":hashlib.sha256(raw).hexdigest()}
labels=json.loads(review.read_text(encoding="utf-8"))
if not isinstance(labels,list):raise ValueError("Review array required")
seen=set();topics={};excluded=[]
for item in labels:
key=(item["post_id"],item["comment_id"])
if key not in comments or key in seen:raise ValueError("Review each actual comment at most once")
seen.add(key);row=comments[key]
if item.get("decision")=="exclude":
reason=item.get("reason")
if not isinstance(reason,str) or not reason.strip():raise ValueError("Exclusion reason required")
excluded.append({"post_id":key[0],"comment_id":key[1],"reason":reason});continue
if item.get("decision")!="include":raise ValueError("Decision must be include or exclude")
original=originals.get((key[0],key[1],row.get("source_csv")))
if original is None or original["request_id"]!=row.get("request_id"):raise ValueError("Raw source does not match merged observation")
node=original["node"];tree=original["tree"]
if node.get("isRemoved") is not False:raise ValueError("Only explicitly non-removed raw comments may support a theme")
topic=item.get("topic");kind=item.get("kind");quote=item.get("quote");content=node.get("content") or {}
if not isinstance(content,dict) or not isinstance(content.get("markdown"),str):raise ValueError("Raw markdown required")
text=content["markdown"]
if not isinstance(topic,str) or not topic.strip() or kind not in ("question","complaint","praise"):raise ValueError("Topic and supported kind required")
if text.strip().lower() in ("[removed]","[deleted]"):raise ValueError("Removal placeholders are not theme evidence")
if not isinstance(quote,str) or not quote.strip() or quote not in text:raise ValueError("Quote must occur verbatim in original raw comment text")
if not node.get("permalink") or not row.get("request_id"):raise ValueError("Evidence source and request_id required")
depth=row.get("depth","")
if not depth.isdigit() or int(depth)!=tree.get("depth"):raise ValueError("Comment depth differs from raw evidence")
if row.get("parent_id")!=str(tree.get("parentId") or ""):raise ValueError("Parent differs from raw evidence")
bucket=topics.setdefault((kind,topic),[])
bucket.append({"post_id":key[0],"comment_id":key[1],"quote":quote,"permalink":node["permalink"],"raw_file":original["raw_file"],"raw_sha256":original["sha256"],
"request_id":row["request_id"],"collected_at":row.get("collected_at"),"depth":int(depth),
"parent_id":row.get("parent_id"),"parent_in_sample":row.get("parent_in_sample"),"source_csv":row.get("source_csv")})
output=[]
for (kind,topic),evidence in sorted(topics.items()):
output.append({"kind":kind,"topic":topic,"supporting_comments":len(evidence),"distinct_posts":len({v["post_id"] for v in evidence}),
"root_comments":sum(v["depth"]==0 for v in evidence),"replies":sum(v["depth"]>0 for v in evidence),
"evidence":evidence,"proposed_action":"","verification_needed":""})
report={"unique_exported_comments":len(comments),"reviewed_comments":len(seen),"unreviewed_comments":len(comments)-len(seen),
"included_comments":sum(len(v) for v in topics.values()),"excluded_comments":len(excluded),"excluded":excluded,
"topics":output,"scope":"Reviewed saved comments only; counts are comments, not people or population prevalence",
"review_policy":"One primary topic per included comment. Semantic labels are human-reviewed, not machine-verified truth."}
with target.open("x",encoding="utf-8") as f:json.dump(report,f,ensure_ascii=False,indent=2)
print(str(target))

Run python3 reddit_review.py merged-comments/comments.csv raw-pages.json review-labels.json question-backlog.json. Read every evidence excerpt in context, then fill proposed_action and verification_needed in a copy. For example, an unanswered setup question leads to a documentation draft, and a complaint leads to a reproduction checklist, not an immediate public accusation. Each proposed action is your editorial decision, not API output.

Counts in question-backlog.json are supporting comments and distinct posts, not distinct people, customer prevalence or independent survey responses. Top-level comments and replies are reported separately, and missing parents stay visible. Excluded and unreviewed counts stay in the coverage record. The output omits author names, but quotes can still contain personal information: redact a shareable copy before you send the quotes outside the review team.

Reject corrupt rows without throwing away a valid missing-cursor page

Before creating the CSV, export_comments.py requires a request ID, an explicit hasNextPage boolean and valid types for comment depth, child count and score. A negative Reddit score is valid; a boolean or fractional score is not accepted as a count. Identical repeated nodes within one page collapse into one row and are counted. Two different versions of the same ID within one page stop the export, so a favorable quote cannot be selected silently; keep the raw response for investigation. The merge step keeps changes between separately saved pages.

When a valid page has comments but no usable next cursor, the exporter still exports those comments and reports missing_usable_cursor; the page has comments, and the thread is not complete. provider_end means only that the comment-list pagination ended. The exporter always sets all_comments_collected to false, because unexpanded reply branches, removed text and later activity are not in the saved pages. next_page_available means a cursor exists; spending on another page is your decision. Continue only within the existing budget and only with a new cursor.

Sign off the backlog before sharing it

For each topic, confirm that the retained excerpts support the label in their thread context. A question points to a documentation gap to investigate, a complaint to a reproduction task and praise to an experience worth preserving. The proposed next steps are editorial judgments, not verified findings about every customer. Fill proposed_action and verification_needed in a reviewed copy, and keep the generated output unchanged.

Deliver these files together: the chosen-thread list with reasons; the original page bytes; the per-page CSVs; pages.json and raw-pages.json; the merged comments and all observations; the review labels; the generated backlog; and the edited action copy. State how many comments remain unreviewed instead of presenting a partially labeled file as fully assessed. Remove personal details from quotes in any shareable copy. The scripts do not contact Reddit users, publish findings, create alerts or grant permission to share the material.

With multiple pages, check by hand that each saved request used the new after cursor from the previous page; merge_pages.py does not validate the cursor chain. Each csv_file in raw-pages.json must exactly match a source_csv value in the merged table.

reddit_review.py also rejects conflicting duplicate IDs within one raw page, unusable non-null nodes and error envelopes, so the review never picks a favorable version. Comment scores must be safe JSON integers, and negative scores remain valid. Keep unexpected values for investigation instead of deriving a precise score from an unsafe number.

Start from chosen community feeds instead of known post links.