hackernews-1.2.0.0: API for Hacker News

Copyright(c) David Johnson 2014-2016
Maintainerdjohnson.m@gmail.com
Stabilityexperimental
PortabilityPOSIX
Safe HaskellNone
LanguageHaskell2010

Web.HackerNews

Contents

Description

Synopsis

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))))))))) #

HackerNews API

Custom combinators

data HackerCapture a #

Custom combinator for appending '.json' to Item query

Instances

(ToHttpApiData a, HasClient * api) => HasClient * ((:>) * * (HackerCapture a) api) #

Custom combinator HasClient instance

Associated Types

type Client ((:>) * * (HackerCapture a) api) (api :: (:>) * * (HackerCapture a) api) :: * #

Methods

clientWithRoute :: Proxy ((* :> *) (HackerCapture a) api) api -> Req -> Client ((* :> *) (HackerCapture a) api) api #

type Client * ((:>) * * (HackerCapture a) api) # 
type Client * ((:>) * * (HackerCapture a) api) = a -> Client * api

API functions

Core Types

data Item #

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/.

Instances

Eq Item # 

Methods

(==) :: Item -> Item -> Bool #

(/=) :: Item -> Item -> Bool #

Show Item # 

Methods

showsPrec :: Int -> Item -> ShowS #

show :: Item -> String #

showList :: [Item] -> ShowS #

Generic Item # 

Associated Types

type Rep Item :: * -> * #

Methods

from :: Item -> Rep Item x #

to :: Rep Item x -> Item #

Arbitrary Item # 

Methods

arbitrary :: Gen Item #

shrink :: Item -> [Item] #

ToJSON Item # 
FromJSON Item # 
type Rep Item # 
type Rep Item = D1 (MetaData "Item" "Web.HackerNews.Types" "hackernews-1.2.0.0-DPqNZgR1ZdmLhphMu67gYR" False) (C1 (MetaCons "Item" PrefixI True) ((:*:) ((:*:) ((:*:) (S1 (MetaSel (Just Symbol "itemId") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe ItemId))) ((:*:) (S1 (MetaSel (Just Symbol "itemDeleted") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe Deleted))) (S1 (MetaSel (Just Symbol "itemType") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 ItemType)))) ((:*:) ((:*:) (S1 (MetaSel (Just Symbol "itemBy") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe UserName))) (S1 (MetaSel (Just Symbol "itemTime") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe Time)))) ((:*:) (S1 (MetaSel (Just Symbol "itemText") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe ItemText))) (S1 (MetaSel (Just Symbol "itemDead") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe Dead)))))) ((:*:) ((:*:) (S1 (MetaSel (Just Symbol "itemParent") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe Parent))) ((:*:) (S1 (MetaSel (Just Symbol "itemKids") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe Kids))) (S1 (MetaSel (Just Symbol "itemURL") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe URL))))) ((:*:) ((:*:) (S1 (MetaSel (Just Symbol "itemScore") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe Score))) (S1 (MetaSel (Just Symbol "itemTitle") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe Title)))) ((:*:) (S1 (MetaSel (Just Symbol "itemParts") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe Parts))) (S1 (MetaSel (Just Symbol "itemDescendants") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe Descendants))))))))

data User #

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.

Constructors

User 

Fields

Instances

Eq User # 

Methods

(==) :: User -> User -> Bool #

(/=) :: User -> User -> Bool #

Show User # 

Methods

showsPrec :: Int -> User -> ShowS #

show :: User -> String #

showList :: [User] -> ShowS #

Generic User # 

Associated Types

type Rep User :: * -> * #

Methods

from :: User -> Rep User x #

to :: Rep User x -> User #

Arbitrary User # 

Methods

arbitrary :: Gen User #

shrink :: User -> [User] #

ToJSON User # 
FromJSON User # 
type Rep User # 

data Updates #

The item and profile changes are at https://hacker-news.firebaseio.com/v0/updates

Constructors

Updates 

Fields

Instances

newtype MaxItem #

The current largest item id is at https://hacker-news.firebaseio.com/v0/maxitem. You can walk backward from here to discover all items.

Constructors

MaxItem ItemId 

Instances

Eq MaxItem # 

Methods

(==) :: MaxItem -> MaxItem -> Bool #

(/=) :: MaxItem -> MaxItem -> Bool #

Show MaxItem # 
Generic MaxItem # 

Associated Types

type Rep MaxItem :: * -> * #

Methods

from :: MaxItem -> Rep MaxItem x #

to :: Rep MaxItem x -> MaxItem #

Arbitrary MaxItem # 
ToJSON MaxItem # 
FromJSON MaxItem # 
type Rep MaxItem # 
type Rep MaxItem = D1 (MetaData "MaxItem" "Web.HackerNews.Types" "hackernews-1.2.0.0-DPqNZgR1ZdmLhphMu67gYR" True) (C1 (MetaCons "MaxItem" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 ItemId)))

newtype UserId #

The user's unique username. Case-sensitive. Required.

Constructors

UserId Text 

Instances

newtype ItemId #

The item's unique id.

Constructors

ItemId Int 

Instances

newtype Deleted #

true if the item is deleted.

Constructors

Deleted Bool 

Instances

Eq Deleted # 

Methods

(==) :: Deleted -> Deleted -> Bool #

(/=) :: Deleted -> Deleted -> Bool #

Show Deleted # 
Generic Deleted # 

Associated Types

type Rep Deleted :: * -> * #

Methods

from :: Deleted -> Rep Deleted x #

to :: Rep Deleted x -> Deleted #

Arbitrary Deleted # 
ToJSON Deleted # 
FromJSON Deleted # 
type Rep Deleted # 
type Rep Deleted = D1 (MetaData "Deleted" "Web.HackerNews.Types" "hackernews-1.2.0.0-DPqNZgR1ZdmLhphMu67gYR" True) (C1 (MetaCons "Deleted" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Bool)))

data ItemType #

The type of item. One of "job", "story", "comment", "poll", or "pollopt"

Constructors

Job 
Story 
Comment 
Poll 
PollOpt 

newtype UserName #

The username of the item's author.

Constructors

UserName Text 

Instances

newtype Time #

Creation date of the item, in Unix Time.

Constructors

Time Integer 

Instances

Eq Time # 

Methods

(==) :: Time -> Time -> Bool #

(/=) :: Time -> Time -> Bool #

Show Time # 

Methods

showsPrec :: Int -> Time -> ShowS #

show :: Time -> String #

showList :: [Time] -> ShowS #

Generic Time # 

Associated Types

type Rep Time :: * -> * #

Methods

from :: Time -> Rep Time x #

to :: Rep Time x -> Time #

Arbitrary Time # 

Methods

arbitrary :: Gen Time #

shrink :: Time -> [Time] #

ToJSON Time # 
FromJSON Time # 
type Rep Time # 
type Rep Time = D1 (MetaData "Time" "Web.HackerNews.Types" "hackernews-1.2.0.0-DPqNZgR1ZdmLhphMu67gYR" True) (C1 (MetaCons "Time" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Integer)))

newtype ItemText #

The comment, story or poll text. HTML.

Constructors

ItemText Text 

Instances

newtype Dead #

true if the item is dead.

Constructors

Dead Bool 

Instances

Eq Dead # 

Methods

(==) :: Dead -> Dead -> Bool #

(/=) :: Dead -> Dead -> Bool #

Show Dead # 

Methods

showsPrec :: Int -> Dead -> ShowS #

show :: Dead -> String #

showList :: [Dead] -> ShowS #

Generic Dead # 

Associated Types

type Rep Dead :: * -> * #

Methods

from :: Dead -> Rep Dead x #

to :: Rep Dead x -> Dead #

Arbitrary Dead # 

Methods

arbitrary :: Gen Dead #

shrink :: Dead -> [Dead] #

ToJSON Dead # 
FromJSON Dead # 
type Rep Dead # 
type Rep Dead = D1 (MetaData "Dead" "Web.HackerNews.Types" "hackernews-1.2.0.0-DPqNZgR1ZdmLhphMu67gYR" True) (C1 (MetaCons "Dead" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Bool)))

newtype Parent #

The item's parent. For comments, either another comment or the relevant story. For pollopts, the relevant poll.

Constructors

Parent ItemId 

Instances

Eq Parent # 

Methods

(==) :: Parent -> Parent -> Bool #

(/=) :: Parent -> Parent -> Bool #

Show Parent # 
Generic Parent # 

Associated Types

type Rep Parent :: * -> * #

Methods

from :: Parent -> Rep Parent x #

to :: Rep Parent x -> Parent #

Arbitrary Parent # 
ToJSON Parent # 
FromJSON Parent # 
type Rep Parent # 
type Rep Parent = D1 (MetaData "Parent" "Web.HackerNews.Types" "hackernews-1.2.0.0-DPqNZgR1ZdmLhphMu67gYR" True) (C1 (MetaCons "Parent" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 ItemId)))

newtype Kids #

The ids of the item's comments, in ranked display order.

Constructors

Kids [ItemId] 

Instances

Eq Kids # 

Methods

(==) :: Kids -> Kids -> Bool #

(/=) :: Kids -> Kids -> Bool #

Show Kids # 

Methods

showsPrec :: Int -> Kids -> ShowS #

show :: Kids -> String #

showList :: [Kids] -> ShowS #

Generic Kids # 

Associated Types

type Rep Kids :: * -> * #

Methods

from :: Kids -> Rep Kids x #

to :: Rep Kids x -> Kids #

Arbitrary Kids # 

Methods

arbitrary :: Gen Kids #

shrink :: Kids -> [Kids] #

ToJSON Kids # 
FromJSON Kids # 
type Rep Kids # 
type Rep Kids = D1 (MetaData "Kids" "Web.HackerNews.Types" "hackernews-1.2.0.0-DPqNZgR1ZdmLhphMu67gYR" True) (C1 (MetaCons "Kids" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [ItemId])))

newtype URL #

The URL of the story.

Constructors

URL Text 

Instances

Eq URL # 

Methods

(==) :: URL -> URL -> Bool #

(/=) :: URL -> URL -> Bool #

Show URL # 

Methods

showsPrec :: Int -> URL -> ShowS #

show :: URL -> String #

showList :: [URL] -> ShowS #

Generic URL # 

Associated Types

type Rep URL :: * -> * #

Methods

from :: URL -> Rep URL x #

to :: Rep URL x -> URL #

Arbitrary URL # 

Methods

arbitrary :: Gen URL #

shrink :: URL -> [URL] #

ToJSON URL # 
FromJSON URL # 
type Rep URL # 
type Rep URL = D1 (MetaData "URL" "Web.HackerNews.Types" "hackernews-1.2.0.0-DPqNZgR1ZdmLhphMu67gYR" True) (C1 (MetaCons "URL" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Text)))

newtype Score #

The story's score, or the votes for a pollopt.

Constructors

Score Int 

Instances

Eq Score # 

Methods

(==) :: Score -> Score -> Bool #

(/=) :: Score -> Score -> Bool #

Show Score # 

Methods

showsPrec :: Int -> Score -> ShowS #

show :: Score -> String #

showList :: [Score] -> ShowS #

Generic Score # 

Associated Types

type Rep Score :: * -> * #

Methods

from :: Score -> Rep Score x #

to :: Rep Score x -> Score #

Arbitrary Score # 

Methods

arbitrary :: Gen Score #

shrink :: Score -> [Score] #

ToJSON Score # 
FromJSON Score # 
type Rep Score # 
type Rep Score = D1 (MetaData "Score" "Web.HackerNews.Types" "hackernews-1.2.0.0-DPqNZgR1ZdmLhphMu67gYR" True) (C1 (MetaCons "Score" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Int)))

newtype Title #

The title of the story, poll or job.

Constructors

Title Text 

Instances

Eq Title # 

Methods

(==) :: Title -> Title -> Bool #

(/=) :: Title -> Title -> Bool #

Show Title # 

Methods

showsPrec :: Int -> Title -> ShowS #

show :: Title -> String #

showList :: [Title] -> ShowS #

Generic Title # 

Associated Types

type Rep Title :: * -> * #

Methods

from :: Title -> Rep Title x #

to :: Rep Title x -> Title #

Arbitrary Title # 

Methods

arbitrary :: Gen Title #

shrink :: Title -> [Title] #

ToJSON Title # 
FromJSON Title # 
type Rep Title # 
type Rep Title = D1 (MetaData "Title" "Web.HackerNews.Types" "hackernews-1.2.0.0-DPqNZgR1ZdmLhphMu67gYR" True) (C1 (MetaCons "Title" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Text)))

newtype Parts #

A list of related pollopts, in display order.

Constructors

Parts [ItemId] 

Instances

Eq Parts # 

Methods

(==) :: Parts -> Parts -> Bool #

(/=) :: Parts -> Parts -> Bool #

Show Parts # 

Methods

showsPrec :: Int -> Parts -> ShowS #

show :: Parts -> String #

showList :: [Parts] -> ShowS #

Generic Parts # 

Associated Types

type Rep Parts :: * -> * #

Methods

from :: Parts -> Rep Parts x #

to :: Rep Parts x -> Parts #

Arbitrary Parts # 

Methods

arbitrary :: Gen Parts #

shrink :: Parts -> [Parts] #

ToJSON Parts # 
FromJSON Parts # 
type Rep Parts # 
type Rep Parts = D1 (MetaData "Parts" "Web.HackerNews.Types" "hackernews-1.2.0.0-DPqNZgR1ZdmLhphMu67gYR" True) (C1 (MetaCons "Parts" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [ItemId])))

newtype Descendants #

In the case of stories or polls, the total comment count.

Constructors

Descendants Int 

newtype Delay #

Delay in minutes between a comment's creation and its visibility to other users.

Constructors

Delay Int 

Instances

Eq Delay # 

Methods

(==) :: Delay -> Delay -> Bool #

(/=) :: Delay -> Delay -> Bool #

Show Delay # 

Methods

showsPrec :: Int -> Delay -> ShowS #

show :: Delay -> String #

showList :: [Delay] -> ShowS #

Generic Delay # 

Associated Types

type Rep Delay :: * -> * #

Methods

from :: Delay -> Rep Delay x #

to :: Rep Delay x -> Delay #

Arbitrary Delay # 

Methods

arbitrary :: Gen Delay #

shrink :: Delay -> [Delay] #

ToJSON Delay # 
FromJSON Delay # 
type Rep Delay # 
type Rep Delay = D1 (MetaData "Delay" "Web.HackerNews.Types" "hackernews-1.2.0.0-DPqNZgR1ZdmLhphMu67gYR" True) (C1 (MetaCons "Delay" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Int)))

newtype Created #

Creation date of the user, in Unix Time.

Constructors

Created Int 

Instances

Eq Created # 

Methods

(==) :: Created -> Created -> Bool #

(/=) :: Created -> Created -> Bool #

Show Created # 
Generic Created # 

Associated Types

type Rep Created :: * -> * #

Methods

from :: Created -> Rep Created x #

to :: Rep Created x -> Created #

Arbitrary Created # 
ToJSON Created # 
FromJSON Created # 
type Rep Created # 
type Rep Created = D1 (MetaData "Created" "Web.HackerNews.Types" "hackernews-1.2.0.0-DPqNZgR1ZdmLhphMu67gYR" True) (C1 (MetaCons "Created" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Int)))

newtype Karma #

The user's karma.

Constructors

Karma Int 

Instances

Eq Karma # 

Methods

(==) :: Karma -> Karma -> Bool #

(/=) :: Karma -> Karma -> Bool #

Show Karma # 

Methods

showsPrec :: Int -> Karma -> ShowS #

show :: Karma -> String #

showList :: [Karma] -> ShowS #

Generic Karma # 

Associated Types

type Rep Karma :: * -> * #

Methods

from :: Karma -> Rep Karma x #

to :: Rep Karma x -> Karma #

Arbitrary Karma # 

Methods

arbitrary :: Gen Karma #

shrink :: Karma -> [Karma] #

ToJSON Karma # 
FromJSON Karma # 
type Rep Karma # 
type Rep Karma = D1 (MetaData "Karma" "Web.HackerNews.Types" "hackernews-1.2.0.0-DPqNZgR1ZdmLhphMu67gYR" True) (C1 (MetaCons "Karma" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Int)))

newtype About #

The user's optional self-description. HTML.

Constructors

About Text 

Instances

Eq About # 

Methods

(==) :: About -> About -> Bool #

(/=) :: About -> About -> Bool #

Show About # 

Methods

showsPrec :: Int -> About -> ShowS #

show :: About -> String #

showList :: [About] -> ShowS #

Generic About # 

Associated Types

type Rep About :: * -> * #

Methods

from :: About -> Rep About x #

to :: Rep About x -> About #

Arbitrary About # 

Methods

arbitrary :: Gen About #

shrink :: About -> [About] #

ToJSON About # 
FromJSON About # 
type Rep About # 
type Rep About = D1 (MetaData "About" "Web.HackerNews.Types" "hackernews-1.2.0.0-DPqNZgR1ZdmLhphMu67gYR" True) (C1 (MetaCons "About" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Text)))

newtype Submitted #

List of the user's stories, polls and comments.

Constructors

Submitted [ItemId]