Confidential: POSLavu API Documentation
API URL: https://admin.poslavu.com/cp/reqserv ((ATTENTION: The API URL has recently changed. If you are using the old API URL please update it to the new one))
Post Variables: * dataname - required * key - required * token - required * table - required * column * value * value_min * value_max * limit Available Tables: * menu_groups * menu_categories * menu_items * tables * orders * order_contents * order_payments * ingredients * ingredient_usage ------------------------ menu_groups ------------------------------ POST: dataname=(dataname)&key=(key)&token=(token)&table=menu_groups <row> <id>8</id> <menu_id>11</menu_id> <group_name>Dinner</group_name> <orderby></orderby> </row> ---------------------- menu_categories ---------------------------- POST: dataname=(dataname)&key=(key)&token=(token)&table=menu_categories&column=group_id&value=2 <row> <id>113</id> <menu_id>11</menu_id> <group_id>2</group_id> <name>Zambos</name> <image></image> <description></description> <active>1</active> <print>0</print> <last_modified_date>0000-00-00 00:00:00</last_modified_date> <printer>1</printer> <modifier_list_id>0</modifier_list_id> <apply_taxrate>Default</apply_taxrate> <custom_taxrate></custom_taxrate> <forced_modifier_group_id>0</forced_modifier_group_id> <print_order>0</print_order> <super_group_id>1</super_group_id> </row> ------------------------ menu_items ------------------------------- POST: dataname=(dataname)&key=(key)&token=(token)&table=menu_items&column=category_id&value=113 <row> <id>813</id> <category_id>113</category_id> <menu_id>11</menu_id> <name>Grox " jhgjhgjh</name> <price>25</price> <description></description> <image>ann_smith_robot_dino.jpg</image> <image2></image2> <image3></image3> <misc_content></misc_content> <options1></options1> <options2></options2> <options3></options3> <active>1</active> <print>1</print> <quick_item>0</quick_item> <last_modified_date>0000-00-00 00:00:00</last_modified_date> <printer>0</printer> <apply_taxrate>Default</apply_taxrate> <custom_taxrate></custom_taxrate> <modifier_list_id>0</modifier_list_id> <forced_modifier_group_id>C</forced_modifier_group_id> <ingredients></ingredients> <open_item>0</open_item> <hidden_value></hidden_value> <hidden_value2></hidden_value2> <allow_deposit>0</allow_deposit> <UPC></UPC> <hidden_value3></hidden_value3> <inv_count>0</inv_count> <show_in_app>1</show_in_app> <super_group_id></super_group_id> </row> -------------------------- tables --------------------------------- POST: dataname=(dataname)&key=(key)&token=(token)&table=tables <row> <id>3</id> <loc_id>9</loc_id> <coord_x>138|258|372|484|594|709|820|820|820|820|141|205|275|407|473|539|605|671|142|70|274|349|741|539|605|671|107|790|206|405|538|671</coord_x> <coord_y>82|82|82|82|82|82|82|191|298|409|211|286|210|211|286|211|286|211|360|409|511|572|292|361|436|361|550|524|436|511|511|511</coord_y> <shapes>square|square|square|square|square|square|square|square|square|square|circle|circle|circle|circle|circle|circle|circle|circle|circle|circle|circle|circle|circle|circle|circle|circle|slant_left|circle|circle|circle|circle|circle</shapes> <widths>74|70|70|70|70|70|70|70|70|70|70|72|70|70|70|70|70|70|70|70|70|70|70|70|70|70|85|70|70|70|70|70</widths> <heights>69|70|70|70|70|70|70|70|70|70|70|69|70|70|70|70|70|70|70|70|70|70|70|70|70|70|88|70|70|70|70|70</heights> <names>Booth 1|Booth 2|Booth 3|Booth 4|Booth 5|Booth 6|Booth 7|Booth 8|Booth 9|Booth 10|Table 1|Table 2|Table 3|Table 5|Table 6|Table 7|Table 8|Table 9|Table 11|Table 12|Table 13|Table 14|Table 15|Table 16|Table 17|Table 18|Cashier|Table 18|Table 19|Table 20|Table 21|Table 22</names> </row> -------------------------- orders --------------------------------- POST: dataname=(dataname)&key=(key)&token=(token)&table=orders&column=closed&value_min=2011-01-01%2000:00:00&value_max=2011-02-01%2000:00:00&limit=0,20 <row> <id>1</id> <order_id>1</order_id> <location>Dev West Side</location> <location_id>9</location_id> <opened>2010-10-06 12:01:20</opened> <closed>2011-01-26 17:16:31</closed> <subtotal>40.50</subtotal> <taxrate>0.06875</taxrate> <tax>2.78</tax> <total>43.28</total> <server>Ancori Lifigi</server> <server_id>5</server_id> <tablename>Booth 7</tablename> <send_status>1</send_status> <discount>0.00</discount> <discount_sh></discount_sh> <gratuity>0.00</gratuity> <gratuity_percent>0.2250</gratuity_percent> <card_gratuity>0.00</card_gratuity> <cash_paid>46.64</cash_paid> <card_paid>0.00</card_paid> <gift_certificate>0.00</gift_certificate> <change_amount>3.36</change_amount> <reopen_refund>0.00</reopen_refund> <void>1</void> <cashier>Ancori Lifigi</cashier> <cashier_id>5</cashier_id> <auth_by></auth_by> <auth_by_id>0</auth_by_id> <guests>1</guests> <email></email> <permission>0</permission> <check_has_printed>1</check_has_printed> <no_of_checks>2</no_of_checks> <card_desc></card_desc> <transaction_id></transaction_id> <multiple_tax_rates>0</multiple_tax_rates> <tab>0</tab> <original_id>0</original_id> <deposit_status>0</deposit_status> <register></register> <refunded>0</refunded> <refund_notes></refund_notes> <refunded_cc></refunded_cc> <refund_notes_cc></refund_notes_cc> <refunded_by>0</refunded_by> <refunded_by_cc>0</refunded_by_cc> <cash_tip></cash_tip> <discount_value></discount_value> <reopened_datetime></reopened_datetime> <discount_type></discount_type> <deposit_amount></deposit_amount> <subtotal_without_deposit></subtotal_without_deposit> <togo_status></togo_status> <togo_phone></togo_phone> <togo_time></togo_time> <cash_applied>43.28</cash_applied> <rounding_amount></rounding_amount> </row> ---------------------- order_contents ----------------------------- POST: dataname=(dataname)&key=(key)&token=(token)&table=order_contents&column=order_id&value=1 <row> <id>1</id> <loc_id>9</loc_id> <order_id>1</order_id> <item>Dynamite</item> <price>15</price> <quantity>1</quantity> <options>Shark - Bacon - Cheese</options> <special></special> <modify_price></modify_price> <print>1</print> <check>1</check> <seat>1</seat> <item_id>120</item_id> <printer>1</printer> <apply_taxrate>0.06875</apply_taxrate> <custom_taxrate>0.06875</custom_taxrate> <modifier_list_id>0</modifier_list_id> <forced_modifier_group_id>0</forced_modifier_group_id> <forced_modifiers_price>5.25</forced_modifiers_price> <course>1</course> <print_order>0</print_order> <open_item>0</open_item> <subtotal></subtotal> <allow_deposit>0</allow_deposit> <deposit_info></deposit_info> <discount_amount></discount_amount> <discount_value></discount_value> <discount_type></discount_type> <after_discount></after_discount> <subtotal_with_mods></subtotal_with_mods> <tax_amount></tax_amount> <notes></notes> <total_with_tax></total_with_tax> <itax_rate></itax_rate> <itax></itax> <tax_rate1></tax_rate1> <tax1></tax1> <tax_rate2></tax_rate2> <tax2></tax2> <tax_rate3></tax_rate3> <tax3></tax3> </row> -------------------------------- order_payments ---------------------------------------- POST: dataname=(dataname)&key=(key)&token=(token)&table=order_payments&column=order_id&value=1-2 <row>
<id>1239</id>
<order_id>1-2</order_id>
<check>1</check>
<amount>5.50</amount>
<card_desc></card_desc>
<transaction_id></transaction_id>
<refunded>0</refunded>
<refund_notes></refund_notes>
<refunded_by>0</refunded_by>
<refund_pnref></refund_pnref>
<tip_amount></tip_amount>
<auth>0</auth>
<loc_id>9</loc_id>
<processed>0</processed>
<auth_code></auth_code>
<card_type></card_type>
<datetime>2011-10-10 11:50:38</datetime>
<pay_type>Cash</pay_type>
<voided>0</voided>
<void_notes></void_notes>
<voided_by>0</voided_by>
<void_pnref></void_pnref>
<register>receipt</register>
<got_response>0</got_response>
<transtype></transtype>
<split_tender_id></split_tender_id>
<temp_data></temp_data>
<change></change>
<total_collected>5.50</total_collected>
<record_no></record_no>
<server_name>Ancori</server_name>
<action>Sale</action>
<ref_data></ref_data>
<process_data></process_data>
<voice_auth>0</voice_auth>
<server_id>15</server_id>
<preauth_id></preauth_id>
<tip_for_id>0</tip_for_id>
<swipe_grade></swipe_grade>
<batch_no></batch_no>
<register_name>receipt</register_name>
<pay_type_id>1</pay_type_id>
<first_four></first_four>
<mpshc_pid></mpshc_pid>
<server_time>2011-10-10 12:49:26</server_time>
<info></info>
<signature>0</signature>
</row> ------------------------------------ PHP Example --------------------------------------- <?php $api_url = "https://admin.poslavu.com/cp/reqserv/"; $api_dataname = "(dataname here)"; $api_key = "(key here)"; $api_token = "(token here)"; $postvars = "dataname=$api_dataname&key=$api_key&token=$api_token"; $postvars .= "&table=tables"; function display_api_response($str) { $str = str_replace("<","<",$str); $str = str_replace(">",">",$str); $str = str_replace("\n","<br>",$str); $str = str_replace("\t"," ",$str); return $str; } $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $api_url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $postvars); $contents = curl_exec($ch); curl_close ($ch); echo "<br>api response: " . display_api_response($contents); ?> ------------------------------------ C# Example ---------------------------------------- using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Web; using System.IO; using System.Net; namespace api_example { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { string api_url = "https://admin.poslavu.com/cp/reqserv/"; string api_dataname = "(dataname here)"; string api_key = "(key here)"; string api_token = "(token here)"; string postvars = "dataname=" + api_dataname + "&key=" + api_key + "&token=" + api_token; postvars += "&table=tables"; string return_val = PostData(api_url, postvars); MessageBox.Show("api response: \n" + return_val); } private string PostData(string url, string postData) { HttpWebRequest request = null; Uri uri = new Uri(url); request = (HttpWebRequest)WebRequest.Create(uri); request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; request.ContentLength = postData.Length; using (Stream writeStream = request.GetRequestStream()) { UTF8Encoding encoding = new UTF8Encoding(); byte[] bytes = encoding.GetBytes(postData); writeStream.Write(bytes, 0, bytes.Length); } try { string result = string.Empty; using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) { using (Stream responseStream = response.GetResponseStream()) { using (StreamReader readStream = new StreamReader(responseStream, Encoding.UTF8)) { result = readStream.ReadToEnd(); } } } return result; } catch { return ""; } } } } ------------------------------- Inserting into the database using PHP -------------------------------- <?php // Confidential: POSLavu API Documentation // EXAMPLE FOR INSERTING AN ORDER USING THE POSLAVU API. function post_to_api($postvars) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://admin.poslavu.com/v2/reqserv/"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $postvars); $response = curl_exec($ch); curl_close ($ch); return $response; } function get_tag_contents($tag,$str) { $contents = array(); $str_parts = explode("<".$tag.">",$str); // look for start tag for($i=0; $i<count($str_parts); $i++) { $current_parts = explode("</".$tag.">",$str_parts[$i]); // look for end tag if(count($current_parts) > 1) // full tag found, get contents { $contents[] = $current_parts[0]; } } return $contents; } $api_url = "https://admin.poslavu.com/cp/reqserv/"; $api_dataname = "(dataname here)"; $api_key = "(key here)"; $api_token = "(token here)"; //----------------------------------------- Add the order $set_contents = " <row> <opened>2011-09-06 16:10:00</opened> <closed>0000-00-00 00:00:00</closed> <subtotal>14.25</subtotal> <taxrate>0.000</taxrate> <tax>0.98</tax> <total>15.23</total> <server>Ancori</server> <server_id>15</server_id> <tablename>Table 5</tablename> <cash_paid>5.50</cash_paid> <change_amount>0</change_amount> <cash_applied>5.50</cash_applied> <card_paid></card_paid> <gift_certificate></gift_certificate> <guests>2</guests> </row> "; $postvars = "dataname=$api_dataname&key=$api_key&token=$api_token"; $postvars .= "&cmd=insert&table=orders&contents=".$set_contents; $response = post_to_api($postvars); // When creating an order the api will return the following info: // <result><id>id of the new entry</id><order_id>the order id for the new order</order_id></result> $order_id_list = get_tag_contents("order_id",$response); // the api will assign the order_id for the new if(count($order_id_list) > 0) { $order_id = $order_id_list[0]; //----------------------------------------- Add the order contents $set_contents = " <row> <sent>0</sent> <order_id>" . $order_id . "</order_id> <item>Nanbot</item> <price>5.5</price> <quantity>1</quantity> <options></options> <special></special> <modify_price></modify_price> <check>1</check> <seat>1</seat> <item_id>814</item_id> <printer>1</printer> <apply_taxrate>0</apply_taxrate> <custom_taxrate>0</custom_taxrate> <course>1</course> <subtotal>5.5</subtotal> <discount_amount></discount_amount> <discount_value></discount_value> <discount_type></discount_type> <after_discount></after_discount> <subtotal_with_mods>5.5</subtotal_with_mods> <tax_amount></tax_amount> <notes></notes> <total_with_tax></total_with_tax> <after_gratuity></after_gratuity> <void>0</void> <discount_id></discount_id> <server_time>2011-10-10 12:49:16</server_time> <device_time>2011-10-10 11:50:12</device_time> </row> <row> <sent>0</sent> <order_id>1-2</order_id> <item>Columbian</item> <price>3.5</price> <quantity>2.5</quantity> <options></options> <special></special> <modify_price></modify_price> <check>1</check> <seat>1</seat> <item_id>824</item_id> <apply_taxrate>0</apply_taxrate> <custom_taxrate>0</custom_taxrate> <course>1</course> <subtotal>8.75</subtotal> <discount_amount></discount_amount> <discount_value></discount_value> <discount_type></discount_type> <after_discount></after_discount> <subtotal_with_mods>8.75</subtotal_with_mods> <tax_amount></tax_amount> <notes></notes> <total_with_tax></total_with_tax> <after_gratuity></after_gratuity> <void>0</void> <discount_id></discount_id> <server_time>2011-10-10 12:49:17</server_time> <device_time>2011-10-10 11:50:23</device_time> </row> "; $postvars = "dataname=$api_dataname&key=$api_key&token=$api_token"; $postvars .= "&cmd=insert&table=order_contents&contents=".$set_contents; $response = post_to_api($postvars); //-------------------------------------------- Add order payments $set_contents = " <row> <order_id>" . $order_id . "</order_id> <check>1</check> <amount>5.50</amount> <transaction_id></transaction_id> <datetime>2011-10-10 11:50:38</datetime> <pay_type>Cash</pay_type> <total_collected>5.50</total_collected> <server_name>Ancori</server_name> <action>Sale</action> <server_id>15</server_id> <server_time>2011-10-10 12:49:26</server_time> </row> "; $postvars = "dataname=$api_dataname&key=$api_key&token=$api_token"; $postvars .= "&cmd=insert&table=order_payments&contents=".$set_contents; $response = post_to_api($postvars); } ?>