clara
v0.4.11
Published
Clara.io API wrapper
Downloads
14
Readme
Clara.io api bindings for node.js
Installation
npm install clara
Quick start
$ npm install clara
$ clara set apiToken <api-token>
$ clara set username <username>
$ clara scenes:get <uuid>
API Overview
Create a clara
instance with your api token and username:
// Visit https://clara.io/settings/api for your api token
var clara = require('clara')({apiToken: 'your-api-token', username: 'your-username'});
Every resource method returns a promise, or accepts an optional callback.
clara.scenes.list().then(function(scenes) {
}).catch(function(err) {
});
With callbacks:
clara.scenes.list({}, function(err, scenes) {
});
The parameters for each resource method are:
- queryOptions: {Object} Any query parameters required for the call.
- params: {Object|String} (Optional) The data for the method. If this is a string, the library will expect a filename to a json file that will be parsed and sent.
- callback: {Function}
clara.scenes.update({sceneId: 'scene-id'}, './scene.json', function(err, result) {});
clara.scenes.create({}, function(err, newScene) {});
Command line overview
All commands are available from the command line runner as well.
$ clara --help
$ clara scenes:get --help
$ clara --apiToken <apiToken> --username <username> scenes:get <sceneId>
Available resources and methods
- scenes:library [options] List public scenes
- scenes:list [options] List your scenes
- scenes:create [options] Create a new scene
- scenes:update [options] Update a scene
- scenes:get Get scene data
- scenes:delete Delete a scene
- scenes:clone Clone a scene
- scenes:import [options] Import a file into the scene
- scenes:export Export a scene
- scenes:render [options] Render an image
- scenes:command [options] Run a command
- jobs:list [options] List your jobs
- jobs:get Get job data
- user:get Get User Profile
- user:update [options] Update user profile
- webhooks:list [options] List webhooks
- webhooks:create [options] Create a webhook
- webhooks:update [options] Update a webhook
- set Set a configuration value to $HOME/.clara.json
- get Return the current configuration for
Configuration
There are several ways to set up the configuration data, from highest to lowest priority:
- Pass directly (through function call, or command line).
clara --apiToken <apiToken> --username <username> scenes:get <sceneId>
Or with api:
var clara = require('clara')({apiToken: '...', username: '...'});
- Environment variables.
Any parameter can be passed through an environment variable, prefixed with clara_
:
clara_apiToken=api-token-here clara_username=username clara scenes:get <uuid>
- Configuration file in current working directory
A json file named .clara.json
can hold configuration data:
{
"apiToken": "api-token-here",
"username": "your-username"
}
- Configuration file in $HOME
If the configuration file .clara.json
exists in $HOME, it will be used.
clara set, clara get
You can use the clara command line to quickly set/get your configuration data. It will write
to $HOME/.clara.json
:
$ clara set apiToken your-api-token
$ clara set username your-username
$ clara scenes:get scene-uuid
Development
Run the tests using npm:
$ npm install
$ npm tests