lamernews-api

Query the Lamernews API from Node.js

lamernews-api

Install with npm:

npm install --save lamernews-api

Instantiates a new LamernewsAPI object and set its root property.

The root of the API. For example, if you want to use the API of EchoJS, you have to set http://echojs.com/ as root.

"use strict";
 
var LamernewsAPI = require("lamernews-api");
 
var api = new LamernewsAPI("http://echojs.com/api/");

Returns news asynchronously.

  • count [Number]: How many news should be returned (default: 30, max: 30)
  • start [Number]: Return news starting at start (default: 0)
  • type [String]: top or latest (default: latest)
  • err [Null, Error]
  • response [Object]
"use strict";
 
var LamernewsAPI = require("lamernews-api");
 
var api = new LamernewsAPI("http://echojs.com/api/");
var options = {
  count: 5,
  type: "top"
};
 
api.getNews(options, function onDone(errresponse) {
    if (err) {
        throw err;
    }
 
    console.log(response.news);
});

Performs a asynchronous API query.

API signature. Please take a look at the source of Lamernews for documentation.

  • err [Null, Error]
  • response [Object]
"use strict";
 
var LamernewsAPI = require("lamernews-api");
 
var api = new LamernewsAPI("http://echojs.com/api/");
var signature = "/login?username=sbruchmann&password=thisisnotmypassword";
 
api.query(signature, function onDone(errresponse) {
    if (err) {
        throw err;
    }
 
    console.log(response);
});

From the repo root:

npm install
npm test