0.1.3 • Published 11 years ago

lamernews-api v0.1.3

Weekly downloads
1
License
MIT
Repository
github
Last release
11 years ago

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

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

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
0.1.3

11 years ago

0.1.2

11 years ago

0.1.1

11 years ago

0.1.0

11 years ago