1.1.4 • Published 9 years ago

forismatic-node v1.1.4

Weekly downloads
18
License
MIT
Repository
github
Last release
9 years ago

forismatic-node Logo

An asynchronous client library for Forismatic API.

NPM Package Version NPM Package License NPM Package Downloads Dependencies Status devDependencies Status

Node Version Travis CI Build Status Code Climate Status Code Climate Test Coverage Status Inch CI Documentation Coverage Status

NPM Package Statistics

Installation

npm install forismatic-node

Quick Start

The quickest way to get started is by executing following code:

var forismatic = require('forismatic-node')();

forismatic.getQuote(function (error, quote) {
    if (!error) {
        console.log(quote);
    } else {
        console.error(error);
    }
});

If everything went well, you'll see something like this in your console:

{
    quoteText: 'Ignorance never settle a question.',
    quoteAuthor: 'Benjamin Disraeli',
    senderName: '',
    senderLink: '',
    quoteLink: 'http://forismatic.com/en/33ae3b318c/'
}

Documentation

getQuote

Requests random quote.

Options

  • lang(default: en) - Response language (en or ru).
  • key(default: undefined) - Numeric key, which influences the choice of quotation, the maximum length is 6 characters.
  • generateKey(default false) - Determines whether numeric key is auto-generated.

Examples

Requests quote in Russian with manually set key.

forismatic.getQuote({
    lang: 'ru',
    key: 123456
}, function (error, quote) {
    if (!error) {
        console.log(quote);
    } else {
        console.error(error);
    }
});

Requests quote in English with auto-generated key.

forismatic.getQuote({
    lang: 'en',
    generateKey: true
}, function (error, quote) {
    if (!error) {
        console.log(quote);
    } else {
        console.error(error);
    }
});

Errors

When errors occur, you receive an error object with default properties as a first argument of the callback.

Tests

To run the test suite, first install the dependencies, then run npm test:

$ npm install
$ npm test

License

Distributed under the MIT License.

1.1.4

9 years ago

1.1.3

9 years ago

1.1.2

10 years ago

1.1.1

10 years ago

1.1.0

10 years ago

1.0.9

10 years ago

1.0.8

10 years ago

1.0.7

10 years ago

1.0.6

10 years ago

1.0.5

10 years ago

1.0.4

10 years ago

1.0.3

10 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago