Today's HN top 10, ranked by score
Pulls the top 30 HN story IDs, fetches each item in parallel, sorts by score, prints the top 10. Pure public API + jq + xargs.
The one-liner
$ curl -s "https://hacker-news.firebaseio.com/v0/topstories.json" \
| jq -r '.[0:30][]' \
| xargs -P 10 -I {} curl -s "https://hacker-news.firebaseio.com/v0/item/{}.json" \
| jq -s -r 'sort_by(-.score) | .[0:10] | .[] | "[\(.score)] \(.title) — \(.url // "discussion")"'What each stage does
- [01] curl
curl -s "https://hacker-news.firebaseio.com/v0/topstories.json"Fetch the array of the current top-500 story IDs from HN's Firebase API. -s = silent (no progress bar). - [02] jq
jq -r '.[0:30][]'Slice the first 30 IDs and emit one ID per line (raw, no quotes) so xargs can consume them. - [03] xargs
xargs -P 10 -I {} curl -s "https://hacker-news.firebaseio.com/v0/item/{}.json"For each ID, hit the item endpoint. -P 10 runs up to 10 fetches in parallel; -I {} substitutes the ID into the URL. - [04] jq
jq -s -r 'sort_by(-.score) | .[0:10] | .[] | "[\(.score)] \(.title) — \(.url // …-s slurps all 30 JSON items into one array. Sort by negative score (descending), take top 10, format each as a line with score, title, and URL (falling back to 'discussion' for Ask HN-style posts with no URL).
Expected output (sample)
[523] Show HN: We built a vector DB in 200 lines of Rust — https://example.com/vdb [412] Apple Silicon M5 Pro benchmarks — https://example.com/m5 [388] The hidden cost of LLM batching — https://example.com/batching ... 7 more lines
Caveats & tips
- Score is a snapshot — repeat to see ranking shift through the day.
- xargs -P value: don't set higher than 20; HN rate-limits aggressive clients.