Skip to main content

Ladu20 API

API structure

Ladu20 API is REST based, queries are processed via CURL POST requests.

API base URL: henceforth BASEURL, will be provided by KMA.
API key: henceforth APIKEY, will be provided by KMA
Request data is posted in CURLOPT_POSTFIELDS as JSON.
Response data is JSON formatted and returns request status, request type, result data and rowcount.

HTTP header Content-Type needs to be set to application/json

PHP sample request
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://baseurl/product',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{"id":"21161"}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'x-api-key: APIKEY'
  ),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
Error handling

Query success or failure is defined in the boolean response field "ok". Response data and error descriptions are available in the field "data".

Successful requestresponse with results:
{"timestamp":"2023-10-13T10:00:35.133","ok":true,"query":"customer","row_count":1,"data":[{"customer_code":"1234","main_customer_code":"1234","receiving_customer_code":"1234","last_update":"2023-10-06T10:35:56.177","name":"TEST OÜ","reg_code":"1234568","vat_in_use":1,"vat_no":"EE1234567","is_private_person":0,"is_customer":1,"is_supplier":0,"is_producer":0,"is_transporter":0,"is_owner":0,"phone":"555555555","address1":"Mustamäe tee 46","address2":"Harjumaa","address3":"Tallinn","postcode":"10612","country":"EE","language":"","email":"info@kma.ee","currency":"EUR","ref_no":"0","old":0,"rowno":1}]}

Successful requestresponse with no results:
{"timestamp":"2023-10-13T09:54:22.303","ok":true,"query":"customer","row_count":0}

Unsuccessful request:
{"timestamp":"2023-10-13T09:56:54.410","ok":false,"query":"customer","data":{"message":"Technical error occurred"}}

APIData Requestsoutput requests

API requests serve data from Ladu20 by predefined filterable POST requests. Filter parameters are defined per request and are not mandatory.

Currently the following standard outputs are available:

  • Customer data
  • Product data
  • Stocklevels
  • Order
  • Dispatch
  • Invoice

Customer data

URL: BASEURLapiurl//customer

Returns customer data from Ladu20 database. Ladu20 defines customers as one collection of data with several statuses. The latter means the customer cards for suppliers, customers, producers etc are the same data unit, with several statuses defining the customer state (eg is_supplier=1 means that the customer is also regarded a supplier in Ladu20).

Filter parameters
default default
PARAMETER NAME TYPE DESCRIPTIONDefault value
last_update string returns data which is update later than the timestamp;
format: 2023-10-11T00:00:00
default:
last 240 hours
old bitbool returns results marked as old in Ladu20;
default:
false
id string customer id in Ladu20 
page int Range 1-n,n 1
rowcount int Range 1-300,1000 300
Sample request data

'{"last_update":"2023-10-11T00:00:00","rowcount":2,"page":1}'

Response data
FIELD NAME TYPE DESCRIPTION
customer_code int  
main_customer_code int payer customer code
receiving_customer_code int  
last_update date format: 2023-10-11T00:00:00, created date
name string  
reg_code string  
vat_in_use int  
vat_no string  
is_private_person boolean  
customer boolean customer status
supplier boolean customer status
producer boolean customer status
transporter boolean customer status
owner string  
info string  
phone string  
address1 string street
address2 string city
address3 string county
postcode string  
country string  
language string  
email string  
currency decimal  
bank string bank name
bankaccount string  
ref_no int reference no
glncode int  
lat int latitude
long int longitude
credit_limit decimal  
debt_min_amount decimal  
debt_from int debt from days
owner_customer string  

 

Product data

Stockbalance

Order

Dispatch

Invoice