Skip to content

SDK Privatization Example

The SDK can be used normally after the initialization is completed. The following is an example of SDK privatization code:

TypeScript
import { AXRobot, AppMode } from "@autoxing/robot-js-sdk";

// create an instance of AXRobot
const axRobot = new AXRobot("<appId>", "<appSecret>", AppMode.WAN_APP "<serverUrl>", "websocketUrl");

// Initialize the AXRobot instance
const successed = await axRobot.init();
if (successed) {
   try {
     // connect to the specified robot
     const res = await axRobot.connectRobot({
       robotId: "<robotId>"
     });
     console.log("connect success: " + res.robotId);
     // do something with robot
   } catch(err) {
     console.log(err.errText)
   }
} else {
   // initialization failed
}

Parameter Description

Name Type Description
appId string The application ID, which can be obtained by applying to the relevant operators
appSecret string Data request key, which can be obtained by applying to the relevant operators
AppMode string Application mode
serverUrl string Private deployment server address
Access via browser domain name: https://apilocal.autoxing.com/
Access via IP + port: https://IP:4443/
websocketUrl string Optional
If only serverUrl is provided and websocketUrl is omitted, the websocket connection address will be automatically generated based on serverUrl
Access via browser domain name: wss://servicelocal.autoxing.com/
Access via IP + port: wss://IP:4443/
  • Note:
  • 1: Version requirement: SDK v1.0.74 or above
  • 2: If only serverUrl is provided and websocketUrl is omitted, the websocket connection address will be automatically generated based on serverUrl
  • For example: "http://127.0.0.1:8080/" -> "ws://127.0.0.1:8080/", "https://127.0.0.1:8080/" -> "wss://127.0.0.1:8080/"
  • 3: If websocketUrl is provided, the specified URL will be used
  • 4: If you do not know how to obtain the private deployment server address, please consult the relevant operators

Example