Please review my API for HackerNews
api.ihackernews.com
api.ihackernews.com
/users/{username}/posts instead of /by/{username}
or
/posts/{id}/comments instead of /comments/{id}
And how come threads are indexed by userid but posts are indexed by username? These kinds of things are the things that slip by developers and give them headaches. I can easily imagine not noticing the username/userid switch and being like "WTF!? 404?!" for a while.
I would expect the standard REST paths would a) make it easier to guess the paths and b) allow for simpler URL generation in client apps (you can generate the url for a user and then just tag on /comments or /posts to get the url for those things)
REST is Hypertext As The Engine Of Application State — the default modus of ActionController::Routing::Routes has nothing to do with it.
A design that uses only opaque UUIDs as names for resources and reveals them to the client via links in the responses is perfect REST. Clean-looking URIs are a distraction, except that they tend to be easier to preserve across software rewrites.
For those wanting debugging tools for JSON APIs (a common request for the APIs I operate):
* JSONView, an addon for Firefox that prints nice-looking JSON from the URLs of the API. https://addons.mozilla.org/en-US/firefox/addon/10869/
* Tidy JSON, a command line tool. http://www.raboof.com/Projects/TidyJson/
Link: http://blog.edparcell.com/how-i-added-my-hacker-news-saved-s...
Your API has advantages and disadvantages against this approach: On the upside, it provides a uniform way for all languages to access content from HN, which is really cool.
On the downside, all requests through your API have to flow through your server - this makes me uneasy for two reasons: First that you could switch off your servers, esp. if take-up is high and you are not being compensated sufficiently for running them. And second, because I'm uncomfortable authenticating to an intermediary.
http://github.com/anoopengineer/jhackernews
Currently supports only fetching of News pages - top pages, new pages and ask HN pages. Support for comments and voting to be added soon.
Licensed under Apache 2.0 license.
Regarding security, you are proxying login credentials through your server. Is that correct? I'd suggest putting up information regarding your privacy policy, if you store any credentials information and the security of your server(s).
FYI, I don't store any data at all. The username and password are required to get an auth token from HN, which is only needed for voting and commenting. The token is what's stored in the cookie that HN issues.
That would lessen the load on the HN servers considerably, especially if your service becomes more popular.
It seems to support automating things things that are almost certainly better off left un-automated - posting, voting, commenting.
It doesn't support anything that might be interesting to automate - say, asynchronous notification on replies to me, posting or commenting on my url, mention of my name, mention of keywords I care about, etc.
It asks for HN credentials.
Nit, but still a little lame - lifts the HN favicon.
this api is just extracting what he already built for ihackernews and allowing others to use it, I would be very very surprised if pg banned it, if it causes any issues then they can pretty surely be sorted out.
It could violate terms of service as it could at its most basic level scrape Hacker News for this information, but there hasn't been any issue with it so far.
Not really relevant to anything I said.
this api is just extracting what he already built for ihackernews and allowing others to use it
There are actually significant downsides to 'others using it'. One is that it becomes a single point of failure for anyone using it. It's essentially a proxy so one abusive user could make HN ban the whole thing and everyone else with it. Same goes for downtime, etc.
Similarly, it introduces a third party in the authentication process for relatively little value and significant risk.
I could well be missing something but I just haven't come up with very many reasons such a service is a good idea to counter the many obvious ways in which it is a bad one.
By ignoring the fact that this was built for a practical purpose, and only mentioning ways that it could be abused implied that the author had bad intentions when writing it, I was clarifying that for everyone else, he should be thanked for ihackernews at the least.
I didnt say there was no downsides to people using it, but people can figure that out for themselves, there are also significant advantages over 1. not writing code yourself, and 2. caching and sharing the load from this domain, we already know that this site has stability issues and bots can quite easily affect the load, even if all people do with this api is create new ui's for hacker news then it would be worth it, I am pretty surprised that is the only useful thing you can see it being used for, there is obviously a lot of use cases.
No it didn't imply anything of the sort. And whether something is built for a practical purpose or not is, in fact, not relevant to whether it's stupid or not. My point was that I think having this is a public web service is stupid and I explained why. The practical purposes you speak of could have been achieved just as easily by releasing the code so people interested in such functionality can use it as a library or host the service themselves.
"children":[{"postedBy":"ronnier","postedAgo":"21 hours
ago","comment":"\u003cfont \u003eThanks, I\u0027ll look
at this tonight and get it
fixed.\u003c/fontu003e","id":1694452,"points":1,
"parentId":1694340,"postId":1694049,"cachedOn":
"\/Date(-62135575200000)\/","children":[]}]}
Thanks!Two questions, curious as I'm as well in the process of indexing HN, and your API may help me avoid this:
- how much content are you actually indexing ? Do you keep every single post or only the ones that do it on the home page or ask HN ? How far in time did you go ?
- do you have some way to implement a full-text search (eg: posts that contain a specific word, to be accurate) ?
http://jsonpify.appspot.com/?url=http://api.ihackernews.com/...
Which it probably doesn't.
Of course I could just do it myself, but it seemed like silly work going from C# > REST > C# :)