hn-api-client

0.1.1 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i hn-api-client

Weekly Downloads

0

Version

0.1.1

License

MIT

Unpacked Size

5.3 kB

Total Files

5

Last publish

Collaborators

  • abdullahtariq1171