JavaScript client library for Rokka.
$ npm install rokka --save
var rokka = require('rokka')({
apiKey: 'apikey'
});
rokka.sourceimages.list('myorg')
.then(function(result) {
console.log(result);
})
.catch(function(err) {
console.error(err);
});
Initializing the Rokka client.
var rokka = require('rokka')({
apiKey: 'apikey', // required for certain operations
apiHost: '<url>', // default: https://api.rokka.io
apiVersion: <number>, // default: 1
renderHost: '<url>', // default: https://{organization}.rokka.io
debug: true, // default: false
transport: {
retries: <number>, // number of retries when API response is 429 (default: 10)
minTimeout: <number>, // minimum milliseconds between retries (default: 1000)
maxTimeout: <number>, // maximum milliseconds between retries (default: 10000)
randomize: <boolean> // randomize time between retries (default: true)
}
});
All properties are optional since certain calls don't require credentials.
Register a new user for the Rokka service.
rokka.users.create('[email protected]')
.then(function(result) {})
.catch(function(err) {});
Get a list of organizations.
rokka.organizations.get('myorg')
.then(function(result) {})
.catch(function(err) {});
Create an organization.
rokka.organizations.create('myorg', '[email protected]', 'Organization Inc.')
.then(function(result) {})
.catch(function(err) {});
rokka.memberships.ROLES.READ
- read-only accessrokka.memberships.ROLES.WRITE
- read-write accessrokka.memberships.ROLES.ADMIN
- administrative access
Add a member to an organization.
rokka.memberships.create('myorg', '[email protected]', rokka.memberships.ROLES.WRITE)
.then(function(result) {})
.catch(function(err) {});
Get a list of source images.
rokka.sourceimages.list('myorg')
.then(function(result) {})
.catch(function(err) {});
Get information of a source image by hash.
rokka.sourceimages.get('myorg', 'c421f4e8cefe0fd3aab22832f51e85bacda0a47a')
.then(function(result) {})
.catch(function(err) {});
Get information of a source image by its binary hash.
rokka.sourceimages.getWithBinaryHash('myorg', 'b23e17047329b417d3902dc1a5a7e158a3ee822a')
.then(function(result) {})
.catch(function(err) {});
Download image by hash.
rokka.sourceimages.download('myorg', 'c421f4e8cefe0fd3aab22832f51e85bacda0a47a')
.then(function(result) {})
.catch(function(err) {});
Upload an image.
rokka.sourceimages.create('myorg', require('fs').createReadStream('picture.png'))
.then(function(result) {})
.catch(function(err) {});
Delete image by hash.
rokka.sourceimages.delete('myorg', 'c421f4e8cefe0fd3aab22832f51e85bacda0a47a')
.then(function(result) {})
.catch(function(err) {});
rokka.operations.resize(width, height, options={})
rokka.operations.rotate(angle, options={})
rokka.operations.dropshadow(options={})
rokka.operations.trim(options={})
rokka.operations.crop(options={})
rokka.operations.noop()
Please refer to the Rokka API documentation
Get a list of available stack operations.
rokka.operations.list()
.then(function(result) {})
.catch(function(err) {});
Get a list of available stacks.
rokka.stacks.list('myorg')
.then(function(result) {})
.catch(function(err) {});
Get details about a stack.
Create a new stack.
var operations = [
rokka.operations.rotate(45),
rokka.operations.resize(100, 100)
];
rokka.stacks.create('myorg', 'mystack', operations)
.then(function(result) {})
.catch(function(err) {});
Delete a stack.
rokka.stacks.delete('myorg', 'mystack')
.then(function(result) {})
.catch(function(err) {});
Get URL for rendering an image.
rokka.render.getUrl('myorg', 'c421f4e8cefe0fd3aab22832f51e85bacda0a47a', 'png', 'mystack')