Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hackernews-api-ts

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hackernews-api-ts

Hackernews v0 API wrapper in Typescript

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Hacker News Typescript API

A clean Typescript client for the Hacker News API.

Dependencies

Examples

Get newest stories

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})}`))
    });

List item/user updates

import HackerNews from 'hackernews-api-ts';

HackerNews.getUpdates().then(updates => console.log(updates));

Get user info for user of newest post

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}]`) });

Get top posts for each category

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}`));
});

Keywords

FAQs

Package last updated on 18 May 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc