Socket
Socket
Sign inDemoInstall

hn-api-client

Package Overview
Dependencies
7
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    hn-api-client

A isomorphic client for Hacker News API


Version published
Weekly downloads
0
Maintainers
1
Install size
578 kB
Created
Weekly downloads
 

Readme

Source

hn-api-client npm

A isomorphic api client for Hacker News API

Installation

yarn i hn-api-client
or
npm i hn-api-client

Usage

const hnApiClient = require('hn-api-client')

.getItem(id)

await hnApiClient.getItem(8863);

/*{ 
  by: 'dhouston',
  descendants: 71,
  id: 8863,
  kids: [...],
  title: 'My YC app: Dropbox - Throw away your USB drive',
  type: 'story',
  ...
}*/

Sample Output


.getUser(id)

await hnApiClient.getUser('Malfunction92');

/*{
  created: 1451669897,
  id: 'Malfunction92',
  karma: 34,
  submitted: [ 10867439, 10822491, ... ]
 }*/

Sample Output


.getMaxItemID(id)

await hnApiClient.getMaxItemID();

/*18920326*/

Sample Output


.getTopStories()

await hnApiClient.getTopStories();

/*[
  {by: 'dankohn1', id: 18912321, kids: [18920127, 18919744, ...], score: 179,  ... }, 
  {by: 'vbezhenar', id: 18919543, kids: [18920212, 18919663, ...], score: 22,  ... },
  ...
]*/

/* To get only ids of stories: */
await hnApiClient.getTopStories({onlyIds: true});

/*[
  18912321,
  18919543]
 */

You can use the following similar methods 
await hnApi.getNewStories()
await hnApi.getBestStories()
await hnApi.getAskStories()
await hnApi.getShowStories()
await hnApi.getJobStories()

.getUpdates()

await hnApiClient.getUpdates();


/* {
  items: [18919919, 18916487, 18920263, ...],
  users: ["blopeur", "sascha_sl", "doppp", ...]
*/

Sample Output

FAQs

Last updated on 19 Jan 2019

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc