Installation
$ npm install hack-news
Usage
Top Stories
The examples below show how to access the IDs of the top stories on Hacker News.
var hn = ; //Returns an array of all the article ids for the top stories on hacker news hn; //Using Promiseshn; /*Returns an array of article ids in the amount of your choice.So if you wanted the top ten stories on Hacker News it would look like this.*/ hn; //Using Promiseshn;
New Stories
The examples below show how to access the IDs of the new stories on Hacker News.
var hn = ; //Returns an array of all the article ids for the new stories on hacker newshn; //Using Promiseshn; /*Returns an array of article ids in the amount of your choice.So if you wanted the top ten newest stories on Hacker News it would look like this.*/hn; //Using Promiseshn;
Ask, Show and Job Stories
The examples below show how to access the IDs of Ask, Show and Job stories on Hacker News.
var hn = ; //Returns an array of all the article ids for Ask, Show and Job stories on hacker news.//Just place 'ask', 'show', or 'job' as the first parameter to retrieve the array you need.hn; //Using Promiseshn; //If you wanted the Top Ten Ask, Show, Job you ca use the numbOfAskShowOrJobStories method like so.hn; //Using Promiseshn;
IDs
The examples below show how to select a single story with its ID you can also use the ID method with the other methods provided.
All items have some of the following properties, with required properties in bold.
Field | Description |
---|---|
id | The item's unique id. |
deleted | true if the item is deleted. |
type | The type of item. One of "job", "story", "comment", "poll", or "pollopt". |
by | The username of the item's author. |
time | Creation date of the item, in Unix Time. |
text | The comment, story or poll text. HTML. |
dead | true if the item is dead. |
parent | The item's parent. For comments, either another comment or the relevant story. For pollopts, the relevant poll. |
kids | The ids of the item's comments, in ranked display order. |
url | The URL of the story. |
score | The story's score, or the votes for a pollopt. |
title | The title of the story, poll or job. |
parts | A list of related pollopts, in display order. |
descendants | In the case of stories or polls, the total comment count. |
var hn = ; //This will return a object filled with data corresponding to the ID that was used.hn; //Used with another methodhn; //Using Promiseshn; //Used with another method.hn;
Users
The examples below show how to select a single user with his or hers ID you can also use the user method with the other methods provided.
All users have some of the following properties, with required properties in bold.
Field | Description |
---|---|
id | The user's unique username. Case-sensitive. Required. |
delay | Delay in minutes between a comment's creation and its visibility to other users. |
created | Creation date of the user, in Unix Time. |
karma | The user's karma. |
about | The user's optional self-description. HTML. |
submitted | List of the user's stories, polls and comments. |
var hn = ; //This will return a object filled with data corresponding to the ID that was used.hn; //Used with another methodhn; //Using Promiseshn; //Used with another method.hn;
Changed items and profiles
The examples below show how to access the changed or updated items and profiles on Hacker News.
var hn = ; //This will return a object with two properties, one for the items and another for the profiles.hn; //Using Promiseshn;
Max Item
The examples below show how to grab the max item on hacker news.
var hn = ; //This will return the max item.hn; //Using Promiseshn;