Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Query Lamernews from Node.js

branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

README.md

lamernews-api

Build Status

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
Something went wrong with that request. Please try again.