Skip to main content

Steps to work with UAC

Step1, Get User Access Credentials (UAC)

Create a UAC in YoLink App ([Account] -> [Advanced Settings] -> [Personal Access Credentials] -> [+])

Step2, Obtain Access Token via UAC

Obtain the access_token of UAC through the Token interface of Open API V2

curl -X POST -d "grant_type=client_credentials&client_id=${UAID}&client_secret=${Secret Key of PAC}" ${SVR_URL}/open/yolink/token

Step3, Get device list by Access Token

Http Request Simple

curl --location --request POST 'https://api.yosmart.com/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",
"time":${timestamp}
}

Response: JSON of BUDP

{
"code": "000000",
"time": 1572322745846,
"msgid": 1572322745,
"method": "Manage.addYoLinkDevice",
"data": {
"deviceId": "****4c160300****",
"deviceUDID": "****ae3685504566af434e0f093c****",
"name": "YoLink Hub",
"token": "****b642-781e-450f-ba86-df28bdea****",
"type": "Hub"
}
}

Step4, Control devices with device token

Call ${DeviceType}.* with Device Net Info(DeviceId & Net Token) obtained in Step 1.

Http Request Simple

curl --location --request POST 'https://api.yosmart.com/open/yolink/v2/api' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer ${access_token}' \
--data-raw '${BDDP}'

Demo Data

Request: JSON of BDDP

{
"method":"Hub.getState",
"time":${timestamp},
"targetDevice":"****4c160300****",
"token":"****b642-781e-450f-ba86-df28bdea****",
"params":{
}
}

Response: JSON of BUDP

{
"code": "000000",
"time": 1572354630744,
"msgid": 1572354631,
"method": "Hub.getState",
"data": {
"version": "0316",
"wifi": {
"ssid": "YoSmart",
"enable": true,
"ip": "192.168.1.164",
"gateway": "192.168.1.1",
"mask": "255.255.255.0"
},
"eth": {
"enable": false
}
}
}

Step5, Get Home General Info

Http Request Simple

curl --location --request POST 'https://api.yosmart.com/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.getGeneralInfo",
"time":${timestamp},
}

Response: JSON of BUDP

{
"code": "000000",
"time": 1640596777941,
"msgid": 1640596777941,
"method": "Manage.getGeneralInfo",
"data": {
"id": "****340cba25****"
}
}

Step6, Subscribe to receive events from devices

 mosquitto_sub -u ${access_token} -p 8003 -h ${API Host} -t yl-home/****340cba25****/+/report