colourlovers

COLOURlovers for Node.js is a connection library for COLOURlovers API, giving you access to an infinite database of colors, palettes, patterns and a lot more provided by COLOURlovers.

npm install colourlovers
2 downloads in the last week
8 downloads in the last month

COLOURlovers API for Node.js

COLOURlovers API for Node.js is a connection library for COLOURlovers API, giving you access to an infinite database of colors, palettes, patterns and a lot more provided by COLOURlovers.

Installation

$ npm install colourlovers

Features

  • Pure JavaScript
  • Full access to COLOURlovers API
  • Lightweight - 1 dependency only (restler)!

Quick Start

First, add the module to your project:

var COLOURlovers = require('colourlovers');

Build your HTTP request using COLOURlovers API Documentation. Here's an example requesting the #FFFFFF hexadecimal color using the color ressource:

COLOURlovers.get('/color/FFFFFF', function(err, data) {
    if(err) throw err;
    console.log(data);
});

This will return you this JSON object:

http://www.colourlovers.com/api/color/FFFFFF?format=json

Here's a more complex HTTP request using the palettes ressource and a couple of GET parameters:

colourlovers.get('/palettes', {
        hueOption:  'blue',
        keywords:   'chartreuse',
        sortBy:     'DESC',
        numResults: 20
    },function(err, data) {
    if(err) throw err;
    console.log(data);
});

This will return you this JSON object:

http://www.colourlovers.com/api/palettes?format=json&hueOptions=blue&keywords=chartreuse&sortBy=DESC&numResults=20

Additional Information

By default, the module will return a JSON object. If you prefer to receive your data in XML format, populate the format key in your request options object like this:

COLOURlovers.get('/colors', { format: 'xml' }, function(err, data) {
    if(err) throw err;
    console.log(data);
});

More Information

License

Copyright (C) 2013, Jean-Philippe Monette contact@jpmonette.net

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

npm loves you