A Hacker News thread to a Markdown file
Give it a Hacker News link and get thread.md with the title, author, score and the first comments, ready to paste into notes or a report.
tested Run for real on 19 November 2026 against https://api.foxapis.com (Python 3.14 with requests 2.34, Node 20). The code below is the file that ran; the output is what it printed.
What you need
- A FoxAPIs key (the free trial gives one)
- Node.js 18 or newer (it uses the built-in fetch; nothing to install)
The code
Save as hn_thread.mjs
// Hacker News thread to a Markdown file with FoxAPIs. Node 18+. Usage: node hn_thread.mjs https://news.ycombinator.com/item?id=8863 (3 credits reported on 19 Nov 2026: 1 for the post, 2 for its comments)
import { writeFileSync } from "node:fs";
const KEY = process.env.FOXAPIS_KEY; // your FoxAPIs key; never paste it into the file
const link = process.argv[2];
if (!KEY || !link) { console.error("Set FOXAPIS_KEY and pass a Hacker News link."); process.exit(1); }
const call = async (path) => {
const r = await fetch(`https://api.foxapis.com/v1/developer/hackernews/${path}`, { method: "POST", headers: { Authorization: `Bearer ${KEY}`, "Content-Type": "application/json" }, body: JSON.stringify({ url: link }) });
if (!r.ok) throw new Error(`${path}: HTTP ${r.status}`);
return r.json();
};
const [post, thread] = await Promise.all([call("post"), call("comments")]);
const lines = [`# ${post.title}`, "", `By ${post.author_handle || post.author_name}, ${post.published_at}. ${post.likes} points, ${post.comments_count} comments.`, `Source: ${post.url}`, ""];
if (post.text) lines.push(String(post.text).trim(), "");
for (const c of thread.comments.slice(0, 20)) lines.push(`- **${c.author || c.author_handle || "unknown"}**: ${String(c.text || "").replace(/\s+/g, " ").trim().slice(0, 300)}`);
writeFileSync("thread.md", lines.join("\n") + "\n");
console.log(`wrote thread.md: ${thread.comments.length} comments read, ${(post.credits_used || 0) + (thread.credits_used || 0)} credits`);Run it
- Put your key in an environment variable: export FOXAPIS_KEY=your-key (PowerShell: $env:FOXAPIS_KEY = "your-key").
- Run node hn_thread.mjs "https://news.ycombinator.com/item?id=8863".
Input used in the test
node hn_thread.mjs "https://news.ycombinator.com/item?id=8863"
What it printed and wrote (19 November 2026)
wrote thread.md: 5 comments read, 3 credits thread.md (first lines): # My YC app: Dropbox - Throw away your USB drive By dhouston, 2007-04-04T19:16:40+00:00. 104 points, 71 comments. Source: http://www.getdropbox.com/u/2/screencast.html
- The comments call returned the first 5 of this thread's 71 comments on 19 Nov 2026, so thread.md holds those 5. The point count and comment total come from the post call.
What a run costs
3 credits for the run: 1 for the post, 2 for its comments. fact: credits the API reported
That is about $0.029 per thread on the Builder plan. Calculated by us: plan price divided by its credits.Formula Plans and credits: pricing.
Official docs, read 19 November 2026
Common questions
Why does the file hold only a few comments?
That is what the comments call returned on the day it was tested; the post line states the real comment total.
Does it need any package?
No. Node 18 and newer has fetch built in.
Start free: get a key More code samples · All recipes
How we calculate
- Cost of the run: The credits per call times the calls the recipe makes, times the smallest paid plan's price per credit (plan price divided by its credits).
Data: the FoxAPIs catalog and plans, read 19 November 2026. Every other figure on this page is copied from the record, not calculated by us.
Run this free, then pay per call
Free to start: 100 credits, no card. Then from $10. Credits you buy never expire. Use them at your own pace. Get my free key
One call costs 1 credit. That is $7.96 per 1,000 calls on the Production plan and $9.80 on Builder (plan price divided by its monthly credits). The Free plan gives 100 credits a month with no card.
Building an AI agent?
- The FoxAPIs MCP server gives your agent every tool through one connection.
- Per-call pricing in credits: you pay for the calls your agent makes, with no seats.
- Free plan: 100 credits a month, no card, no monthly fee.