Extension APIs

This article introduces how to use the JavaScript APIs provided by SHOPLINE POS to implement Web extensions on the POS app page, allowing you to interact with the native features of SHOPLINE POS.


API usage guide

Requirements

Before you begin, make sure you meet the following requirements:


Integration procedure

Step1: Import the SDK

Include the JavaScript SDK in your project by specifying the version number in the script tag as shown below:

<!-- Specify the version -->
<script src="https://cdn.myshopline.com/sl/sdk/sl-jssdk-1.0.35.mini.js"></script>

Step 2: Call APIs

API call example

Use the posapp module in the SDK to integrate APIs. You can access the APIs under the posapp module through the global variable shoplineAppBridge.

The following code and accompanying screenshot show how to use the [openWebWindow](https://shopline.yuque.com/xple8g/mcb268/usk76th9ywoztk7w#Extpl) API to open your app in half screen.

<!-- window.shoplineAppBridge: global variable -->
<!-- posapp: module name -->
<!-- 'openWebWindow': feature -->
<!-- { url : localurl, }: input parameter -->
<!-- then((res): a synchronous callback; res response parameters -->
<!-- {'code': Int, 'msg': string, 'timestamp': Number, 'data': Obj\} -->
shoplineAppBridge.posapp('openWebWindow', { url : localurl, }).then((res) => {

}

API response example

A response example of an API call is as follows:

{
code: 0,
msg: "",
timeStamp: 1729822782000,
data: {}
}
Parameter nameTypeDescription
codenumberThe error code returned by the API call. Refer to Error code for details.
msgstringThe error message returned by the API call when code is not 0.
timeStampnumberThe response time of the API call, formatted as a 13-digit millisecond timestamp.
dataobjectThe result returned by certain API calls. Refer to API references for details.

Examples

API call example

<script type="text/javascript">
function openWebWindow() {
var url = "https://xxxxxxxx";
window.shoplineAppBridge.posapp('openWebWindow', {"url":url,"style":1,"position":{"x":0.1,"y":0.05,"width":0.8,"height":0.9}}).then((res) => {

// Example res = { "code":0, "timeStamp":1730276377000}
var jsonRes = JSON.stringify(res);
if (jsonRes['code'] == 0) {
// Your processing logic
}
});
}
</script>

Event callback example

<script type="text/javascript">
function POSEvent_deviceNetworkStatus(res) {

// Example res = { "code":0,"data":{"connectionStatus":"wifi"} }
var jsonRes = JSON.stringify(res);
if (jsonRes['code'] == 0) {

if (jsonRes['data']['connectionStatus'] == "wifi") {
// Your processing logic
}
}
}
</script>

API references

UI operations

The following are APIs related to UI operations.

openWebWindow

Use this API to pop up a web window, with customizable window position and size. You need to pass in the URL of the web page that you wish to open.

  • Request parameters
Parameter nameTypeRequired or notDescription
urlstringYesThe link to the web page that you wish to open.
stylenumberNoThe window opening mode. Valid values are:
+ 0: open in full screen.
+ 1: open in half screen. You can customize the size and position of the window through position.
positionobjectNoThe position of the window on the screen.
Specify this parameter when the value of style is 1.
position.xnumberNoHorizontal coordinate that scales proportionally with the screen width. The default value is 0.
Value range: 0-1
position.ynumberNoVertical coordinate that scales proportionally with the screen height. The default value is 0.
Value range: 0-1
position.widthnumberNoThe window width that scales proportionally with the screen width. The default value is 1, which means the window width matches the screen width.
Value range: 0-1
position.heightnumberNoThe window height that scales proportionally with the screen height. The default value is 1, which means the window height matches the screen height.
Value range: 0-1
  • Response parameters
Parameter nameTypeRequired or notDescription
codenumberYesThe error code.
msgstringNoThe error message. This parameter is returned when the value of code is not 0.
timeStampnumberYesThe response time of the API call, formatted as a 13-digit millisecond timestamp.

closeWebWindow

Use this API to close the Web window.

  • Request parameters: none
  • Response parameters
Parameter nameTypeRequired or notDescription
codenumberYesThe error code.
msgstringNoThe error message. This parameter is returned when the value of code is not 0.
timeStampnumberYesThe response time of the API call, formatted as a 13-digit millisecond timestamp.

showToast

Use this API to display essential text information as a fixed toast notification at the center of the Web window.

  • Request parameters
Parameter nameTypeRequired or notDescription
textstringYesThe text to be displayed in the toast.
  • Response parameters
Parameter nameTypeRequired or notDescription
codenumberYesThe error code.
msgstringNoThe error message. This parameter is returned when the value of code is not 0.
timeStampnumberYesThe response time of the API call, formatted as a 13-digit millisecond timestamp.

enablePullRefresh

Use this API to enable or disable the pull-to-refresh functionality for the window. The functionality is disabled by default.

  • Request parameters
Parameter nameTypeRequired or notDescription
enablebooleanYesIndicates whether the pull-to-refresh functionality is enabled. Valid values are:
+ true: enable the functionality
+ false: disable the functionality
  • Response parameters
Parameter nameTypeRequired or notDescription
codenumberYesThe error code.
msgstringNoThe error message. This parameter is returned when the value of code is not 0.
timeStampnumberYesThe response time of the API call, formatted as a 13-digit millisecond timestamp.

setBackMode

If the Web window includes a navigation bar with a back button, use this API to define the behavior of the back button. There are two supported actions upon clicking the back button:

  • It closes the Web window directly.
  • It navigates to the previous page of the Web window.

If not set, the default behavior is to close the Web window directly.

  • Request parameters
Parameter nameTypeRequired or notDescription
modenumberYesThe action triggered when clicking the back button. Valid values are:
+ 0: close the Web window directly.
+ 1: return to the previous page of the Web window.
  • Response parameters
Parameter nameTypeRequired or notDescription
codenumberYesThe error code.
msgstringNoThe error message. This parameter is returned when the value of code is not 0.
timeStampnumberYesThe response time of the API call, formatted as a 13-digit millisecond timestamp.

Device information

getDeviceNetworkStatus

Use this API to get the network status of the mobile device.

  • Request parameters: none
  • Response parameters
Parameter nameTypeRequired or notDescription
codenumberYesThe error code.
msgstringNoThe error message. This parameter is returned when the value of code is not 0.
timeStampnumberYesThe response time of the API call, formatted as a 13-digit millisecond timestamp.
dataobjectNoThis parameter is returned when the value of code is 0.
data.connectionStatusstringNoDevice network status. Valid values are:
+ wifi: connected to wireless network
+ wwan: connected to cellular network
+ unavailable: no network connection

POSEvent_deviceNetworkStatus

Use this API to listen for the network status of the mobile device. When the network status changes, this API will notify the Web window page.

  • Request parameters: none
  • Response parameters
Parameter nameTypeRequired or notDescription
codenumberYesThe error code.
msgstringNoThe error message. This parameter is returned when the value of code is not 0.
timeStampnumberYesThe response time of the API call, formatted as a 13-digit millisecond timestamp.
dataobjectYesThis parameter is returned when the value of code is 0.
data.connectionStatusstringYesDevice network status. Valid values are:
+ wifi: connected to wireless network
+ wwan: connected to cellular network
+ unavailable: no network connection

getDeviceInfo

Use this API to get the basic information about the mobile device.

  • Request parameters: none
  • Response parameters
Parameter nameTypeRequired or notDescription
codenumberYesThe error code.
msgstringNoThe error message. This parameter is returned when the value of code is not 0.
timeStampnumberYesThe response time of the API call, formatted as a 13-digit millisecond timestamp.
dataobjectNoThis parameter is returned when the value of code is 0.
data.deviceNamestringNoThe name of the device. For example, iPhone 14 Pro and Sunmi T2.
data.deviceIdstringNoThe ID of the device.
For example, 00:0C:29:01:98:27.
data.osVersionstringNoThe version of the device's operating system. For example, 17.2.1.
data.osstringNoThe device's operating system type. Valid values are:
+ Android
+ iOS
data.appVersionstringNoThe version number of the SHOPLINE POS app installed on the device. For example, 2.15.0.

getDeviceLanguage

Use this API to get the language setting from SHOPLINE POS. If you detect any changes in the language settings, you can update the language settings in the POS app accordingly.

  • Request parameters: none
  • Response parameters
Parameter nameTypeRequired or notDescription
codenumberYesThe error code.
msgstringNoThe error message. This parameter is returned when the value of code is not 0.
timeStampnumberYesThe response time of the API call, formatted as a 13-digit millisecond timestamp.
dataobjectNoThis parameter is returned when the value of code is 0.
data.appLanguagestringNoThe language that is used in the SHOPLINE POS. Valid values are:
+ en: English
+ zh-Hans: Simplified Chinese
+ zh-Hant: Traditional Chinese
+ ja: Japanese

POSEvent_deviceLanguage

Use this API to listen for language setting changes in SHOPLINE POS. Upon detecting a change, this API will notify the Web window page. You can monitor this notification to retrieve language information, ensuring your app stays in synchronization with the language settings of the SHOPLINE POS.

  • Request parameters: none
  • Response parameters
Parameter nameTypeRequired or notDescription
codenumberYesThe error code.
msgstringNoThe error message. This parameter is returned when the value of code is not 0.
timeStampnumberYesThe response time of the API call, formatted as a 13-digit millisecond timestamp.
dataobjectYesThis parameter is returned when the value of code is 0.
data.appLanguagestringYesThe language that is used in the SHOPLINE POS. Valid values are:
+ en: English
+ zh-Hans: Simplified Chinese
+ zh-Hant: Traditional Chinese
+ ja: Japanese

POS information

getPOSInfo

Use this API to get the basic information about the merchant's POS system, such as the information about the account, store, branch store, and staff.

  • Request parameters: none
  • Response parameters
Parameter nameTypeRequired or notDescription
codenumberYesThe error code.
msgstringNoThe error message. This parameter is returned when the value of code is not 0.
timeStampnumberYesThe response time of the API call, formatted as a 13-digit millisecond timestamp.
dataobjectNoThis parameter is returned when the value of code is 0.
data.storeIdstringNoThe ID of the store.
data.offlineStoreIdstringNoThe ID of the branch store.
data.posStaffIdstringNoThe ID of the employee in the POS system.
data.currencyCodestringNoA three-letter store currency code that follows the ISO 4217 standard.
data.currentStaffUidstringNoThe user ID of the employee.
data.loginStaffUidstringNoThe ID of the logged-in POS account.

POSEvent_POSInfo

Use this API to listen for the basic information changes about the merchant's POS system, such as the information about the account, store, branch store, and staff. When there is a switch in stores or staff within the POS, this API will notify the Web window page.

  • Request parameters: none
  • Response parameters
Parameter nameTypeRequired or notDescription
codenumberYesThe error code.
msgstringNoThe error message. This parameter is returned when the value of code is not 0.
timeStampnumberYesThe response time of the API call, formatted as a 13-digit millisecond timestamp.
dataobjectNoThis parameter is returned when the value of code is 0.
data.storeIdstringNoThe ID of the store.
data.offlineStoreIdstringNoThe ID of the branch store.
data.posStaffIdstringNoThe ID of the employee in the POS system.
data.uidstringNoThe ID of the logged-in POS account.

getUDBInfo

Use this API to get the basic information of the currently logged-in POS account.

  • Request parameters: none
  • Response parameters
Parameter nameTypeRequired or notDescription
codenumberYesThe error code.
msgstringNoThe error message. This parameter is returned when the value of code is not 0.
timeStampnumberYesThe response time of the API call, formatted as a 13-digit millisecond timestamp.
dataobjectNoThis parameter is returned when the value of code is 0.
data.isLoginbooleanNoIndicates whether the POS is logged in. Valid values are:
+ true: logged in
+ false: not logged in
Default value: false
data.uidstringNoThe ID of the currently logged-in POS account.
data.otpstringNoThe credential for the POS server request, used for subsequent access to the POS server API.
The credential expires one day after you receive it and can only be used once.

getCustomHeader

Use this API to obtain the header information of the POS server request. If you make subsequent requests to POS server APIs, include the following header information in HTTP requests.

  • Request parameters: none
  • Response parameters
Parameter nameTypeRequired or notDescription
codenumberYesThe error code.
msgstringNoThe error message. This parameter is returned when the value of code is not 0.
timeStampnumberYesThe response time of the API call, formatted as a 13-digit millisecond timestamp.
dataobjectNoThis parameter is returned when the value of code is 0.
data.deviceInfostringNoA JSON-formatted string that contains device-related information.
For example, "{\"model\":\"iPad (9th generation)\",\"brand\":\"Apple\",\"os\":\"ios\",\"deviceId\":\"****\",\"appVersion\":\"2.21.0\",\"newDeviceId\":\"****\",\"osVersion\":\"15.4.1\"}".
data.uidstringNoThe ID of the currently logged-in POS account.
data.otpstringNoThe credential for the POS server request, used for subsequent access to the POS server API.
data.langstringNoThe language that is used in the SHOPLINE POS. Valid values are:
+ en: English
+ zh-Hans: Simplified Chinese
+ zh-Hant: Traditional Chinese
+ ja: Japanese
data.ticketstringNoA JSON-formatted string that contains store-related information.
For example, "{\"posId\":\"***\",\"offlineStoreId\":\"****\",\"merchantId\":\"****\",\"posStaffId\":\"***\",\"innerToken\":\"***\",\"storeId\":\"***\"}".

Products

getProducts

Use this API to get the list of product IDs of the currently logged-in branch store.

  • Request parameters
Parameter nameTypeRequired or notDescription
offlineStoreIDstringYesThe ID of the branch store.
queryStringstringNoThe keyword for searching the related products. Based on the search keyword, the system will search within the following scopes:
+ Product name
+ SKU
+ Barcode
+ SPU
+ Manufacturer
+ Summary
For example, shoes.
sortTypestringNoThe sorting methods for result lists. Valid values are:
+ RECENTLY_ADDED: Sorted by creation time from most recent to oldest. This is the default value.
+ RECENTLY_ADDED_ASCENDING: Sorted by creation time from oldest to most recent.
+ ALPHABETICAL_A_TO_Z: Sorted by product name from A to Z.
+ ALPHABETICAL_Z_TO_A: Sorted by product name from Z to A.
pageSizenumberYesThe number of products returned per page.
Value range: 1-500
pageNumnumberYesThe requested page number. Page numbering starts from 1.
Value range: 1-unlimited
  • Response parameters
Parameter nameTypeRequired or notDescription
codenumberYesThe error code.
msgstringNoThe error message. This parameter is returned when the value of code is not 0.
timeStampnumberYesThe response time of the API call, formatted as a 13-digit millisecond timestamp.
dataobjectNoThis parameter is returned when the value of code is 0.
data.productIdsstring[]NoA list of product IDs.

getProductsInfo

Use this API to get product details in bulk for the currently logged-in branch store.

  • Request parameters
Parameter nameTypeRequired or notDescription
productIdsstring[]YesA list of product IDs. It is recommended to limit each query to a maximum of 50 products.
Maximum size: 500
offlineStoreIDstringYesThe ID of the branch store for which product details are being queried.
  • Response parameters
Parameter nameTypeRequired or notDescription
codenumberYesThe error code.
msgstringNoThe error message. This parameter is returned when the value of code is not 0.
timeStampnumberYesThe response time of the API call, formatted as a 13-digit millisecond timestamp.
dataobject[]NoThis parameter is returned when the value of code is 0.
data.productIdstringNoThe ID of the product.
data.skusobject[]YesA list of product SKU information.
data.skus.skuIdstringYesThe SKU ID.
data.skus.locationPriceIntYesThe price of the product sold in the branch store.
data.skus.serialNumberstring[]NoA list of product serial numbers.

Shopping cart

getCartInfo

Use this API to get the shopping cart information in the SHOPLINE POS.

Note: In this API, amount-related data is formatted as a currency-free price string. For example, "100.00" represents 100 Chinese Yuan (CNY) if the store currency is CNY.

  • Request parameters: none
  • Response parameters
Parameter nameTypeRequired or notDescription
codenumberYesThe error code.
msgstringNoThe error message. This parameter is returned when the value of code is not 0.
timeStampnumberYesThe response time of the API call, formatted as a 13-digit millisecond timestamp.
dataobjectNoThis parameter is returned when the value of code is 0.
data.lineItemsobject[]NoA list of shopping cart item line information.
data.lineItems.productIdstringYesThe ID of the product.
data.lineItems.skuIdstringYesThe ID of the SKU.
data.lineItems.finalPricestringYesA transaction unit price, a price string without a currency symbol. For example, "100.00" represents 100 Chinese Yuan (CNY) if the store currency is CNY.
data.lineItems.quantitynumberYesThe add-to-cart quantity.
data.lineItems.finalLinePricestringYesThe total price of the products in the item line.
data.customerobjectNoThe customer information.
data.customer.uidstringNoThe customer's ID.
data.customer.emailstringNoThe customer's email.
data.customer.phonestringNoThe customer's phone number.
data.valuationobjectNoThe pricing information.
data.valuation.subtotalstringYesThe subtotal amount.
data.valuation.totalDiscountsstringNoThe discount amount.
data.valuation.deductMemberPointAmountstringNoThe points deduction amount.
data.valuation.totalTaxstringNoThe total consumption tax amount.
data.valuation.totalDutystringNoThe customer duty amount.
data.valuation.taxesIncludedbooleanNoIndicates whether the product price finalLinePrice includes taxes (including both the customer duty and the consumption tax). Valid values are:
+ true: finalLinePrice includes taxes.
+ false: finalLinePrice does not include taxes.
data.valuation.totalTipstringNoThe tip amount.
data.valuation.adjustPricestringNoThe amount rounded off.
data.valuation.grandTotalstringYesThe total amount.
data.notestringNoThe shopping cart note.
data.localDiscountobjectNoThe local discount information.
data.localDiscount.titlestringNoThe discount title.
data.localDiscount.amountstringNoThe discount amount.
data.localDiscount.percentagestringNoThe discount percentage.
Value range: 0-1
Example: 0.25
data.codeDiscountsstring[]NoA list of discount codes added to the shopping cart.
data.propertiesobjectNoA reserved field for future expansion. Currently undefined for specific use.

POSEvent_CartInfo

Use this API to listen for the data changes in the current shopping cart. When the pricing information in the cart changes, this API will notify the Web window page.

  • Request parameters: none
  • Response parameters
Parameter nameTypeRequired or notDescription
codenumberYesThe error code.
msgstringNoThe error message. This parameter is returned when the value of code is not 0.
timeStampnumberYesThe response time of the API call, formatted as a 13-digit millisecond timestamp.
dataobjectNoThis parameter is returned when the value of code is 0.
data.lineItemsobject[]NoA list of shopping cart item line information.
data.lineItems.productIdstringYesThe ID of the product.
data.lineItems.skuIdstringYesThe ID of the SKU.
data.lineItems.finalPricestringYesA transaction unit price, a price string without a currency symbol. For example, "100.00" represents 100 Chinese Yuan (CNY) in stores using this currency.
data.lineItems.quantitynumberYesThe add-to-cart quantity.
data.lineItems.finalLinePricestringYesThe total price of the products in the item line.
data.customerobjectNoThe customer information.
data.customer.uidstringNoThe customer's ID.
data.customer.emailstringNoThe customer's email.
data.customer.phonestringNoThe customer's phone number.
data.valuationobjectNoThe pricing information.
data.valuation.subtotalstringYesThe subtotal amount.
data.valuation.totalDiscountsstringNoThe discount amount.
data.valuation.deductMemberPointAmountstringNoThe points deduction amount.
data.valuation.totalTaxstringNoThe total consumption tax amount.
data.valuation.totalDutystringNoThe customer duty amount.
data.valuation.taxesIncludedbooleanNoIndicates whether the product price finalLinePrice includes taxes (including both the customer duty and the consumption tax). Valid values are:
+ true: finalLinePrice includes taxes.
+ false: finalLinePrice does not include taxes.
data.valuation.totalTipstringNoThe tip amount.
data.valuation.adjustPricestringNoThe amount rounded off.
data.valuation.grandTotalstringYesThe total amount.
data.notestringNoThe shopping cart note.
data.localDiscountobjectNoThe local discount information.
data.localDiscount.titlestringNoThe discount title.
data.localDiscount.amountstringNoThe discount amount. Either amount or percentage will be returned, but not both.
data.localDiscount.percentagestringNoThe discount percentage. Either amount or percentage will be returned, but not both.
Value range: 0-1
Example: 0.25
data.codeDiscountsstring[]NoA list of discount codes added to the shopping cart.
data.propertiesobjectNoA reserved field for future expansion. Currently undefined for specific use.

operateCartDiscountCode

Use this API to add or delete a specified discount code from the shopping cart.

  • Request parameters
Parameter nameTypeRequired or notDescription
operateActionstringYesThe operation on discount codes:
+ Add: indicates adding the discount code.
+ Clear: indicates deleting the discount code.
discountCodestringYesThe discount code.
Example:ETIFRN8ODO8U
  • Response parameters
Parameter nameTypeRequired or notDescription
codenumberYesThe error code.
msgstringNoThe error message. This parameter is returned when the value of code is not 0.
timeStampnumberYesThe response time of the API call, formatted as a 13-digit millisecond timestamp.

operateCartDiscount

Use this API to add or delete a shopping cart discount for orders or products. It supports percentage-based and fixed-amount discounts.

  • Request parameters
Parameter nameTypeRequired or notDescription
operateActionstringYesThe operation on discounts. Valid values are:
+ Add: indicates adding the discount.
+ Clear: indicates deleting the discount.
discountTitlestringNoThe title of the discount.
discountTypestringNoThe discount type. Valid values are:
+ Percent: indicates the percentage-based discount.
+ Amount: indicates the fixed-amount discount.
discountAmountstringNoThe discount information. Pass in the value based on different discountType values:
+ Percent: pass in a string value from 0 to 1 representing the discount percentage.
+ Amount: pass in a specific discount amount as a string, such as "10.22". The currency follows the store currency.
discountDimensionstringYesThe discount dimension. Valid values are:
+ Product: Discounts applied at the product level.
+ Order: Discounts applied at the order level.
skuIdstringNoThe SKU ID.
Specify this parameter when the value of discountDimension is Product.
  • Response parameters
Parameter nameTypeRequired or notDescription
codenumberYesThe error code.
msgstringNoThe error message. This parameter is returned when the value of code is not 0.
timeStampnumberYesThe response time of the API call, formatted as a 13-digit millisecond timestamp.

operateCartProduct

Use this API to add or delete products from the shopping cart.

  • Request parameters
Parameter nameTypeRequired or notDescription
operateActionstringYesThe operation on products:
+ Add: indicates adding products.
+ Clear: indicates deleting products.
skuIdstringYesThe SKU ID.
serialCodesstring[]NoA list of SKU serial numbers.
quantitynumberNoThe number of products added or deleted from the shopping cart.
Value range: 1-999
  • Response parameters
Parameter nameTypeRequired or notDescription
codenumberYesThe error code.
msgstringNoThe error message. This parameter is returned when the value of code is not 0.
timeStampnumberYesThe response time of the API call, formatted as a 13-digit millisecond timestamp.

operateCartCustomer

Use this API to add or delete a customer from the shopping cart.

  • Request parameters
Parameter nameTypeRequired or notDescription
operateActionstringYesThe operation on a customer:
+ Add: indicates adding a customer.
+ Clear: indicates deleting a customer.
customerIdstringNoThe ID of the customer.
Required when the value of operateAction is Add.
Not required when the value of operateAction is Clear. Because only one customer can be in the shopping cart at a time, the existing customer information in the cart will be directly deleted.
  • Response parameters
Parameter nameTypeRequired or notDescription
codenumberYesThe error code.
msgstringNoThe error message. This parameter is returned when the value of code is not 0.
timeStampnumberYesThe response time of the API call, formatted as a 13-digit millisecond timestamp.

addCustomSales

Use this API to add custom product information to the shopping cart.

  • Request parameters
Parameter nameTypeRequired or notDescription
titlestringNoThe title of the custom product.
pricestringYesThe product amount, formatted as a currency-free price string.
For example, "100.00" represents 100 Chinese Yuan (CNY) in stores using this currency.
  • Response parameters
Parameter nameTypeRequired or notDescription
codenumberYesThe error code.
msgstringNoThe error message. This parameter is returned when the value of code is not 0.
timeStampnumberYesThe response time of the API call, formatted as a 13-digit millisecond timestamp.

Order

getCurrentOrderId

Use this API to get the ID of the last completed order, or a specific historical order ID when viewing order history.

  • Request parameters: none
  • Response parameters
Parameter nameTypeRequired or notDescription
codenumberYesThe error code.
msgstringNoThe error message. This parameter is returned when the value of code is not 0.
timeStampnumberYesThe response time of the API call, formatted as a 13-digit millisecond timestamp.
dataobjectNoThis parameter is returned when the value of code is 0.
data.orderIdstringNoThe order ID.

POSEvent_orderCompleted

Use this API to listen for the ID of the last completed order. When an order is successfully created, this API will notify the Web window page.

  • Request parameters: none
  • Response parameters
Parameter nameTypeRequired or notDescription
codenumberYesThe error code.
msgstringNoThe error message. This parameter is returned when the value of code is not 0.
timeStampnumberYesThe response time of the API call, formatted as a 13-digit millisecond timestamp.
dataobjectYesThis parameter is returned when the value of code is 0.
data.orderIdstringYesThe order ID.

Hardware management

getCurrentHardwareInfo

Use this API to get information about the third-party hardware device connected by the SHOPLINE POS app.

  • Request parameters: none
  • Response parameters
Parameter nameTypeRequired or notDescription
codenumberYesThe error code.
msgstringNoThe error message. This parameter is returned when the value of code is not 0.
timeStampnumberYesThe response time of the API call, formatted as a 13-digit millisecond timestamp.
dataobject[]NoThis parameter is returned when the value of code is 0.
data.hardwareTypestringNoThe type of the hardware. Valid values are:
+ receiptPrinter: receipt printer
+ labelPrinter: label printer
data.hardwareBrandstringNoThe hardware brand. Valid values are:
+ star
+ sunmi
+ epson
+ feie
+ socket
+ brother
+ zebra
+ unknown
If the hardware brand is not included in the valid values, unknown is returned.
data.namestringNoThe name of the device.
data.connectionTypestringNoThe connection method used by the hardware. Valid values are:
+ bluetooth: Bluetooth connection
+ wifi: WiFi connection
+ LAN: Local Area Network (LAN) connection
+ usb: USB connection
data.statusstringNoThe connection status of the hardware. Valid values are:
+ connected: indicates that the hardware is connected.
+ unconnected: indicates that the hardware is not connected.

POSEvent_currentHardware

Use this API to listen for hardware device connections, detecting additions and removals. When there are changes, this API will notify the Web window page.

  • Request parameters: none
  • Response parameters
Parameter nameTypeRequired or notDescription
codenumberYesThe error code.
msgstringNoThe error message. This parameter is returned when the value of code is not 0.
timeStampnumberYesThe response time of the API call, formatted as a 13-digit millisecond timestamp.
dataobject[]NoThis parameter is returned when the value of code is 0.
data.hardwareTypestringNoThe type of the hardware. Valid values are:
+ receiptPrinter: receipt printer
+ labelPrinter: label printer
data.hardwareBrandstringNoThe hardware brand. Valid values are:
+ star
+ sunmi
+ epson
+ feie
+ socket
+ brother
+ zebra
+ unknown
If the hardware brand is not included in the valid values, unknown is returned.
data.namestringNoThe name of the device.
data.connectionTypestringNoThe connection method used by the hardware. Valid values are:
+ bluetooth: Bluetooth connection
+ wifi: WiFi connection
+ LAN: Local Area Network (LAN) connection
+ usb: USB connection
data.statusstringNoThe connection status of the hardware. Valid values are:
+ connected: indicates that the hardware is connected.
+ unconnected: indicates that the hardware is not connected.

openAddHardwareView

Use this API to access the device connection interface, which opens a new window for connecting third-party printer hardware, such as a receipt printer, simplifying the connection process.

  • Request parameters
Parameter nameTypeRequired or notDescription
hardwareTypeStringYesThe type of the hardware. Valid values are:
+ receiptPrinter: receipt printer
+ labelPrinter: label printer
  • Response parameters
Parameter nameTypeRequired or notDescription
codenumberYesThe error code.
msgstringNoThe error message. This parameter is returned when the value of code is not 0.
timeStampnumberYesThe response time of the API call, formatted as a 13-digit millisecond timestamp.

sendPrinterCommand

Use this API to send print information. It supports printing images encoded in the base64 format.

  • Request parameters
Parameter nameTypeRequired or notDescription
printInfoStringYesThe image in the base64 encoding format. Only support printing images.
printQuantitynumberYesThe number of the image that needs to be printed.
Value range: 1-999
  • Response parameters
Parameter nameTypeRequired or notDescription
codenumberYesThe error code.
msgstringNoThe error message. This parameter is returned when the value of code is not 0.
timeStampnumberYesThe response time of the API call, formatted as a 13-digit millisecond timestamp.

openCameraScan

Use this API to open the camera on a mobile device for scanning barcodes. It supports both linear and QR code scanning. Upon successful scanning, an asynchronous callback will be triggered to return the scanned barcode string information.

  • Request parameters: none
  • Response parameters
Parameter nameTypeRequired or notDescription
codenumberYesThe error code.
msgstringNoThe error message. This parameter is returned when the value of code is not 0.
timeStampnumberYesThe response time of the API call, formatted as a 13-digit millisecond timestamp.
dataobjectNoThis parameter is returned when the value of code is 0.
data.codestringNoThe scanned barcode data.

openSharePanel

Use this API to open the share panel.

  • Request parameters
Parameter nameTypeRequired or notDescription
textstringNoThe text to be shared.
imageUrlstringNoThe URL of the image to be shared.
imageFilestringNoThe file of the base64 encoded image to be shared.
filestringNoThe file of the base64 encoded PDF to be shared.
fileUrlstringNoThe URL of the PDF file to be shared.
  • Response parameters
Parameter nameTypeRequired or notDescription
codenumberYesThe error code.
msgstringNoThe error message. This parameter is returned when the value of code is not 0.
timeStampnumberYesThe response time of the API call, formatted as a 13-digit millisecond timestamp.

API error codes

After calling the API, if the returned error code is not 0, it indicates a failure in the API call. You can refer to the following table to check the specific reasons for the error based on the returned error codes.

Success code

CodeDescription
0The API call is successful.

Common error codes

CodeDescription
1The API call fails.
1001The URL format error.
1002Parameters missing.
1003Parameter type error.
1004You do not have permission to call this API. Check if the currently logged-in employee has the authorization to perform this action.
CodeDescription
3001The product cannot be found according to the SKU ID.
CodeDescription
6001The discount code is invalid.
6002The discount code has been used.
6003The product cannot be found.
6004The customer cannot be found.
6005The shopping cart is empty.
6006Shopping cart pricing fails.
6007Fail to use the discount code.
6008The shopping cart has utilized offline pricing and is not accessible to use.
6009The number of products in the shopping cart reaches the maximum limit.
6010A refund is in process. You cannot operate the shopping cart.
CodeDescription
5001The software type is not supported.
5002The print is not connected.
5003Image parsing fails.
5004Image download fails.
5005File parsing fails.
5006File download fails.
5007Fail to obtain the camera permission.
Was this article helpful to you?

Error loading component.

Error loading component.