Socket
Socket
Sign inDemoInstall

yc-api

Package Overview
Dependencies
49
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    yc-api

This is a wrapper module around the Hacker News API. You can filter the news in order to show you only the stories with a minimum score.


Version published
Weekly downloads
2
decreased by-33.33%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

What is it?

This is a wrapper module around the Hacker News API. You can filter the news in order to show you only the stories with a minimum score.

Installation

As simple as npm install yc-api

Usages

Import the module with var yc-api = require('yc-api').

In the new es6 fashon import yc-pi from yc-api.

###get_top_stories_id(cb)

This take the top stories (IDs) from YC and return them into the callback.

###get_story(url,cb) Takes an url as argument and return into the callback a JSON object containing the story.

The returned object looks like this:

{
      "by" : "dhouston",
      "descendants" : 71,
      "id" : 8863,
      "kids" : [ 8952, 9224, 8917, 8884, 8887, 8943, 8869, 8958, 9005, 9671, 8940, 9067, 8908, 9055, 8865, 8881, 8872, 8873, 8955, 10403, 8903, 8928, 9125, 8998, 8901, 8902, 8907, 8894, 8878, 8870, 8980, 8934, 8876 ],
      "score" : 111,
      "time" : 1175714200,
      "title" : "My YC app: Dropbox - Throw away your USB drive",
      "type" : "story",
      "url" : "http://www.getdropbox.com/u/2/screencast.html"
  }

###get_stories(cb) Return into a callback an array of JSON object containing the stories.

###stories_with_score(score,cb) Same as get_stories but return into the object only the stories with the minimum score of score.

Example

stories_with_score(200,function (stories){
	console.log(stories);
});

Example

var yc-api = require('yc-api');
var async = require('async');

var yc = new yc-api.API;

yc.stories_with_score(500, function (stories)  {
    async.each(stories,function (story, cb)  {
        console.log(story.title);
        cb();
    }, function (err, res) {
        if (err) throw err;
        console.log('done');
    });
});

FAQs

Last updated on 22 Apr 2016

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