Skip to content

A Node.js client library for seamless integration with Algolia's kickass Hacker News API.

License

Notifications You must be signed in to change notification settings

fraction/node-hacker-news-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

7777c87 · May 30, 2014

History

51 Commits
May 30, 2014
Apr 12, 2014
Apr 12, 2014
May 30, 2014
May 30, 2014

Repository files navigation

Node.js Hacker News API

A Node.js library for seamless integration with Algolia's kickass Hacker News API.

Installation

npm install hacker-news-api

Examples

Some methods only require a callback.

var hn = require('hacker-news-api');

hn.getLastPolls(function (error, data) {
  if (error) throw error;
  console.log(data);
});

Some methods require a string and a callback.

var hn = require('hacker-news-api');

hn.getUserStories('pg', function (error, data) {
  if (error) throw error;
  console.log(data);
});

Some methods require an object and a callback.

var hn = require('hacker-news-api');

hn.search({
  query: 'javascript',
  tags: 'poll'
}, function (error, data) {
  if (error) throw error;
  console.log(data);
});

Methods

Callback only

  • getComments(cb)
  • getLastComments(cb);
  • getPolls(cb)
  • getLastPolls(cb)
  • getPosts(cb)
  • getLastPosts(cb)
  • getStories(cb)
  • getLastStories(cb)

String and callback

  • getItem(id, cb)
  • getUser(username, cb)
  • getUserComments(username, cb)
  • getLastUserComments(username, cb)
  • getUserPolls(username, cb)
  • getLastUserPolls(username, cb)
  • getUserStories(username, cb)
  • getLastUserStories(username, cb)
  • searchComments(query, cb)
  • searchLastComments(query, cb)
  • searchPosts(query, cb)
  • searchLastPosts(query, cb)
  • searchStories(query, cb)
  • searchLastStories(query, cb)

Object and callback

  • search(obj, cb)
  • searchLast(obj, cb)