A clean Typescript client for the Hacker News API.
import HackerNews from 'hackernews-api-ts';
HackerNews.getStories(HackerNews.TYPE_TOP, 0, 5)
.then(stories => {
let i=1;
stories.forEach(story => console.log(`${i++}. ${story.title} [${story.score}] (${story.url})}`))
});
import HackerNews from 'hackernews-api-ts';
HackerNews.getUpdates().then(updates => console.log(updates));
import HackerNews from 'hackernews-api-ts';
HackerNews.getMaxItem()
.then(item => HackerNews.getUser(item.by))
.then(user => { if(user) console.log(`Latest item was posted by ${user.id} [${user.karma}]`) });
import HackerNews from 'hackernews-api-ts';
HackerNews.TYPES.forEach(type => {
HackerNews.getStories(type,0,1)
.then(stories => console.log(`Top ${type} story: ${stories[0].title}`));
});