Copyright | (c) David Johnson 2014-2016 |
---|---|
Maintainer | djohnson.m@gmail.com |
Stability | experimental |
Portability | POSIX |
Safe Haskell | None |
Language | Haskell2010 |
Haskell port of https://github.com/HackerNews/API
- type HackerNewsAPI = ("item" :> (HackerCapture ItemId :> Get '[JSON] Item)) :<|> (("user" :> (HackerCapture UserId :> Get '[JSON] User)) :<|> (("maxitem.json" :> Get '[JSON] MaxItem) :<|> (("topstories.json" :> Get '[JSON] TopStories) :<|> (("newstories.json" :> Get '[JSON] NewStories) :<|> (("beststories.json" :> Get '[JSON] BestStories) :<|> (("askstories.json" :> Get '[JSON] AskStories) :<|> (("showstories.json" :> Get '[JSON] ShowStories) :<|> (("jobstories.json" :> Get '[JSON] JobStories) :<|> ("updates.json" :> Get '[JSON] Updates)))))))))
- data HackerCapture a
- getItem :: Manager -> ItemId -> IO (Either HackerNewsError Item)
- getUser :: Manager -> UserId -> IO (Either HackerNewsError User)
- getMaxItem :: Manager -> IO (Either HackerNewsError MaxItem)
- getTopStories :: Manager -> IO (Either HackerNewsError TopStories)
- getNewStories :: Manager -> IO (Either HackerNewsError NewStories)
- getBestStories :: Manager -> IO (Either HackerNewsError BestStories)
- getAskStories :: Manager -> IO (Either HackerNewsError AskStories)
- getShowStories :: Manager -> IO (Either HackerNewsError ShowStories)
- getJobStories :: Manager -> IO (Either HackerNewsError JobStories)
- getUpdates :: Manager -> IO (Either HackerNewsError Updates)
- data Item = Item {
- itemId :: Maybe ItemId
- itemDeleted :: Maybe Deleted
- itemType :: ItemType
- itemBy :: Maybe UserName
- itemTime :: Maybe Time
- itemText :: Maybe ItemText
- itemDead :: Maybe Dead
- itemParent :: Maybe Parent
- itemKids :: Maybe Kids
- itemURL :: Maybe URL
- itemScore :: Maybe Score
- itemTitle :: Maybe Title
- itemParts :: Maybe Parts
- itemDescendants :: Maybe Descendants
- data User = User {}
- data Updates = Updates {}
- newtype MaxItem = MaxItem ItemId
- newtype TopStories = TopStories [ItemId]
- newtype NewStories = NewStories [ItemId]
- newtype BestStories = BestStories [ItemId]
- newtype AskStories = AskStories [ItemId]
- newtype ShowStories = ShowStories [ItemId]
- newtype JobStories = JobStories [ItemId]
- newtype UserId = UserId Text
- newtype ItemId = ItemId Int
- newtype Deleted = Deleted Bool
- data ItemType
- newtype UserName = UserName Text
- newtype Time = Time Integer
- newtype ItemText = ItemText Text
- newtype Dead = Dead Bool
- newtype Parent = Parent ItemId
- newtype Kids = Kids [ItemId]
- newtype URL = URL Text
- newtype Score = Score Int
- newtype Title = Title Text
- newtype Parts = Parts [ItemId]
- newtype Descendants = Descendants Int
- newtype Delay = Delay Int
- newtype Created = Created Int
- newtype Karma = Karma Int
- newtype About = About Text
- newtype Submitted = Submitted [ItemId]
- data HackerNewsError
Hacker News API
type HackerNewsAPI = ("item" :> (HackerCapture ItemId :> Get '[JSON] Item)) :<|> (("user" :> (HackerCapture UserId :> Get '[JSON] User)) :<|> (("maxitem.json" :> Get '[JSON] MaxItem) :<|> (("topstories.json" :> Get '[JSON] TopStories) :<|> (("newstories.json" :> Get '[JSON] NewStories) :<|> (("beststories.json" :> Get '[JSON] BestStories) :<|> (("askstories.json" :> Get '[JSON] AskStories) :<|> (("showstories.json" :> Get '[JSON] ShowStories) :<|> (("jobstories.json" :> Get '[JSON] JobStories) :<|> ("updates.json" :> Get '[JSON] Updates))))))))) Source #
HackerNews API
Custom combinators
data HackerCapture a Source #
Custom combinator for appending '.json' to Item
query
API functions
getMaxItem :: Manager -> IO (Either HackerNewsError MaxItem) Source #
Retrieve MaxItem
getTopStories :: Manager -> IO (Either HackerNewsError TopStories) Source #
Retrieve TopStories
getNewStories :: Manager -> IO (Either HackerNewsError NewStories) Source #
Retrieve NewStories
getBestStories :: Manager -> IO (Either HackerNewsError BestStories) Source #
Retrieve BestStories
getAskStories :: Manager -> IO (Either HackerNewsError AskStories) Source #
Retrieve AskStories
getShowStories :: Manager -> IO (Either HackerNewsError ShowStories) Source #
Retrieve ShowStories
getJobStories :: Manager -> IO (Either HackerNewsError JobStories) Source #
Retrieve JobStories
getUpdates :: Manager -> IO (Either HackerNewsError Updates) Source #
Retrieve Updates
Core Types
Stories, comments, jobs, Ask HNs and even polls are just items. They're identified by their ids, which are unique integers, and live under https://hacker-news.firebaseio.com/v0/item/.
Item | |
|
Users are identified by case-sensitive ids, and live under https://hacker-news.firebaseio.com/v0/user/. Only users that have public activity (comments or story submissions) on the site are available through the API.
User | |
|
The item and profile changes are at https://hacker-news.firebaseio.com/v0/updates
The current largest item id is at https://hacker-news.firebaseio.com/v0/maxitem. You can walk backward from here to discover all items.
newtype TopStories Source #
newtype NewStories Source #
newtype BestStories Source #
newtype AskStories Source #
newtype ShowStories Source #
newtype JobStories Source #
The user's unique username. Case-sensitive. Required.
The item's unique id.
true
if the item is deleted.
The type of item. One of "job", "story", "comment", "poll", or "pollopt"
The username of the item's author.
Creation date of the item, in Unix Time.
The comment, story or poll text. HTML.
true
if the item is dead.
The item's parent. For comments, either another comment or the relevant story. For pollopts, the relevant poll.
The ids of the item's comments, in ranked display order.
The URL of the story.
The story's score, or the votes for a pollopt.
The title of the story, poll or job.
A list of related pollopts, in display order.
newtype Descendants Source #
In the case of stories or polls, the total comment count.
Delay in minutes between a comment's creation and its visibility to other users.
Creation date of the user, in Unix Time.
The user's karma.
The user's optional self-description. HTML.
List of the user's stories, polls and comments.
data HackerNewsError Source #
Error handling for HackerNewsAPI