exhn v1.1.0 ExHN

Interface to the static endpoints of the Hacker News API.

See the API docs for more information.

Summary

Functions

Gets the item with the specified id

Returns a Stream of items from a given enum of id numbers

Gets the user with the specified name

Functions

item(id)
item(integer) :: {:ok, map} | {:error, String.t}

Gets the item with the specified id

Example

iex> ExHN.item(1)
{:ok,
  %{"by" => "pg", "descendants" => 15, "id" => 1,
    "kids" => [487171, 15, 234509, 454410, 82729], "score" => 61,
    "time" => 1160418111, "title" => "Y Combinator", "type" => "story",
    "url" => "http://ycombinator.com"}}
items(enum)
items(list | Range.t) :: Enumerable.t

Returns a Stream of items from a given enum of id numbers

Example

iex> ExHN.items(10..15) |> Enum.take(1)
[ok: %{"by" => "frobnicate", "descendants" => 0, "id" => 10, "kids" => [454419],
   "score" => 3, "time" => 1160421674,
   "title" => "PhotoShow: Broadcast Photos to Cable TV", "type" => "story",
   "url" => "http://www.techcrunch.com/2006/10/09/broadcast-photos-to-cable-tv/"}]
user(name)
user(String.t) :: {:ok, map} | {:error, String.t}

Gets the user with the specified name

Example

iex> {:ok, user} = ExHN.user("pg")
iex> user["created"]
1160418092