Only using the official API is quite cumbersome, as fetching a story with comments requires one network request per each comment.
Instead, try considering the (more unknown) Algolia API[0]. It supports fetching the entire tree in one request. Unfortunately the comments aren’t sorted, so you’ll still have to use the official one (or parse the HN HTML) if you need that.
For my HN client[1], I parse the HN HTML (as it’s required for voting), and sort the comments from the Algolia API. It’s much faster than recursively requesting the official API.
I found this interesting, looking at the Firebase API. I guess one could get the min/max item ids for the child posts, and query the range of ids (startAt(), endAt()).
In response to people's complaints about the usability of the HN Firebase API: yes. We're going to eventually have a new API that returns a simple JSON version of any HN URL. At that point we'll phase out the Firebase API, with a generous deprecation period. I'd be curious to hear people's thoughts about what a generous deprecation period might be.
The great thing about the Firebase API is that it's live, so you can subscribe to updates to a post/comment/profile and see them as they're made (no polling, just websockets). I'd hope any future version would retain this feature.
I'm reluctant to lose it as I'm about to release a browser extension that relies on it pretty heavily :)
[Edit]: this feature is undocumented in the link above, but it's a standard feature of FB and works as expected in all client libraries https://firebase.google.com/docs/database
I'd say it depends on how straightforward the new API will be. The app I use (Materialistic) is both free and ads-free. So I don't expect the developer to drop everything they are doing to update it if will require a lot of work. So 6 months minimum if everything is well documented, a year if it will be a hassle.
Wish API would show comment votes instead of only showing them up until 8 years ago when displaying them was turned off on the main site. Aside from allowing users to enable them via their on interface, do analysis, etc — it broke HN’s comment search based on comment popularity.
I’d like to be able to conveniently access my most popular comments. There are quite a few things in there that I might like to write longer-form articles about.
I don’t want vote information to be publicly available. Hiding those numbers was good for the site. Users have ways to get their own data. That’s enough.
I found the official API quite a pain to work with while building myself an alternative "hn ui"[0]. I mostly switched over to using the Algolia API[1], which is a lot more "fun" to work with. I can only recommend checking that one out as well.
I wrote a fairly simple "Who is hiring?" browser (using this API) that fetched the post listings and stored them locally in an HTML file accessible by pointing your browser at file:///... . It supported filtering by "Remote", "Interns", and "Visa" with buttons, had an ad hoc Regex filter, and the ability to remove posts using a delete button and not see them again (or to restore all deleted posts) using the localStorage api.
It was indeed barebones but I'd like to think it helped me find a job. I would link the code (it's on GitHub) but today the "Who is hiring?" posts include a few considerably more advanced and capable "searchers" right in the top of the post:
Firebase is owned by google. There are plenty of OSS solutions to create this exact realtime thing without getting too close to the elephant in the room.
I'm currently writing an HN posts score tracker (basically it plots score variations over time since they were in new for each popular post) and it's really handy that you can just subscribe with eventsource [0] and get realtime update when something changes without having to manually poll each post wasting resources. Not yet sure about the latency though.
If you want to see a small example of this API being used, here's a utility to generate an RSS feed of replies to comments you post that you can self-host:
Anyone know of a good tool to get something like push notifications when specific topics come up on HN? I've been thinking maybe I should build one, but I also feel like someone must have already done it by now.
You can check this [1] service that I prepared for myself then made it publicly available. For now it’s only sending popular stories as notification. Planning to add keyword feature.
Don’t have any suggestions but as an alternative to notifications, I wrote a script to check the HN API for keywords such as “outage” “downtime” “breached” and show the results on a TV screen in my office.
Has been quite useful for the ops side of what I work on!
Similar to this, I created "HN Faves API", which is an API to fetch a user's favorited posts and comments on HN. Interestingly, HN doesn't have an official API for this.
I used to query flagged comments from time to time using the API, just out of some morbid curiosity. It definitely used to work for that; I am not sure if flagged items are in the same class as dead ones, though, or if they have since deliberately eliminated this capability. I eventually found more interesting things to do :)
For a few years I am working on the side on a HN client. One thing that is really sad is that there is now way to handle authentication properly as a 3rd party. The user basically has to trust you with her/his password or you have to "steal" the auth token from a login.
[+] [-] goranmoomin|3 years ago|reply
Instead, try considering the (more unknown) Algolia API[0]. It supports fetching the entire tree in one request. Unfortunately the comments aren’t sorted, so you’ll still have to use the official one (or parse the HN HTML) if you need that.
For my HN client[1], I parse the HN HTML (as it’s required for voting), and sort the comments from the Algolia API. It’s much faster than recursively requesting the official API.
[0]: https://hn.algolia.com/api
[1]: https://github.com/goranmoomin/HackerNews
[+] [-] catnip09|3 years ago|reply
https://hngraphql.fly.dev/graphql
[+] [-] CodesInChaos|3 years ago|reply
[+] [-] adamredwoods|3 years ago|reply
Van Puffelen answers some of this here, but he doesn't get into specific queries: https://www.youtube.com/watch?v=66lDSYtyils
He also mentions here that Firestore offers a bit more for WHERE type clauses over Firebase:
https://stackoverflow.com/questions/26700924/query-based-on-...
[+] [-] dang|3 years ago|reply
[+] [-] somishere|3 years ago|reply
I'm reluctant to lose it as I'm about to release a browser extension that relies on it pretty heavily :)
[Edit]: this feature is undocumented in the link above, but it's a standard feature of FB and works as expected in all client libraries https://firebase.google.com/docs/database
[+] [-] MarcellusDrum|3 years ago|reply
[+] [-] arthurcolle|3 years ago|reply
[+] [-] catnip09|3 years ago|reply
I want to build a HN web client but it's not possible without scrapping the site which won't scale.
[+] [-] ksec|3 years ago|reply
[+] [-] yamrzou|3 years ago|reply
[+] [-] krapp|3 years ago|reply
Just being able to get an entire thread in a single request alone, and filter queries would make things much easier.
[+] [-] saagarjha|3 years ago|reply
[+] [-] livinglist|3 years ago|reply
[+] [-] O__________O|3 years ago|reply
Related:
https://news.ycombinator.com/item?id=32535637
[+] [-] chrismorgan|3 years ago|reply
(https://james.darpinian.com/blog/scraping-my-own-hacker-news... gives one way of doing it, by crawling your /threads?id=‹username› page, which does contain the point counts for each comment by you.)
[+] [-] 1123581321|3 years ago|reply
[+] [-] metadat|3 years ago|reply
We're already helping to create a training set of slightly above average English speaker discourse for free.
[+] [-] superb-owl|3 years ago|reply
[1] https://github.com/superb-owl/hacker-news-comments
[2] https://superbowl.substack.com/p/commenting-on-hacker-news
[+] [-] AtroxDev|3 years ago|reply
[0]: https://hnhub.dev/
[1]: https://hn.algolia.com/api/
[+] [-] avg_dev|3 years ago|reply
It was indeed barebones but I'd like to think it helped me find a job. I would link the code (it's on GitHub) but today the "Who is hiring?" posts include a few considerably more advanced and capable "searchers" right in the top of the post:
> Searchers: try https://kennytilton.github.io/whoishiring/, https://hnjobs.emilburzo.com, https://news.ycombinator.com/item?id=10313519.
It was fun; I enjoyed working on it.
[+] [-] maxique|3 years ago|reply
[+] [-] ashish01|3 years ago|reply
https://github.com/ashish01/hn-data-dumps
[+] [-] breck|3 years ago|reply
[+] [-] reneberlin|3 years ago|reply
[+] [-] easrng|3 years ago|reply
[+] [-] somishere|3 years ago|reply
[+] [-] greatgib|3 years ago|reply
[+] [-] Asdrubalini|3 years ago|reply
[0] https://github.com/jpopesculian/reqwest-eventsource/
[+] [-] password4321|3 years ago|reply
[+] [-] imnitishng|3 years ago|reply
[+] [-] banana_giraffe|3 years ago|reply
https://gist.github.com/Q726kbXuN/15e61acc003bb6d46a458001fe...
[+] [-] BeyondSchwifty|3 years ago|reply
[+] [-] mavci|3 years ago|reply
[1] https://hnn.avci.me/
[+] [-] tailspin2019|3 years ago|reply
Has been quite useful for the ops side of what I work on!
[+] [-] djbusby|3 years ago|reply
[+] [-] dinkledunk|3 years ago|reply
[+] [-] plibither8|3 years ago|reply
On GitHub: https://github.com/plibither8/hn-faves-api
You can try it out here: https://hn-faves.mihir.ch
[+] [-] adamredwoods|3 years ago|reply
https://firebase.google.com/docs/database/web/read-and-write
[+] [-] overshard|3 years ago|reply
https://github.com/overshard/newtab/blob/master/newtab.js#L1...
Haven't had any issues with it!
[+] [-] superb-owl|3 years ago|reply
I wrote a script that uses your browser cookies to scrape them from the website here: https://github.com/superb-owl/hacker-news-comments
[+] [-] shkaj|3 years ago|reply
Is there any way to query this API as if showdead is switched on?
[+] [-] avg_dev|3 years ago|reply
[+] [-] fileeditview|3 years ago|reply
[+] [-] wslh|3 years ago|reply
[+] [-] teleclimber|3 years ago|reply
[+] [-] O__________O|3 years ago|reply
[+] [-] kogir|3 years ago|reply
[+] [-] krapp|3 years ago|reply