Hacker News API wrapper written in Crystal
All functions return JSON
-
Add the dependency to your
shard.yml
:dependencies: hn: github: crystal-libs/hn.cr
-
Run
shards install
require "hn"
user_agent = "[description]:[version] by @[username]"
hn = HN::HackerNews.new(user_agent)
hn.item("1")
#{"by" => "pg", "descendants" => 15, "id" => 1, "kids" => [15, 234509, 487171, 454426, 454424, 454410, 82729], "score" => 57, "time" => 1160418111, "title" => "Y Combinator", "type" => "story", "url" => "http://ycombinator.com"}
hn.user("test")
#{"about" => "", "created" => 1175289467, "delay" => 0, "id" => "test", "karma" => 1, "submitted" => [1043201, 1029445, 1026445, 586568, 418362, 418361, 11780]}
hn.max_item
#29832636
The function takes a required kind
argument. It must be one of the following:
- "new"
- "top"
- "best"
- "ask"
- "show"
- "job"
hn.get_stories(kind="ask")
#[29830770, 29826725, 29830214, 29825080, 29825844, ...]
hn.changed_items
#[29831564, 29832264, 29832633, 29832087, 29825303, ...]
hn.changed_profiles
#["throwawayboise", "givemeethekeys", "jorts", "vasco", "podge", ...]
TODO: Write development instructions here
- Fork it (https://github.com/crystal-libs/hn.cr/fork)
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
- gxfr - creator and maintainer