This is a very small API library for Celery, you can find the documentation here. It's heavily inspired by @reggi's Whiplash client.
npm install try-celery
var Celery = require("try-celery");
var celery = new Celery("YOUR_API_KEY_HERE");
The new Celery()
object can take a couple of different argument sets.
A key in the form of a string
, like so, version
is automatically 1
.
var celery = new Celery("j54kjh83ij2h23");
A key in the form of a `object, like so.
var celery = new Celery({ "key": "j54kjh83ij2h23", "version": "1", });
The last function you'll ever need celery.request()
. This function is very similar to the object above in terms of parameters.
celery.request(options,callbacks);
The function takes two parameters.
If options is a string it will be the same as options.url
see below.
There is only one mandatory value if you use options as an object and that is options.url
. No preceding /
is needed when specifying a path (e.g. orders
, orders/originator
)
You can specify options.method
and query
.
The defaults are as follows:
var options = { "method":"GET", "query":{}, }
The callbacks
param is a object, which needs to contain both success
and error
.
celery.request({ "method":"DELETE", "url":"orders/"+id }, function(err, body){ if(err) console.log(err); console.log(body); });
The following example returns all orders
.
var Celery = require("try-celery"); var celery = new Celery("j54kjh83ij2h23"); celery.request("orders", function(err, body){ if(err) console.log(err); console.log(body); });