1.1.0 • Published 9 years ago
quotzzy-node v1.1.0
An asynchronous client library for Quotzzy API.
Installation
npm install quotzzy-node
Quick Start
The quickest way to get started is by executing following code:
var quotzzy = require('quotzzy-node')();
quotzzy.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:
{
text: 'Ignorance never settle a question.',
author: {
name: 'Benjamin Disraeli',
wiki: 'http://en.wikipedia.com/wiki/Benjamin%20Disraeli'
}
}
Documentation
getQuote
Requests random quote.
Options
lang
(default:en
) - Response language (en
orru
).key
(default:undefined
) - Numeric key, which influences the choice of quotation, the maximum length is 6 characters.generateKey
(defaultfalse
) - Determines whether numeric key is auto-generated.
Examples
Requests quote in Russian with manually set key.
quotzzy.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.
quotzzy.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.