TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Show HN: yget – get top stories on HN without a browser

2 pointsby libeleover 1 year ago
example usage:<p><pre><code> $ yget 3 1. Cisco Acquires Splunk &lt;https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=37596497&gt; 591 points by siddharthb_ | 325 comments 2. Matrix 2.0: The Future of Matrix &lt;https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=37599510&gt; 151 points by jrepinc | 63 comments 3. Nippon Television has just acquired Studio Ghibli &lt;https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=37596788&gt; 454 points by sohkamyung | 146 comments #!&#x2F;bin&#x2F;sh # yget: get top stories on hn without a browser # https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=37601452 # this is a small shell script i wrote to try out the firebase API that # prints HN posts one at a time into your terminal. it depends on curl # and jq, but is otherwise fully portable. yget () { URI_FMT=&#x27;https:&#x2F;&#x2F;hacker-news.firebaseio.com&#x2F;v0&#x27; URL_FMT=&#x27;https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=&#x27; USER=${USER:-$(whoami || id -un)} YGET_DIR=&quot;${YGET_DIR:-&#x2F;tmp&#x2F;yget.$USER}&quot; mkdir -p &quot;$YGET_DIR&quot; topstories=&quot;$YGET_DIR&quot;&#x2F;topstories.json curl -s &quot;$URI_FMT&#x2F;topstories.json&quot; &gt; &quot;$topstories&quot; if [ -n &quot;$1&quot; ]; then if test &quot;$1&quot; -ge 1 2&gt;&#x2F;dev&#x2F;null &amp;&amp; test &quot;$1&quot; -le 500 2&gt;&#x2F;dev&#x2F;null; then post_left=&quot;$1&quot; elif test &quot;$1&quot; -lt 1 2&gt;&#x2F;dev&#x2F;null || test &quot;$1&quot; -gt 500 2&gt;&#x2F;dev&#x2F;null; then printf &quot;out of range!\n&quot; exit 1 else printf &quot;invalid input!\n&quot; exit 1 fi else post_left=&quot;4&quot; fi post_count=&quot;$post_left&quot; while [ &quot;$post_left&quot; -gt 0 ]; do rank=$((post_count - post_left)) num=$((rank + 1)) id=$(jq -r .[&quot;$rank&quot;] &quot;$topstories&quot;) story=&quot;$YGET_DIR&quot;&#x2F;&quot;$id&quot;.json curl -s &quot;$URI_FMT&#x2F;item&#x2F;$id.json&quot; &gt; &quot;$story&quot; title=$(jq -r &#x27;.title&#x27; &quot;$story&quot;) score=$(jq -r &#x27;.score&#x27; &quot;$story&quot;) user=$(jq -r &#x27;.by&#x27; &quot;$story&quot;) comments=$(jq -r &#x27;.descendants&#x27; &quot;$story&quot;) printf &quot;\n%3d. %s \n&quot; &quot;$num&quot; &quot;$title&quot; printf &quot; &lt;%s&gt; \n&quot; &quot;$URL_FMT$id&quot; printf &quot; %s points by %s | %s comments \n&quot; &quot;$score&quot; &quot;$user&quot; &quot;$comments&quot; post_left=$((post_left - 1)) done } yget &quot;$1&quot;</code></pre>

1 comment

mdwaltersover 1 year ago
This is great! You should expand this to be a full-fledged HN reader.