Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dmjio/hackernews
:newspaper: HackerNews API
https://github.com/dmjio/hackernews
ghcjs hacker-news-api haskell http-client servant
Last synced: about 1 month ago
JSON representation
:newspaper: HackerNews API
- Host: GitHub
- URL: https://github.com/dmjio/hackernews
- Owner: dmjio
- License: mit
- Created: 2014-10-09T16:21:35.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2017-12-27T17:32:36.000Z (about 7 years ago)
- Last Synced: 2024-04-15T14:22:43.321Z (9 months ago)
- Topics: ghcjs, hacker-news-api, haskell, http-client, servant
- Language: Haskell
- Homepage: http://hackage.haskell.org/package/hackernews
- Size: 104 KB
- Stars: 40
- Watchers: 5
- Forks: 9
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
hackernews
==========
![Hackage](https://img.shields.io/hackage/v/hackernews.svg)
![Hackage Dependencies](https://img.shields.io/hackage-deps/v/hackernews.svg)
![Haskell Programming Language](https://img.shields.io/badge/language-Haskell-blue.svg)
![MIT License](http://img.shields.io/badge/license-MIT-brightgreen.svg)
[![Build Status](https://travis-ci.org/dmjio/hackernews.svg?branch=master)](https://travis-ci.org/dmjio/hackernews)Hacker News API for Haskell
### Documentation
Now it supports GHCJS and can be used in the browser! Just install it using:
```bash
cabal install --ghcjs
```### Tests
```bash
cabal configure && cabal test
``````bash
HackerNews API tests
should round trip Updates JSON
should round trip Item JSON
should round trip User JSON
should retrieve item
should retrieve user
should retrieve max item
should retrieve top stories
should retrieve new stories
should retrieve best stories
should retrieve ask stories
should retrieve show stories
should retrieve job stories
should retrieve updatesFinished in 1.2129 seconds
13 examples, 0 failures
```### Usage
```haskell
module Main whereimport Network.HTTP.Client
import Network.HTTP.Client.TLSimport Web.HackerNews
main :: IO ()
main = do
mgr <- newManager tlsManagerSettings
print =<< getItem mgr (ItemId 1000)
print =<< getUser mgr (UserId "dmjio")
print =<< getMaxItem mgr
print =<< getTopStories mgr
print =<< getNewStories mgr
print =<< getBestStories mgr
print =<< getAskStories mgr
print =<< getShowStories mgr
print =<< getJobStories mgr
print =<< getUpdates mgr
``````bash
Right ( Item {
itemId = Just (ItemId 1000)
, itemDeleted = Nothing
, itemType = Story
, itemBy = Just (UserName "python_kiss")
, itemTime = Just (Time 1172394646)
, itemText = Nothing
, itemDead = Nothing
, itemParent = Nothing
, itemKids = Nothing
, itemURL = Just (URL "http://www.netbusinessblog.com/2007/02/19/how-important-is-the-dot-com/")
, itemScore = Just (Score 4)
, itemTitle = Just (Title "How Important is the .com TLD?")
, itemParts = Nothing
, itemDescendants = Just (Descendants 0)
})
Right (User {userId = UserId "dmjio"
, userDelay = Nothing
, userCreated = Created 1375807763
, userKarma = Karma 7
, userAbout = Nothing
, userSubmitted = Just (Submitted [11966297,9355613, ...])
})
Right (MaxItem 12695220)
Right (TopStories [12694004,12692190,12691597,...])
Right (NewStories [12695214,12695213,12695195,...])
Right (BestStories [12649414,12637126,12684980, ...])
Right (AskStories [12694706,12694401,12694038, ...])
Right (ShowStories [12694004,12692190,12695037, ...])
Right (JobStories [12693320,12691627,12690539,...])
Right (Updates { items = [12694916,12694478,12693674,..],
profiles = [UserName "stefano", UserName "chillydawg", ...]
})```