SQL-Ledger allows you to call any of its functions from command line. An example will better illustrate this.
The following code run from your Linux/Unix shell will add a new customer to the customers table:
./ct.pl " login=armaghan &password=armaghan &path=bin/mozilla &db=customer &action=save &typeofcontact=company &name=Ledger123 &firstname=Armaghan &lastname=Saqib &city=London "
You could also insert this information using plain old SQL INSERT statement but here is the problem. Customer information is stored in at least three tables (customer, contact, address). You have to make sure you INSERT rows with correct id numbers in all three tables.
On the other hand API takes care of adding proper data rows in each tables with a single call like above. API also validates your data and runs any logic which is run when you are adding a customer through web interface. For example if you have defined a sequence for customer numbers, the next number is assigned automatically from that sequence.
API can be used to “simulate” any sql-ledger function from command line. You can add customers, vendors, parts as well as any type of transaction (invoices, cash receipts and payments etc.)
This makes it very easy to integrate sql-ledger with any other application. For example you can integrate it with your CRM solution, POS system, or e-commerce solutions like AgoraCart or Interchange.
API also allows you to add new data entry interfaces with ease. All you need to develop is the code which will interact with users and leave the rest to the API.
Import invoices and payment functions built in new versions of sql-ledger are in fact “newer interfaces” built using the API.
You can make API calls from any language using its shell execution mechnisim. For example you can use the following php code to make SL api call.
<?php
$module = './ct.pl';
$params = 'login=armaghan';
$params .= '&password=armaghan';
$params .= '&path=bin/mozilla';
$params .= '&db=customer';
$params .= '&action=save';
$params .= '&typeofcontact=company';
$params .= '&name=Ledger123';
$params .= '&firstname=Armaghan';
$params .= '&lastname=Saqib';
$params .= '&city=London';
$output = shell_exec("$module \"$params\"");
echo "<pre>$output</pre>";
?>