This page hosts an unofficial Hacker News API that provides an easy access to YCombinator Hacker News data in JSON format. The API does not allow anonymous access and requires a key with every API request.

The API has been developed in 2011 for the Hacker News Droid app. Since then the API has been used by many other free apps and open-source projects. If you're looking for an API for a commercial project/app, please consider using the official Hacker News API; otherwise, if you need a key for your hobby project, please contact me.

The API is built in Python and makes use of the Hacker News Search API (hnsearch.com) as well as data scraping. Full source available on GitHub. For any questions please drop me a note ( ). Cheers, Gleb Popov. Last updated: 06/07/13.

API Index


Homepage API

Returns homepage news, including author, points, number of comments, etc  (JSON)

URL: http://hndroidapi.appspot.com/news/format/<format>/page/<page id>
App ID:  [Required] ID or Description of client/consumer app (e.g. HackerNewsDroid)
API Token:  [Required]
Callback:  [Optional] returns data in JSONP format (e.g. myAwesomeCallbackFunction)
Format: JSON


Comments by Post ID API

Returns nested post comments by id  (JSON)

URL: http://hndroidapi.appspot.com/nestedcomments/format/<format>/id/<id>
Post ID:  [Required] HN Post ID (e.g. 3423232)
App ID:  [Required] ID or Description of client/consumer app (e.g. HackerNewsDroid)
API Token:  [Required]
Callback:  [Optional] returns data in JSONP format (e.g. myAwesomeCallbackFunction)
Format: JSON


Data by Post ID API

Returns post data by id  (JSON)

URL: http://hndroidapi.appspot.com/post/format/<format>/id/<id>
Post ID:  [Required] HN Post ID (e.g. 3423232)
App ID:  [Required] ID or Description of client/consumer app (e.g. HackerNewsDroid)
API Token:  [Required]
Callback:  [Optional] returns data in JSONP format (e.g. myAwesomeCallbackFunction)
Format: JSON


Newest API

Returns new posts, including author, points, number of comments, etc  (JSON)

URL: http://hndroidapi.appspot.com/newest/format/<format>/page/<page id>
App ID:  [Required] ID or Description of client/consumer app (e.g. HackerNewsDroid)
API Token:  [Required]
Callback:  [Optional] returns data in JSONP format (e.g. myAwesomeCallbackFunction)
Format: JSON


Best API

Returns best content, including author, points, number of comments, etc  (JSON)

URL: http://hndroidapi.appspot.com/best/format/<format>/page/<page id>
App ID:  [Required] ID or Description of client/consumer app (e.g. HackerNewsDroid)
API Token:  [Required]
Callback:  [Optional] returns data in JSONP format (e.g. myAwesomeCallbackFunction)
Format: JSON


Ask HN API

Returns ask HN content, including author, points, number of comments, etc  (JSON)

URL: http://hndroidapi.appspot.com/ask/format/<format>/page/<page id>
App ID:  [Required] ID or Description of client/consumer app (e.g. HackerNewsDroid)
API Token:  [Required]
Callback:  [Optional] returns data in JSONP format (e.g. myAwesomeCallbackFunction)
Format: JSON


Submissions by User

Returns submissions by user, including author, points, number of comments, etc  (JSON)

URL: http://hndroidapi.appspot.com/submitted/format/<format>/user/<username>
Username:  [Required] HN Username (e.g. john1)
App ID:  [Required] ID or Description of client/consumer app (e.g. HackerNewsDroid)
API Token:  [Required]
Callback:  [Optional] returns data in JSONP format (e.g. myAwesomeCallbackFunction)
Format: JSON

API Updates


Update (04/29/13): Closing the API to public/anonymous access.

Update (02/11/13): Fixed the issue with long URLs in the comment string.

Update (01/25/13): New API to retrieve post data: http://hndroidapi.appspot.com/post/format/<format>/id/<id>

Update (12/23/12): Merry XMas Everyone! Fixed encoding issues and implemented a new HTML scraper for all API calls except the "Comments by Story ID" call using PHP. So, the AppEngine just calls the PHP service to retrieve JSON data.

Update (10/02/12): Trying to stay ahead of PG and the people that keep blocking my IPs . We setup an AWS instance to fetch/scrape data from the site. Big thanks to Eric Kigathi for helping to setup the instance.

Update (09/30/12): The servers got blacklisted again. Switched to another IP...Good times. The API is back on.

Update (09/09/12): Added JSONP support (thanks Brett)!

Update (09/08/12): Both of my servers got blacklisted by HN again (50.56.235.145 and 50.56.197.180). The API was down for a few hours - sorry guys. The servers are used in round-robin fashion to scrape data from HackerNews website and feed back to the AppEngine API app (this website). I added another server to the queue and they haven't blacklisted it yet :)

Update (05/22/12): One of the servers got blacklisted by HN....the API was down for a few hours.

Update (05/11/12): Removed Page ID parameter. The API no longer supports content pagination since it's disallowed (robots.txt) by HN site.

Update (05/07/12): New look&feel (this page). Started looking at HN Search API (api.hnsearch.com) for main content retrieval.

Update (05/05/12): The server got blacklisted again..so there was an outage for a few hours...I used another IP address, which isn't blacklisted (yet)...emailed PG and asked to whitelist IP addresses.

Update (01/04/12): Fixed the bug that was truncating last character in comments

Update (12/23/11): Reached AppEngine Quotas (DataStore DELETE) so had to enable billing for the app and modify API calls to handle errors better. The API and app are fully functional now.

Update (10/23/11): The API now supports nested comments as a new API call (/nestedcomments) (thanks to Suan Aik Yeo). The old comments API (/comments) has been deprecated.



Update (10/22/11): Thanks to my friend Eric I now have a dedicated server to handle API traffic. The API has been down for a few hours on Friday, October 21st because of GAE urlfetch (DownloadError: ApplicationError: 2) errors. Apparently, GAE started to deny requests to HN so the data had to be retrieved from another server. The API still runs on GAE but the data is being fetched from another server and then provided to GAE instances for processing.

Update (09/20/11): The API went live.