eLiga Third-Party API Documentation

website·Indexed 29 days ago

https://yj26141780712.github.io/eligaDocs

Documentation for integrating third-party systems with eLiga, featuring APIs for personnel information import and listing, device management, and real-time data retrieval via WebSocket. Includes detailed JSON data structures for device training and testing across hardware models such as T130-VBT, T232, S230, T100, T103, T160, T168, T120, T131, and T110, as well as token authentication guidelines.

Tokens
12K
Snippets
40
Records
48
Agent score
75%

What's inside eLiga

  1. Implement facial recognition login flow for devices

    The facial recognition login process is handled via WebSocket communication between the server and the device:

    1. The device selects facial login and connects to the configured WebSocket address.
    2. The server sends a command to start facial recognition.
    3. The device sends the captured face image in base64 format to the server.
    4. The server responds with either a success message (including user data) or an error message.
    // 1. Server starts recognition
    { "code":"start" }
    
    // 2. Device sends image
    { "image":"base64_encoded_image" }
    
    // 3. Server success response
    {
        "code":"ok",
        "message":"人脸认证成功",
        "data": {
            "userId": 12,
            "name":"运动员12",
            "avatar":"https://www.eliga.cn/head/12.png",
            "height": 170,
            "weight": 60,
            "sex": 1,
            "age": 30
        }
    }
    
    // 4. Server failure response
    { "code":"error", "message":"人脸认证失败" }
  2. Obtain an API access token

    The token is a globally unique credential required for all API calls. It must be stored securely with at least 512 characters of space.

    Key Constraints:

    • Validity: The token is valid for 2 hours (7200 seconds).
    • Refresh: Tokens must be refreshed periodically. Requesting a new token will invalidate the previous one.
    • Access: Third-party credentials (appid and secret) are not open for public application; contact the development team to obtain them.
  3. Implement QR code login flow for devices

    The QR code login process involves the device, a third-party app, and a third-party server:

    1. The device selects QR code login and establishes a WebSocket connection to the configured WebSocket address.
    2. A third-party app scans the login QR code and sends a login request to the third-party server using the link embedded in the QR code.
    3. Upon successful identity verification, the third-party server sends a login success message to the device via the WebSocket connection.
    4. The device enters the main interface upon receiving the success message.
    {
        "event":"login:ok",
        "data": {
            "userId": 12, // User unique identifier
            "name":"运动员12", // User name
            "avatar":"https://www.eliga.cn/head/12.png", // Avatar URL
            "height": 170, // Height
            "weight": 60, // Weight
            "sex": 1, // Gender: 0 Male, 1 Female
            "age": 30 // Age
        }
    }
  4. Connect to the WebSocket for real-time device data

    To receive real-time device data, establish a WebSocket connection using the following endpoint. You must provide your interface credential as a token in the query string.
    wss://ilive.eliga.cn/ws/third/deviceRealTimeData?token=YOUR_INTERFACE_TOKEN
  5. T160 Hip Adductor and T168 Squat Trainer data structure

    The T160 (deviceType: 5) and T168 (deviceType: 6) trainers share the same data structure. They record resistance settings (set vs real), test data for multiple sets (up to 6 sets), and coordinate pairs for power and speed curves (Load in kg + Power in W or Speed in m/s).
    {
        "dataType" : 1, // 0: Training, 1: Test
        "actName" : "俯身飞鸟", // Action name
        "startTime": "2023-07-19 14:10:25",
        "endTime": "2023-07-19 14:10:40",
        "powerSet" : ["8.1","9.9","11.7","13.5","15.3","17.1"], // Set resistance (kg) for 1-6 sets
        "powerReal" : ["27.1","26.2","28.2","25.1","30.6","27.1"], // Actual resistance at max power (kg)
        "testData": [[332.5],[336.8],[356.3],[123.4],[478.3],[332.5]], // Max power per set (W)
        "powerCurve" : [1,2], // Continuous curve: [Load(kg), Power(W)]
        "powerScatterCurve" : [1,2], // Scatter curve: [Load(kg), Power(W)]
        "speedCurve" : [1,2], // Continuous curve: [Load(kg), Speed(m/s)]
        "speedScatterCurve" : [1,2], // Scatter curve: [Load(kg), Speed(m/s)]
        "maxPower" : "0.0", // Unit: W
        "maxPowerLoad" : "0.0" // Unit: kg
    }
  6. Data structure for T232 Non-Track Functional Trainer

    The T232 Non-Track Functional Trainer (deviceType: 1) records testing data focusing on resistance settings, actual resistance achieved, and power/speed metrics. It uses a similar curve structure to the T130 for visualizing load vs. performance.
    {
        "dataType" : 1, // 0: Training, 1: Test
        "actName" : "俯身飞鸟",
        "startTime": "2023-07-19 14:10:25",
        "endTime": "2023-07-19 14:10:40",
        "powerSet" : ["8.1","9.9","11.7","13.5","15.3","17.1"], // Resistance setting (kg)
        "powerReal" : ["27.1","26.2","28.2","25.1","30.6","27.1"], // Actual resistance at max power (kg)
        "testData": [[332.5],[336.8],[356.3],[123.4],[478.3],[332.5]], // Max power per set (W)
        "powerCurve" : [1,2], // [load(kg), power(W)]
        "powerScatterCurve" : [1,2], // [load(kg), power(W)]
        "speedCurve" : [1,2], // [load(kg), speed(m/s)]
        "speedScatterCurve" : [1,2], // [load(kg), speed(m/s)]
        "maxPower" : "0.0", // Max power (W)
        "maxPowerLoad" : "0.0", // Max power load (kg)
        "bestPower" : "0.0", // Best power (W)
        "bestPowerLoad" : "0.0", // Best power load (kg)
        "maxLoad" : "0.0"
    }
  7. Data structure for T100 Power Bike

    The T100 Power Bike (deviceType 3) records training and testing data including power, cadence, heart rate, and symmetry. The curveData field contains a series of arrays representing time, distance, force, speed, power, cadence, and heart rate.
    {
    	"dataType": 0, // 0: Training, 1: Test
    	"modeName": "自由骑", // Mode name
    	"modeId": 0, // Mode ID
    	"curveData": [[ 0, 0.01, 90.1, 0.43, 9.61, 5.89, 0 ], []], // [time(s), distance(km), force(N), speed(km/h), power(w), cadence(rpm), heartRate(bpm)]
    	"startTime": "2023-07-19 14:10:25", // y-m-d h:m:s
    	"endTime": "2023-07-19 14:10:40",
    	"totalTime": "00:00:07",
    	"totalDistance": 0.01, // km
    	"totalEnergy": 1.05, // kcal
    	"maxHeartRate": 0, // bpm
    	"avgHeartRate": 0, // bpm
    	"avgSpeed": 5.8, // km/h
    	"maxSpeed": 8.48, // km/h
    	"avgPower": 0, // w
    	"maxPower": 1, // w
    	"maxCadence": 2, // rpm
    	"avgCadence": 2, // rpm
    	"maxForceAngleLeft": 50.1, // degrees
    	"maxForceAngleRight": 50.2, // degrees
    	"totalSymmetryLeft": 20, // % output
    	"totalSymmetryRight": 80, // % output
    	"powerWeight": 2.333, // w/kg
    	"avgRate": "10:20", // m:s
    	"polarChartLists": [[], [[6.93, 110.18]]], // Polar curve x,y values
    	"VO2max": 0, // ml/kg/min
    	"target": " ",
    	"perform": " "
    }
  8. Reference device training data parameters for force measurement

    The following parameters are used in device training data structures to measure force, timing, and balance. These keys are typically used in JSON payloads for hardware devices monitoring peak force and development rates.
    {
      "peakForceImpt+weight/peakForceImpt": "Peak Force / Net Peak Force",
      "relativePeakForce": "Relative Peak Force",
      "specificTimeValue": "Force value at a specific time",
      "rateForceDevelopment": "Rate of Force Development (RFD) at a specific time",
      "impulse": "Impulse at a specific time",
      "peakForceDevelopmentTimeLeft": "Peak force development time (s) [Left]",
      "peakForceDevelopmentTimeRight": "Peak force development time (s) [Right]",
      "peakForceDevelopmentTimeJoin": "Peak force development time (s) [Combined]",
      "peakForceHoldTimeLeft": "Peak force hold time (s) [Left]",
      "peakForceHoldTimeRight": "Peak force hold time (s) [Right]",
      "peakForceHoldTimeJoin": "Peak force hold time (s) [Combined]",
      "netMaxPeakForceLeft": "Absolute peak force (N) [Left]",
      "netMaxPeakForceRight": "Absolute peak force (N) [Right]",
      "specificTimeNetForceLeft": "Absolute force (N) at specific times [Left] (Expected format: [[50,0],[100,0],[150,0],[200,0]] for 50ms, 100ms, 150ms, 200ms)",
      "specificTimeNetForceRight": "Absolute force (N) at specific times [Right] (Expected format: [[50,0],[100,0],[150,0],[200,0]] for 50ms, 100ms, 150ms, 200ms)",
      "specificTimeRFDLeft": "RFD (N/s) at specific times [Left] (Expected format: [[50,0],[100,0],[150,0],[200,0]] for 50ms, 100ms, 150ms, 200ms)",
      "specificTimeRFDRight": "RFD (N/s) at specific times [Right]",
      "specificTimeBalanceRatio": "Balance ratio at specific times [Left] (Expected format: [[50,0],[100,0],[150,0],[200,0]] for 50ms, 100ms, 150ms, 200ms)",
      "standardDeviation": "Standard Deviation",
      "leftRightPeakForceGrowthRateComparison": "Comparison of peak force development time between left and right sides",
      "peakForceMomentComparison": "Left/Right ratio of the combined peak force moment"
    }
  9. Integrate device data ingestion

    Third-party systems must implement a data receiving interface to capture device metrics. The device sends a JSON payload containing the device serial number, user ID, and specific training/test data including timestamps, mode, and action details.
    {
        "deviceSn":"T232-0002",
        "userId":2,
        "data":{
            "dataType":1, // Data type: 0 Training, 1 Testing
            "startTime":"2022-08-01 09:10:10", // Start time
            "endTime":"2022-08-01 09:10:10", // End time
            "modeId": 0,  // Mode ID
            "modeName" :"恒力", // Mode name
            "actId": 0, // Action ID
            "actName":"卧推", // Action name
            "data": { // Device-specific data object
    
            }
        }
    }
  10. T100 Power Bike data structure

    The T100 Power Bike (deviceType: 3) uses a specific JSON structure to record cycling metrics. Key data includes curveData (a 2D array containing time, distance, force, speed, power, cadence, and heart rate) and various peak/average metrics for speed, power, and cadence. It also tracks left/right symmetry and force angles.
    {
    	"dataType": 1, // 0: Training, 1: Test
    	"modeName": "自由骑", // Mode name
    	"modeId": 0, // Mode ID
    	"curveData": [[ 0, 0.01, 90.1, 0.43, 9.61, 5.89, 0 ], []], // [time(s), distance(km), force(N), speed(km/h), power(w), cadence(rpm), heartRate(bpm)]
    	"startTime": "2023-07-19 14:10:25", // y-m-d h:m:s
    	"endTime": "2023-07-19 14:10:40",
    	"totalTime": "00:00:07",
    	"totalDistance": 0.01, // km
    	"totalEnergy": 1.05, // kcal
    	"maxHeartRate": 0, // bpm
    	"avgHeartRate": 0, // bpm
    	"avgSpeed": 5.8, // km/h
    	"maxSpeed": 8.48, // km/h
    	"avgPower": 0, // w
    	"maxPower": 1, // w
    	"maxCadence": 2, // rpm
    	"avgCadence": 2, // rpm
    	"maxForceAngleLeft": 50.1, // degrees
    	"maxForceAngleRight": 50.2, // degrees
    	"totalSymmetryLeft": 20, // percentage
    	"totalSymmetryRight": 80, // percentage
    	"powerWeight": 2.333, // w/kg
    	"avgRate": "10:20", // m:s
    	"polarChartLists": [[], [[6.93, 110.18]]], // Polar curve [x, y]
    	"VO2max": 0, // ml/kg/min
    	"target": " ",
    	"perform": " "
    }
  11. Data structure for T133 Segment Timing (分段计时)

    The T133 device (deviceType: 23) uses a specific JSON structure to record timing intervals and photoelectric gate data. The dataType field distinguishes between training (0) and testing (1).
    {
        "dataType": 1, // 0: Training, 1: Test
        "actName": "传统测试", // Action name
        "startTime": "2024-03-04 15:01:47",
        "endTime": "2024-03-04 15:02:32",
        "path": [98, 1, 2, 3],
        "projectid": 1,
        "data": [
            {
                "id": "1711698699143", // Current timestamp of training data
                "uid": 1087, // Coach ID
                "tid": 160, // Team ID
                "tName": "足球队", // Team Name
                "projectname": "", // Project name (currently unused)
                "projectdesc": "", // Project description (currently unused)
                "projectid": "", // Project ID (currently unused)
                "imgaddress": "",
                "name": "王杰", // Trainee name
                "personid": 1087,
                "lastMinute": 1711698699000, // Currently unused
                "time": "", // Currently unused
                "children": ["1.95", "3.80"], // Training interval times
                "stampList": [17416, 19267], // Timestamps from photoelectric gates
                "qipaodata": 15469, // Start time
                "errList": [1, 1], // Error status: 1 = Correct, 0 = Error (highlighted red)
                "path": "2-3" // Path
            }
        ],
        "sonlauch": {}
    }
  12. Request a token via the getToken API

    Use a GET request to the /eliga/api/third/getToken endpoint to retrieve an access token.

    Request Parameters:

    • appid (Required): The unique third-party user credential.
    • secret (Required): The unique third-party user credential secret (appsecret).

    Response Fields:

    • code: Result status. 200 indicates success; other values indicate an error.
    • message: Error description.
    • data.token: The retrieved access token.
    • data.expiresIn: Token validity duration in seconds.
    GET https://ilive.eliga.cn/eliga/api/third/getToken?appid=APPID&secret=APPSECRET
    {
        "code":"200",
        "message":"ok",
        "data":{
            "token":"token",
            "expiresIn":7200
        }
    }