Skip to content

sbruchmann/lamernews-api

Repository files navigation

lamernews-api

Discontinued. See lamernews-client by @bevacqua.

Installation

Install with npm:

npm install --save lamernews-api

API

new LamernewsAPI(root);

Instantiates a new LamernewsAPI object and set its root property.

Parameters

root (required) [String]

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.

Usage

"use strict";

var LamernewsAPI = require("lamernews-api");

var api = new LamernewsAPI("http://echojs.com/api/");

LamernewsAPI#getNews(options, callback)

Returns news asynchronously.

Parameters

options (optional) [Object]
  • 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)
callback(err, response) (required) [Function]
  • err [Null, Error]
  • response [Object]

Usage

"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(err, response) {
    if (err) {
        throw err;
    }

    console.log(response.news);
});

LamernewsAPI#query(signature, callback)

Performs a asynchronous API query.

signature (String)

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

callback(err, response) (required) [Function]
  • err [Null, Error]
  • response [Object]

Usage

"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(err, response) {
    if (err) {
        throw err;
    }

    console.log(response);
});

Testing

From the repo root:

npm install
npm test

About

[DISCONTINUED] Query Lamernews from Node.js

Resources

License

Stars

Watchers

Forks

Packages

No packages published