Live data from Hacker News

Show HN: News API

hackednews.herokuapp.com

1–6 of 6 posts

Show HN: News API

#1
The resources are transmitted via JSON responses. This was a bit of fun.

API:

{path:"/"}, {path:"/news"}, {path:"/news2"}, {path:"/newest"}, {path:"/newcomments"}, {path:"/ask"}, {path:"/x", uri: (req) -> "/x?fnid=#{req.query.fnid}" }, {path:"/user", uri: (req) -> "/user?id=#{req.query.id}" }, {path:"/item", uri: (req) -> "/item?id=#{req.query.id}"}, {path:"/submitted", uri: (req) -> "/submitted?id=#{req.query.id}"}, {path:"/threads", uri: (req) -> "/threads?id=#{req.query.id}"}],

Source:

https://github.com/blackjable/hackednews

Show HN: News API
hackednews.herokuapp.com

Re: Show HN: News API

#3
post #2

Looks like a great start. Any plans to do comments?

The API is here:

{path:"/"}

{path:"/news"}

{path:"/news2"}

{path:"/newest"}

{path:"/newcomments"}

{path:"/ask"}

{path:"/x", uri: (req) -> "/x?fnid=#{req.query.fnid}" }

{path:"/user", uri: (req) -> "/user?id=#{req.query.id}" }

{path:"/item", uri: (req) -> "/item?id=#{req.query.id}"}

{path:"/submitted", uri: (req) -> "/submitted?id=# {req.query.id}"}

{path:"/threads", uri: (req) -> "/threads?id=#{req.query.id}"}

not everything is implemented. Its mostly readonly view of the resources.

Code is here:

https://github.com/blackjable/hackednews

Re: Show HN: News API

#4
post #2

Looks like a great start. Any plans to do comments?

The API is here: {path:"/"} {path:"/news"} {path:"/news2"} {path:"/newest"} {path:"/newcomments"} {path:"/ask"} {path:"/x", uri: (req) -> "/x?fnid=#{req.query.fnid}" } {path:"/user", uri: (req) -> "/user?id=#{req.query.id}" } {path:"/item", uri: (req) -> "/item?id=#{req.query.id}"} {path:"/submitted", uri: (req) -> "/submitted?id=# {req.query.id}"} {path:"/threads", uri: (req) -> "/threads?id=#{req.query.id}"} not ev…

Oh very nice. I was doing some server side scraping of HN content a little while back and it was a pain. I would have much preferred to use an API or something. Have you gotten banned a bunch of times yet or are you getting around that somehow?

Re: Show HN: News API

#5
post #4

Earlier quoted context omitted.

The API is here: {path:"/"} {path:"/news"} {path:"/news2"} {path:"/newest"} {path:"/newcomments"} {path:"/ask"} {path:"/x", uri: (req) -> "/x?fnid=#{req.query.fnid}" } {path:"/user", uri: (req) -> "/user?id=#{req.query.id}" } {path:"/item", uri: (req) -> "/item?id=#{req.query.id}"} {path:"/submitted", uri: (req) -> "/submitted?id=# {req.query.id}"} {path:"/threads", uri: (req) -> "/threads?id=#{req.query.id}"} not ev…

Oh very nice. I was doing some server side scraping of HN content a little while back and it was a pain. I would have much preferred to use an API or something. Have you gotten banned a bunch of times yet or are you getting around that somehow?

I'm not hitting it that often and no one is really using the API yet so I haven't hit any limits.

If I do get banned because of excess use I would stop and put some caching in place or something. I didnt want tot start with a cache because I wanted information from the site to be up to date as possible. HN data changes really quickly, as you know.

Re: Show HN: News API

#6
post #4

Earlier quoted context omitted.

Oh very nice. I was doing some server side scraping of HN content a little while back and it was a pain. I would have much preferred to use an API or something. Have you gotten banned a bunch of times yet or are you getting around that somehow?

I'm not hitting it that often and no one is really using the API yet so I haven't hit any limits. If I do get banned because of excess use I would stop and put some caching in place or something. I didnt want tot start with a cache because I wanted information from the site to be up to date as possible. HN data changes really quickly, as you know.

Yeah, absolutely. I got into issues when I was trying to parse the comments for the top 20. If you hit the top 20 and pull down the comments you'll get banned. I ended up giving up on my iOS app because once any real usage started the server was instantly banned (even with 5 minute delay between updating). I ended up realizing that I would have to parse it client side (in obj-c). But then again, I'm not that smart so maybe I was over complicating it.