Steps to work with Local API
caution
Local API is only available for Local Hub
SVR_URL: http://{Your Local Hub IP Address}:1080
Step1, Get Access Credentials
YoLink App ([Local Hub] -> [Local Network] -> [Integrations] -> [Local API])
Step2, Obtain Access Token
Obtain the access_token through the Token interface of Open API V2
curl -X POST -d "grant_type=client_credentials&client_id=${ClientId}&client_secret=${ClientSecret}" ${SVR_URL}/open/yolink/token
Step3, Get device list by Access Token
Http Request Simple
curl --location --request POST '${SVR_URL}/open/yolink/v2/api' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer ${access_token}' \
--data-raw '${BDDP}'
Demo Data
Request: JSON of BDDP
{
"method": "Home.getDeviceList"
}
Response: JSON of BUDP
{
"code": "000000",
"time": 1739325898971,
"msgid": 1739325898971,
"method": "Home.getDeviceList",
"desc": "Success",
"data": {
"deviceId": "****4c010001****",
"name": "Door Sensor",
"token": "****2C89C9FE5C30509B9B6****",
"type": "DoorSensor"
}
}
Step4, Control devices with device token
Call ${DeviceType}.* with Device Net Info(DeviceId & Net Token) obtained in Step 3.
Http Request Simple
curl --location --request POST '${SVR_URL}/open/yolink/v2/api' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer ${access_token}' \
--data-raw '${BDDP}'
Demo Data
Request: JSON of BDDP
{
"method": "DoorSensor.getState",
"targetDevice": "****4c010001****",
"token": "****2C89C9FE5C30509B9B6****",
"params": {}
}
Response: JSON of BUDP
{
"code": "000000",
"time": 1739326633594,
"msgid": 1739326633594,
"method": "DoorSensor.getState",
"desc": "Success",
"data": {
"online": false,
"state": {
"state": "closed",
"battery": 4,
"delay": 0,
"version": "041e",
"openRemindDelay": 10,
"alertInterval": 5
},
"reportAt": "2025-02-10T04:00:22.818Z"
}
}