25 ms·
Hacker News Official API
- snidane 4y agoWhat is the use case? I can't imagine anything besides getting a real time view on the frontpage or likes of my own comments that a monthly static data dump wouldn't solve.
- dhritzkiv 4y agoProbably 3rd party clients that offer quality of life / usability improvements over the website. E.g. I use Hackers [1][2] because it is much easier to read stories on mobile and supports dark mode. Unfortunately, it doesn't support commenting or downvoting (yet?) [1] https://apps.apple.com/us/app/hackers-for-hacker-news/id603503901 https://apps.apple.com/us/app/hackers-for-hacker-news/id6035... [2] https://github.com/weiran/Hackers https://github.com/weiran/Hackers
- deleted 4y ago[deleted]
- busymom0 4y agoI am the developer of HACK (available on iOS, Android and MacOS) which allows commenting, upvoting, downvoting, favoriting, submitting new posts and also supports push notifications for replies. It is the top Hacker News client in the App Store. https://apps.apple.com/ca/app/hack-for-hacker-news-developer/id1464477788 https://apps.apple.com/ca/app/hack-for-hacker-news-developer...
- bombcar 4y agoHuh has the link to this on the bottom of the page been there since jan1?
- inductive_magic 4y agoThere was a link to the API documentation at the bottom for as long as I can remember using HN, but I’m not sure if it always pointed to the GitHub-page linked in this post.
- overshard 4y agoI use this API in a few places such as a custom New Tab extension I made for myself on Chromium based browsers: https://github.com/overshard/newtab/blob/master/newtab.js#L125 https://github.com/overshard/newtab/blob/master/newtab.js#L1... Haven't had any issues with it!
- wslh 4y agoAgain, it would be also great if we have a user's personal API to get our private info either.
- teleclimber 4y agoAgreed. An read only API for my upvoted stories and comments would be great so I can preserve this data and use it outside of HN.
- O__________O 4y agoAlso be nice if per private user behavior, that a user was able to authorize API access to it without risking account lose.
- seanalltogether 4y agoIs this expected to be a read only api, or is write planned for the future?
- greatgib 4y agoThis is so awesome. I like very much the spirit of giving access to the api as-is. With no fuss.
- O__________O 4y agoWish 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. Related: https://news.ycombinator.com/item?id=32535637 https://news.ycombinator.com/item?id=32535637
- metadat 4y agoWhat difference would exposing counts make? Why should this data be mineable? We're already helping to create a training set of slightly above average English speaker discourse for free.
- O__________O 4y agoIf it was up to me, all data would be publicly available aside from emergency recovery email and password. This would include mod commutations and mod logs; unless it was security related, which would have a formal process with deadlines for release. —- To address you specific question as why the comment voting data would be of use, among other reasons, it would allow users to have custom filters. For example, posts and comments with high up/down votes tend to be flamewars. Mods also random boost/ding posts/comments too.
- metadat 4y agoI hear you, but what is the endgame with this? Does it lead to a better HN? Lobste.rs actually exposes even less and doesn't provide an API because the users haven't consented to such intrusions. Personally, I don't want to be able to review every vote for or against my HN account. It wouldn't be productive and would likely lead to me not wanting to be here at all. It'd be like having a super strong mirror and then looking at your skin and being confronted with too much information about the reality of how nasty looking and imperfect being human is. Basically not a healthy pastime. FWIW, if you're truly passionate about this, it's not difficult to setup your own site with the lobste.rs open-source code. Maybe there is a whole subset of like-minded folks. The lobste.rs origin story may also be of interest to you. The TL;DR is jcs was being singled out and abused by pg on HN. Thankfully there is no evidence dang has (or would ever) do this, it was certainly toxic behavior on Paul's part. Being a moderator isn't for everyone, it's a Certain Thing, and net-positive mods who avoid power tripping are truly rare gems on the Internet. Open information would guarantee such abuses couldn't happen in the dark, but at what cost to the best aspects enabled by the HN ecosystem? References: https://news.ycombinator.com/item?id=4452568 https://news.ycombinator.com/item?id=4452568 https://news.ycombinator.com/item?id=32112665 https://news.ycombinator.com/item?id=32112665
- shkaj 4y agoAnnoying how it doesn't show the text or anything for dead items. Is there any way to query this API as if showdead is switched on?
- avg_dev 4y agoI 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 :)
- dang 4y agoThe problem was that many third party apps and clients were displaying flagged and [dead] comments as if they were normal comments. Then we'd get angry emails about all the horrendous comments we were "condoning" when in fact the users posting them were as banned as banned could be.
- O__________O 4y agoWould be nice if HN was API first, which address number of the requests on this page.
- metadat 4y agoWould it be feasible to make a Firebase-to-Supabase connector? Having a self-hosted private HN Algolia (perhaps via Elasticsearch) would be nice. Algolia's forced fuzziness and limited number of results per page are a drag. Why can't they provide any search controls? Or at least support the "-" operator to exclude a term.
- examplary_cable 4y agoHow hard is it for HN to make its own API? so I could do something like: curl https://api.news.ycombinator.com/ https://api.news.ycombinator.com/
- avg_dev 4y agoMy understanding is that this is the official HN API. I think Firebase is a YC company. Others can correct me if I'm wrong. See the link at the bottom of every HN item page. Edit: I took a look, it seems like Firebase is owned by Google now, but it was original a YC-funded startup, judging by this page: https://www.crunchbase.com/funding_round/firebase-pre-seed--9860afed https://www.crunchbase.com/funding_round/firebase-pre-seed--...
- O__________O 4y agoYes, Firebase is listed on YC’s list of companies they have funded here: https://www.ycombinator.com/companies/firebase https://www.ycombinator.com/companies/firebase
- reneberlin 4y agoFirebase 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.
- easrng 4y agoI don't think it was owned by google when hn started using it for the API.
- gkoberger 4y agoI think using Google or not is pretty irrelevant, but I looked because I was curious. This repo started in 2015, and Firebase was bought in 2014. I'm really surprised; I thought it was way more recent than that.
- easrng 4y agoThe oldest snapshot from the domain on the wayback machine is from 12 days before it was acquired, and the API might be older than that.
- somishere 4y agoSwitch to Supabase?
- beltsazar 4y ago> The v0 API is essentially a dump of our in-memory data structures. TIL that HN doesn't use a "proper" / persistent DB. I wonder then how HN handles data persistence. Is it as simple as creating write-ahead logs + checkpointing every some duration?
- orf 4y agoSure they do, what they are saying is that the data format is just the raw format they use in memory after loading it from a database.
- krapp 4y agoNo they don’t. This forum was created as a MVP of a webapp using PG’s Arc Lisp. All user and comment data are stored as tables serialized to text files or in memory. You can find an old version of the code at http://arclanguage.org http://arclanguage.org
- orf 4y agoSo they do use a database? In the form of text files. The comment I was responding to was edited, and before it was asking if they stored everything in memory and how they handled reboots.
- Asdrubalini 4y agoI'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. [0] https://github.com/jpopesculian/reqwest-eventsource/ https://github.com/jpopesculian/reqwest-eventsource/
- password4321 4y agohttps://hnrankings.info/ https://hnrankings.info/
- NKosmatos 4y agoNice one, wish there was something similar for user rankings (with karma points).
- Asdrubalini 4y agoI know but it does not provide detailed and raw data, making it impossibile to do a bunch of interesting in-depth analysis. Also, I like to build this kind of stuff to explore async rust capabilities.
- mgdlbp 4y agoAlso https://upvotetracker.com/ https://upvotetracker.com/ Gives a few more variables, and the different sample times show a different set of transient effects.
- superb-owl 4y agoIf you're looking to get your comment scores, the API sadly will not oblige. I wrote a script that uses your browser cookies to scrape them from the website here: https://github.com/superb-owl/hacker-news-comments https://github.com/superb-owl/hacker-news-comments
- goranmoomin 4y agoOnly 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. [0]: https://hn.algolia.com/api https://hn.algolia.com/api [1]: https://github.com/goranmoomin/HackerNews https://github.com/goranmoomin/HackerNews
- CodesInChaos 4y agoIf you already parse the html, what's the point in calling the Algolia API at all?
- rajnathani 4y agoI believe HN's website has a rate-limiter even for viewing, which the HN API doesn't have.
- adamredwoods 4y agoI 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()). Van Puffelen answers some of this here, but he doesn't get into specific queries: https://www.youtube.com/watch?v=66lDSYtyils 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-multiple-where-clauses-in-firebase/26701282#26701282 https://stackoverflow.com/questions/26700924/query-based-on-...
- catnip09 4y agoYeah, I built a graphql API for HN for this reason. It will let you fetch all comments, users, and posts in a single request. https://hngraphql.fly.dev/graphql https://hngraphql.fly.dev/graphql
- ilaksh 4y agoIt would be interesting to see some live readout of the item updates (with context somehow).
- imnitishng 4y agoTiny project I built using the same API https://github.com/imnitishng/hkrnws https://github.com/imnitishng/hkrnws
- banana_giraffe 4y agoIf 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: https://gist.github.com/Q726kbXuN/15e61acc003bb6d46a458001fedf6829 https://gist.github.com/Q726kbXuN/15e61acc003bb6d46a458001fe...
- poofuck 4y agoHas anyone done a mass archiving of HN via this API? It would be a shame for this vast trove of expert knowledge and nerd sniping to vanish into the ether after the next hard drive apocalypse or similar.
- Freddie111 4y agoWhat interesting projects could be built/are built on top of this?
- krapp 4y agoI've been hacking on a read-only client in Godot for a while. I don't know if that's "interesting" though.
- avg_dev 4y agoI 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: > Searchers: try https://kennytilton.github.io/whoishiring/ https://kennytilton.github.io/whoishiring/, https://hnjobs.emilburzo.com https://hnjobs.emilburzo.com, https://news.ycombinator.com/item?id=10313519 https://news.ycombinator.com/item?id=10313519. It was fun; I enjoyed working on it.
- maxique 4y agoI'd still like to see yours if you're up to sharing! :)
- avg_dev 4y agoHi, thanks for your interest! I am definitely happy to share, but I didn’t expect any interest and I posted my comment under my HN pseudonym account. However when I link to the repo on GitHub that thin veneer of obscurity will disappear and I’d prefer that it did not. Being a programmer, I am quite familiar with workarounds and I am happy to offer you couple of different options: 1. You could add an email address to https://news.ycombinator.com/user?id=maxique https://news.ycombinator.com/user?id=maxique and I can email you there - I’m happy to share my name and contact info in a one-off request, just not on an ongoing basis for anyone to see. 2. I could clone the repo onto my current machine and delete the .git dir, leaving the code and the README.md intact, produce an archive of that stuff, and link it here in this thread. While I’m sure it may be possible to use a code search tool to find the repo on GitHub after that, I am not terribly bothered by that. I am open to other options as well if you have any suggestions. Finally, the code was written for whatever version of the Ruby interpreter (MRI) was current in 2016, in case that will dissuade your interest. EDIT: I have a bias to action, appreciate interest in my work, and figured it was likely that you would see my reply at some later point and then I'd have to see your reply to my reply at some even later point, and we'd continue the loop, and eventually your interest would wane. So I went with option two. Here you go: https://we.tl/t-Bu257EdQn9 https://we.tl/t-Bu257EdQn9 This is my first time using WeTransfer; let me know how it works out for you. I actually originally had a link that I hosted on file.io (which I've also never used before), but it looks like that gets automatically deleted after one download, which seems slightly excessive to me.
- fileeditview 4y agoFor 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.
- pid_0 4y ago
- qorrect 4y agoHow much does HN cost to run I wonder.
- CharlesW 4y agoYou may be able to determine that from this: https://news.ycombinator.com/item?id=16076041 https://news.ycombinator.com/item?id=16076041
- ashish01 4y agoI wrote a simple hn data downloaded based on this api. Last I remember I was able to download the entire corpus by letting it run overnight. https://github.com/ashish01/hn-data-dumps https://github.com/ashish01/hn-data-dumps
- breck 4y agoOh this might be exactly what I need. Giving it a try now. Thanks!
- andy_ppp 4y agoI’d like to build following and alerts for commenters I like here… is it possible on top of this or Algolia?
- hombre_fatal 4y agoWhy not look at the API and see for yourself?
- password4321 4y agoYes. https://news.ycombinator.com/item?id=8561849 https://news.ycombinator.com/item?id=8561849
- stefanvdw1 4y agoThe API is pretty nice to work with, I’ve used it to build an open source alternative HN client[0]. I do wish it would support login though, but you can’t have it all. 0. https://modernorange.io https://modernorange.io
- plibither8 4y agoSimilar 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. On GitHub: https://github.com/plibither8/hn-faves-api https://github.com/plibither8/hn-faves-api You can try it out here: https://hn-faves.mihir.ch https://hn-faves.mihir.ch
- AtroxDev 4y agoI 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. [0]: https://hnhub.dev/ https://hnhub.dev/ [1]: https://hn.algolia.com/api/ https://hn.algolia.com/api/
- kogir 4y agoIt always amuses me when the API link in the footer floats up as a submission every few years.
- krapp 4y agoIt's almost as if a color scheme of grey on grey makes features hard to notice.
- BeyondSchwifty 4y agoAnyone 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.
- dinkledunk 4y agoThere's been several, but they always get abandoned after a year or two.
- tailspin2019 4y agoDon’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!
- mavci 4y agoYou 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. [1] https://hnn.avci.me/ https://hnn.avci.me/
- olivialau595 4y agoWould you consider adding regex support as well?
- djbusby 4y agoCronjob to the Algolia Search API, send to your email.
- _iyhy 4y agoI wish it had auth
- dang 4y agoIn 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.
- yamrzou 4y agoI'd say about 6 months.
- arthurcolle 4y agoI would say a full calendar year is "generous" from the announcement date
- catnip09 4y agoCan you allow login and write operation via the API? I want to build a HN web client but it's not possible without scrapping the site which won't scale.
- ghosty141 4y agoIm typing this from the iOS app HACK which somehow allows for writing comments and upvoting etc.
- searchableguy 4y agoThey have to scrape the site in the background to work. While this is doable, any such client will need to follow the HN bot policy which limits the scrapping speed. Another issue is browser only client. If HN has set proper cors (I didn't check if it is the case), then you cannot build a web client through scrapping without proxy.
- dang 4y agoProbably not in the first release, but hopefully after that.
- 4y ago
- adamredwoods 4y agoI've never used Firebase before. Took a little while to dig through the docs, but finally would the web/js version for observing and get: https://firebase.google.com/docs/database/web/read-and-write https://firebase.google.com/docs/database/web/read-and-write
- justinhj 4y agoSince there is no update shouldn’t the headline have the year?
- dgudkov 4y agoHopefully, v1 will include webhooks.
- lmas 4y agoAn official RSS/Atom feed would be great too.
- password4321 4y agoShow HN: DeepHN – Full-text search of 30M Hacker News posts and linked webpages 20210413 https://news.ycombinator.com/item?id=26791582 https://news.ycombinator.com/item?id=26791582