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:
- You have created a development store.
- You have created an app in the SHOPLINE Partner Portal.
- You have created a Web extension for your public app.
- Use SHOPLINE POS version 2.15.0 or above.
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 name | Type | Description |
---|---|---|
code | number | The error code returned by the API call. Refer to Error code for details. |
msg | string | The error message returned by the API call when code is not 0 . |
timeStamp | number | The response time of the API call, formatted as a 13-digit millisecond timestamp. |
data | object | The 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 name | Type | Required or not | Description |
---|---|---|---|
url | string | Yes | The link to the web page that you wish to open. |
style | number | No | The 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 . |
position | object | No | The position of the window on the screen. Specify this parameter when the value of style is 1 . |
position.x | number | No | Horizontal coordinate that scales proportionally with the screen width. The default value is 0 .Value range: 0-1 |
position.y | number | No | Vertical coordinate that scales proportionally with the screen height. The default value is 0 .Value range: 0-1 |
position.width | number | No | The 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.height | number | No | The 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 name | Type | Required or not | Description |
---|---|---|---|
code | number | Yes | The error code. |
msg | string | No | The error message. This parameter is returned when the value of code is not 0 . |
timeStamp | number | Yes | The 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 name | Type | Required or not | Description |
---|---|---|---|
code | number | Yes | The error code. |
msg | string | No | The error message. This parameter is returned when the value of code is not 0 . |
timeStamp | number | Yes | The 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 name | Type | Required or not | Description |
---|---|---|---|
text | string | Yes | The text to be displayed in the toast. |
- Response parameters
Parameter name | Type | Required or not | Description |
---|---|---|---|
code | number | Yes | The error code. |
msg | string | No | The error message. This parameter is returned when the value of code is not 0 . |
timeStamp | number | Yes | The 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 name | Type | Required or not | Description |
---|---|---|---|
enable | boolean | Yes | Indicates whether the pull-to-refresh functionality is enabled. Valid values are: + true : enable the functionality+ false : disable the functionality |
- Response parameters
Parameter name | Type | Required or not | Description |
---|---|---|---|
code | number | Yes | The error code. |
msg | string | No | The error message. This parameter is returned when the value of code is not 0 . |
timeStamp | number | Yes | The 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 name | Type | Required or not | Description |
---|---|---|---|
mode | number | Yes | The 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 name | Type | Required or not | Description |
---|---|---|---|
code | number | Yes | The error code. |
msg | string | No | The error message. This parameter is returned when the value of code is not 0 . |
timeStamp | number | Yes | The 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 name | Type | Required or not | Description |
---|---|---|---|
code | number | Yes | The error code. |
msg | string | No | The error message. This parameter is returned when the value of code is not 0 . |
timeStamp | number | Yes | The response time of the API call, formatted as a 13-digit millisecond timestamp. |
data | object | No | This parameter is returned when the value of code is 0 . |
data.connectionStatus | string | No | Device 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 name | Type | Required or not | Description |
---|---|---|---|
code | number | Yes | The error code. |
msg | string | No | The error message. This parameter is returned when the value of code is not 0 . |
timeStamp | number | Yes | The response time of the API call, formatted as a 13-digit millisecond timestamp. |
data | object | Yes | This parameter is returned when the value of code is 0 . |
data.connectionStatus | string | Yes | Device 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 name | Type | Required or not | Description |
---|---|---|---|
code | number | Yes | The error code. |
msg | string | No | The error message. This parameter is returned when the value of code is not 0 . |
timeStamp | number | Yes | The response time of the API call, formatted as a 13-digit millisecond timestamp. |
data | object | No | This parameter is returned when the value of code is 0 . |
data.deviceName | string | No | The name of the device. For example, iPhone 14 Pro and Sunmi T2 . |
data.deviceId | string | No | The ID of the device. For example, 00:0C:29:01:98:27 . |
data.osVersion | string | No | The version of the device's operating system. For example, 17.2.1 . |
data.os | string | No | The device's operating system type. Valid values are: + Android + iOS |
data.appVersion | string | No | The 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 name | Type | Required or not | Description |
---|---|---|---|
code | number | Yes | The error code. |
msg | string | No | The error message. This parameter is returned when the value of code is not 0 . |
timeStamp | number | Yes | The response time of the API call, formatted as a 13-digit millisecond timestamp. |
data | object | No | This parameter is returned when the value of code is 0 . |
data.appLanguage | string | No | The 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 name | Type | Required or not | Description |
---|---|---|---|
code | number | Yes | The error code. |
msg | string | No | The error message. This parameter is returned when the value of code is not 0 . |
timeStamp | number | Yes | The response time of the API call, formatted as a 13-digit millisecond timestamp. |
data | object | Yes | This parameter is returned when the value of code is 0 . |
data.appLanguage | string | Yes | The 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 name | Type | Required or not | Description |
---|---|---|---|
code | number | Yes | The error code. |
msg | string | No | The error message. This parameter is returned when the value of code is not 0 . |
timeStamp | number | Yes | The response time of the API call, formatted as a 13-digit millisecond timestamp. |
data | object | No | This parameter is returned when the value of code is 0 . |
data.storeId | string | No | The ID of the store. |
data.offlineStoreId | string | No | The ID of the branch store. |
data.posStaffId | string | No | The ID of the employee in the POS system. |
data.currencyCode | string | No | A three-letter store currency code that follows the ISO 4217 standard. |
data.currentStaffUid | string | No | The user ID of the employee. |
data.loginStaffUid | string | No | The 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 name | Type | Required or not | Description |
---|---|---|---|
code | number | Yes | The error code. |
msg | string | No | The error message. This parameter is returned when the value of code is not 0 . |
timeStamp | number | Yes | The response time of the API call, formatted as a 13-digit millisecond timestamp. |
data | object | No | This parameter is returned when the value of code is 0 . |
data.storeId | string | No | The ID of the store. |
data.offlineStoreId | string | No | The ID of the branch store. |
data.posStaffId | string | No | The ID of the employee in the POS system. |
data.uid | string | No | The 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 name | Type | Required or not | Description |
---|---|---|---|
code | number | Yes | The error code. |
msg | string | No | The error message. This parameter is returned when the value of code is not 0 . |
timeStamp | number | Yes | The response time of the API call, formatted as a 13-digit millisecond timestamp. |
data | object | No | This parameter is returned when the value of code is 0 . |
data.isLogin | boolean | No | Indicates whether the POS is logged in. Valid values are: + true : logged in+ false : not logged inDefault value: false |
data.uid | string | No | The ID of the currently logged-in POS account. |
data.otp | string | No | The 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 name | Type | Required or not | Description |
---|---|---|---|
code | number | Yes | The error code. |
msg | string | No | The error message. This parameter is returned when the value of code is not 0 . |
timeStamp | number | Yes | The response time of the API call, formatted as a 13-digit millisecond timestamp. |
data | object | No | This parameter is returned when the value of code is 0 . |
data.deviceInfo | string | No | A 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.uid | string | No | The ID of the currently logged-in POS account. |
data.otp | string | No | The credential for the POS server request, used for subsequent access to the POS server API. |
data.lang | string | No | The language that is used in the SHOPLINE POS. Valid values are: + en : English+ zh-Hans : Simplified Chinese + zh-Hant : Traditional Chinese+ ja : Japanese |
data.ticket | string | No | A 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 name | Type | Required or not | Description |
---|---|---|---|
offlineStoreID | string | Yes | The ID of the branch store. |
queryString | string | No | The 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 . |
sortType | string | No | The 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. |
pageSize | number | Yes | The number of products returned per page. Value range: 1-500 |
pageNum | number | Yes | The requested page number. Page numbering starts from 1 . Value range: 1-unlimited |
- Response parameters
Parameter name | Type | Required or not | Description |
---|---|---|---|
code | number | Yes | The error code. |
msg | string | No | The error message. This parameter is returned when the value of code is not 0 . |
timeStamp | number | Yes | The response time of the API call, formatted as a 13-digit millisecond timestamp. |
data | object | No | This parameter is returned when the value of code is 0 . |
data.productIds | string[] | No | A list of product IDs. |
getProductsInfo
Use this API to get product details in bulk for the currently logged-in branch store.
- Request parameters
Parameter name | Type | Required or not | Description |
---|---|---|---|
productIds | string[] | Yes | A list of product IDs. It is recommended to limit each query to a maximum of 50 products. Maximum size: 500 |
offlineStoreID | string | Yes | The ID of the branch store for which product details are being queried. |
- Response parameters
Parameter name | Type | Required or not | Description |
---|---|---|---|
code | number | Yes | The error code. |
msg | string | No | The error message. This parameter is returned when the value of code is not 0 . |
timeStamp | number | Yes | The response time of the API call, formatted as a 13-digit millisecond timestamp. |
data | object[] | No | This parameter is returned when the value of code is 0 . |
data.productId | string | No | The ID of the product. |
data.skus | object[] | Yes | A list of product SKU information. |
data.skus.skuId | string | Yes | The SKU ID. |
data.skus.locationPrice | Int | Yes | The price of the product sold in the branch store. |
data.skus.serialNumber | string[] | No | A 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 name | Type | Required or not | Description |
---|---|---|---|
code | number | Yes | The error code. |
msg | string | No | The error message. This parameter is returned when the value of code is not 0 . |
timeStamp | number | Yes | The response time of the API call, formatted as a 13-digit millisecond timestamp. |
data | object | No | This parameter is returned when the value of code is 0 . |
data.lineItems | object[] | No | A list of shopping cart item line information. |
data.lineItems.productId | string | Yes | The ID of the product. |
data.lineItems.skuId | string | Yes | The ID of the SKU. |
data.lineItems.finalPrice | string | Yes | A 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.quantity | number | Yes | The add-to-cart quantity. |
data.lineItems.finalLinePrice | string | Yes | The total price of the products in the item line. |
data.customer | object | No | The customer information. |
data.customer.uid | string | No | The customer's ID. |
data.customer.email | string | No | The customer's email. |
data.customer.phone | string | No | The customer's phone number. |
data.valuation | object | No | The pricing information. |
data.valuation.subtotal | string | Yes | The subtotal amount. |
data.valuation.totalDiscounts | string | No | The discount amount. |
data.valuation.deductMemberPointAmount | string | No | The points deduction amount. |
data.valuation.totalTax | string | No | The total consumption tax amount. |
data.valuation.totalDuty | string | No | The customer duty amount. |
data.valuation.taxesIncluded | boolean | No | Indicates 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.totalTip | string | No | The tip amount. |
data.valuation.adjustPrice | string | No | The amount rounded off. |
data.valuation.grandTotal | string | Yes | The total amount. |
data.note | string | No | The shopping cart note. |
data.localDiscount | object | No | The local discount information. |
data.localDiscount.title | string | No | The discount title. |
data.localDiscount.amount | string | No | The discount amount. |
data.localDiscount.percentage | string | No | The discount percentage. Value range: 0-1 Example: 0.25 |
data.codeDiscounts | string[] | No | A list of discount codes added to the shopping cart. |
data.properties | object | No | A 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 name | Type | Required or not | Description |
---|---|---|---|
code | number | Yes | The error code. |
msg | string | No | The error message. This parameter is returned when the value of code is not 0 . |
timeStamp | number | Yes | The response time of the API call, formatted as a 13-digit millisecond timestamp. |
data | object | No | This parameter is returned when the value of code is 0 . |
data.lineItems | object[] | No | A list of shopping cart item line information. |
data.lineItems.productId | string | Yes | The ID of the product. |
data.lineItems.skuId | string | Yes | The ID of the SKU. |
data.lineItems.finalPrice | string | Yes | A 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.quantity | number | Yes | The add-to-cart quantity. |
data.lineItems.finalLinePrice | string | Yes | The total price of the products in the item line. |
data.customer | object | No | The customer information. |
data.customer.uid | string | No | The customer's ID. |
data.customer.email | string | No | The customer's email. |
data.customer.phone | string | No | The customer's phone number. |
data.valuation | object | No | The pricing information. |
data.valuation.subtotal | string | Yes | The subtotal amount. |
data.valuation.totalDiscounts | string | No | The discount amount. |
data.valuation.deductMemberPointAmount | string | No | The points deduction amount. |
data.valuation.totalTax | string | No | The total consumption tax amount. |
data.valuation.totalDuty | string | No | The customer duty amount. |
data.valuation.taxesIncluded | boolean | No | Indicates 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.totalTip | string | No | The tip amount. |
data.valuation.adjustPrice | string | No | The amount rounded off. |
data.valuation.grandTotal | string | Yes | The total amount. |
data.note | string | No | The shopping cart note. |
data.localDiscount | object | No | The local discount information. |
data.localDiscount.title | string | No | The discount title. |
data.localDiscount.amount | string | No | The discount amount. Either amount or percentage will be returned, but not both. |
data.localDiscount.percentage | string | No | The discount percentage. Either amount or percentage will be returned, but not both. Value range: 0-1 Example: 0.25 |
data.codeDiscounts | string[] | No | A list of discount codes added to the shopping cart. |
data.properties | object | No | A 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 name | Type | Required or not | Description |
---|---|---|---|
operateAction | string | Yes | The operation on discount codes: + Add : indicates adding the discount code.+ Clear : indicates deleting the discount code. |
discountCode | string | Yes | The discount code. Example: ETIFRN8ODO8U |
- Response parameters
Parameter name | Type | Required or not | Description |
---|---|---|---|
code | number | Yes | The error code. |
msg | string | No | The error message. This parameter is returned when the value of code is not 0 . |
timeStamp | number | Yes | The 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 name | Type | Required or not | Description |
---|---|---|---|
operateAction | string | Yes | The operation on discounts. Valid values are: + Add : indicates adding the discount.+ Clear : indicates deleting the discount. |
discountTitle | string | No | The title of the discount. |
discountType | string | No | The discount type. Valid values are: + Percent : indicates the percentage-based discount. + Amount : indicates the fixed-amount discount. |
discountAmount | string | No | The 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. |
discountDimension | string | Yes | The discount dimension. Valid values are: + Product : Discounts applied at the product level.+ Order : Discounts applied at the order level. |
skuId | string | No | The SKU ID. Specify this parameter when the value of discountDimension is Product . |
- Response parameters
Parameter name | Type | Required or not | Description |
---|---|---|---|
code | number | Yes | The error code. |
msg | string | No | The error message. This parameter is returned when the value of code is not 0 . |
timeStamp | number | Yes | The 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 name | Type | Required or not | Description |
---|---|---|---|
operateAction | string | Yes | The operation on products: + Add : indicates adding products.+ Clear : indicates deleting products. |
skuId | string | Yes | The SKU ID. |
serialCodes | string[] | No | A list of SKU serial numbers. |
quantity | number | No | The number of products added or deleted from the shopping cart. Value range: 1-999 |
- Response parameters
Parameter name | Type | Required or not | Description |
---|---|---|---|
code | number | Yes | The error code. |
msg | string | No | The error message. This parameter is returned when the value of code is not 0 . |
timeStamp | number | Yes | The 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 name | Type | Required or not | Description |
---|---|---|---|
operateAction | string | Yes | The operation on a customer: + Add : indicates adding a customer.+ Clear : indicates deleting a customer. |
customerId | string | No | The 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 name | Type | Required or not | Description |
---|---|---|---|
code | number | Yes | The error code. |
msg | string | No | The error message. This parameter is returned when the value of code is not 0 . |
timeStamp | number | Yes | The 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 name | Type | Required or not | Description |
---|---|---|---|
title | string | No | The title of the custom product. |
price | string | Yes | The 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 name | Type | Required or not | Description |
---|---|---|---|
code | number | Yes | The error code. |
msg | string | No | The error message. This parameter is returned when the value of code is not 0 . |
timeStamp | number | Yes | The 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 name | Type | Required or not | Description |
---|---|---|---|
code | number | Yes | The error code. |
msg | string | No | The error message. This parameter is returned when the value of code is not 0 . |
timeStamp | number | Yes | The response time of the API call, formatted as a 13-digit millisecond timestamp. |
data | object | No | This parameter is returned when the value of code is 0 . |
data.orderId | string | No | The 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 name | Type | Required or not | Description |
---|---|---|---|
code | number | Yes | The error code. |
msg | string | No | The error message. This parameter is returned when the value of code is not 0 . |
timeStamp | number | Yes | The response time of the API call, formatted as a 13-digit millisecond timestamp. |
data | object | Yes | This parameter is returned when the value of code is 0 . |
data.orderId | string | Yes | The 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 name | Type | Required or not | Description |
---|---|---|---|
code | number | Yes | The error code. |
msg | string | No | The error message. This parameter is returned when the value of code is not 0 . |
timeStamp | number | Yes | The response time of the API call, formatted as a 13-digit millisecond timestamp. |
data | object[] | No | This parameter is returned when the value of code is 0 . |
data.hardwareType | string | No | The type of the hardware. Valid values are: + receiptPrinter : receipt printer + labelPrinter : label printer |
data.hardwareBrand | string | No | The 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.name | string | No | The name of the device. |
data.connectionType | string | No | The 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.status | string | No | The 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 name | Type | Required or not | Description |
---|---|---|---|
code | number | Yes | The error code. |
msg | string | No | The error message. This parameter is returned when the value of code is not 0 . |
timeStamp | number | Yes | The response time of the API call, formatted as a 13-digit millisecond timestamp. |
data | object[] | No | This parameter is returned when the value of code is 0 . |
data.hardwareType | string | No | The type of the hardware. Valid values are: + receiptPrinter : receipt printer + labelPrinter : label printer |
data.hardwareBrand | string | No | The 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.name | string | No | The name of the device. |
data.connectionType | string | No | The 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.status | string | No | The 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 name | Type | Required or not | Description |
---|---|---|---|
hardwareType | String | Yes | The type of the hardware. Valid values are: + receiptPrinter : receipt printer + labelPrinter : label printer |
- Response parameters
Parameter name | Type | Required or not | Description |
---|---|---|---|
code | number | Yes | The error code. |
msg | string | No | The error message. This parameter is returned when the value of code is not 0 . |
timeStamp | number | Yes | The 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 name | Type | Required or not | Description |
---|---|---|---|
printInfo | String | Yes | The image in the base64 encoding format. Only support printing images. |
printQuantity | number | Yes | The number of the image that needs to be printed. Value range: 1-999 |
- Response parameters
Parameter name | Type | Required or not | Description |
---|---|---|---|
code | number | Yes | The error code. |
msg | string | No | The error message. This parameter is returned when the value of code is not 0 . |
timeStamp | number | Yes | The 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 name | Type | Required or not | Description |
---|---|---|---|
code | number | Yes | The error code. |
msg | string | No | The error message. This parameter is returned when the value of code is not 0 . |
timeStamp | number | Yes | The response time of the API call, formatted as a 13-digit millisecond timestamp. |
data | object | No | This parameter is returned when the value of code is 0 . |
data.code | string | No | The scanned barcode data. |
openSharePanel
Use this API to open the share panel.
- Request parameters
Parameter name | Type | Required or not | Description |
---|---|---|---|
text | string | No | The text to be shared. |
imageUrl | string | No | The URL of the image to be shared. |
imageFile | string | No | The file of the base64 encoded image to be shared. |
file | string | No | The file of the base64 encoded PDF to be shared. |
fileUrl | string | No | The URL of the PDF file to be shared. |
- Response parameters
Parameter name | Type | Required or not | Description |
---|---|---|---|
code | number | Yes | The error code. |
msg | string | No | The error message. This parameter is returned when the value of code is not 0 . |
timeStamp | number | Yes | The 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
Code | Description |
---|---|
0 | The API call is successful. |
Common error codes
Code | Description |
---|---|
1 | The API call fails. |
1001 | The URL format error. |
1002 | Parameters missing. |
1003 | Parameter type error. |
1004 | You do not have permission to call this API. Check if the currently logged-in employee has the authorization to perform this action. |
Product related error codes
Code | Description |
---|---|
3001 | The product cannot be found according to the SKU ID. |
Shopping cart related error codes
Code | Description |
---|---|
6001 | The discount code is invalid. |
6002 | The discount code has been used. |
6003 | The product cannot be found. |
6004 | The customer cannot be found. |
6005 | The shopping cart is empty. |
6006 | Shopping cart pricing fails. |
6007 | Fail to use the discount code. |
6008 | The shopping cart has utilized offline pricing and is not accessible to use. |
6009 | The number of products in the shopping cart reaches the maximum limit. |
6010 | A refund is in process. You cannot operate the shopping cart. |
Hardware related error codes
Code | Description |
---|---|
5001 | The software type is not supported. |
5002 | The print is not connected. |
5003 | Image parsing fails. |
5004 | Image download fails. |
5005 | File parsing fails. |
5006 | File download fails. |
5007 | Fail to obtain the camera permission. |