Using API

Template

Different ways of using API

Using eKansio API

eKansio API offers full resources list of getting/setting application schema and data, because the API is used also internally. See available resources

Making API call in javascript

cms -object offers resource to make ajax calls to eKansio API.

Set response to a variable (synchronous call!)

var response = cms.api.get('record', {table:'customer', id:customer_id});

Handle data with callback function:

cms.api.get('record', {
  table:'customer',
  id:customer_id
}, function(response){
  // Do stuff with response.data
});

More examples of fetching data.

Making calls from remote site

eKansio allows cross-domain ajax calls to enable making ajax -calls from remote site.

eKansio provides Javascript object for making calls to api:

var Api = eApi.create({
  host: 'http://www.ekansio.fi',
  username: 'demouser',
  password: '1234',
});

Api.get('record',{
  table:'customer',
  id:customer_id
},function(){
  // Do stuff with eKansio data
});

This way you expose you password in public code!!

This way you expose you password in public code!!

More examples

Creating API resource

Actions can be called using api/action/:id/print -resource. You can run the action and get the content of any ActionType, but to make API resources it is adviced to use text type

Add customer info inside DOM element:

cms.api.get('action/customer_orders_table/print',{
  id: customer_id
}, data => {
  $('.js-orders').append(data);
})