SinricPro uses REST for its API. This means it uses JSON for data exchange and follows common HTTP practices for communication.
To interact with the SinricPro API, you’ll need an API key. You can create and manage your API keys within the SinricPro Dashboard under the Credentials section. To create a new API Key click here
Request
curl -X POST 'https://api.sinric.pro/api/v1/auth' --header 'x-sinric-api-key: a614xxxx-xxxx-xxxx-xxxx-xxxxxxxx'
Response
{
"success": true,
"message": "OK.",
"accessToken": "eyJhbG.xxxxxxxxx.xxxxxxxxxxxxxxx...",
"refreshToken": "9i4GV2Llpsl87FoT1HvQcxaybP3xxxxxxxxxxxxxxxx..",
"expiresIn": 604800
}
access Token
is your access token. The access token grants authorization for future API calls. Remember, it will expire after 604800
seconds.
Request
curl -X GET 'https://api.sinric.pro/api/v1/devices' --header 'Authorization: Bearer {accessToken}'
Response
{
"success":true,
"devices":[
{
"name":"TV"
}
]
}
Request
curl -X GET 'https://api.sinric.pro/api/v1/devices/{device_id}' --header 'Authorization: Bearer {accessToken}'
Response
{
"success":true,
"device":{
"name":"TV"
}
}
Request
curl --location 'https://api.sinric.pro/api/v1/devices/{device_id}/action' \
--header 'Authorization: Bearer {accessToken}' \
--header 'Content-Type: application/json' \
--data '{ "type": "request", "action": "setPowerState", "value": "{\"state\":\"On\"}" }'
Note: value
is a string. Use JSON.stringify()
Response
{
"success": true,
"message": "OK. Your message has been queued for processing."
}
If you prefer a single API call to control your devices, explore examples in IFTTT or Apple Shortcuts. These might provide a more user-friendly approach for basic control.
SinricPro prioritizes speed and avoids blocking. All command requests are queued and handled asynchronously, meaning the response might not be immediate. To receive confirmation or continuously monitor device status, subscribe to updates through our SSE (Server-Sent Events) endpoint.
curl -N --http2 -H "Accept:text/event-stream" https://portal.sinric.pro/sse/stream?accessToken={accessToken}
Response
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- 0:00:05 --:--:-- 0
{"event":"deviceConnected","device":{"name":"lightbulb","id":"660a7edf061ee8c78078c5ab"}}
....
{"event":"deviceDisconnected","device":{"name":"switch2","id":"660a6c3d061ee8c78078bf3e"}}
...
{"event":"deviceMessageArrived","device": {"name":"switch2","id":"660a6c3d061ee8c78078bf3e","powerState":"On"}}
Request
curl --location 'https://api.sinric.pro/api/v1/devices/{device_id}/action' \
--header 'Authorization: Bearer {accessToken}' \
--header 'Content-Type: application/json' \
--data '{ "type": "request", "action": "setMode", "value": "{\"mode\":\"Open\"}" }'
Note: value
is a string. Use JSON.stringify()
Request
curl --location 'https://api.sinric.pro/api/v1/devices/{device_id}/action' \
--header 'Authorization: Bearer {accessToken}' \
--header 'Content-Type: application/json' \
--data '{ "type": "request", "action": "setRangeValue", "value": "{\"rangeValue\": 100}" }'
Note: value
is a string. Use JSON.stringify()
Request
curl --location 'https://api.sinric.pro/api/v1/devices/{device_id}/action' \
--header 'Authorization: Bearer {accessToken}' \
--header 'Content-Type: application/json' \
--data '{ "type": "request", "action": "DoorbellPress", "value": "{\"state\": \"pressed\"}" }'
Note: value
is a string. Use JSON.stringify()
Request
curl --location 'https://api.sinric.pro/api/v1/devicess/find' \
--header 'Authorization: Bearer {accessToken}' \
--header 'Content-Type: application/json' \
--data '{ "name" : "TV", "description" : "....." }'
Response
{ "success":true,"devices": [ {"name": "TV"} ] }
Complete API endpoints are available here
Looking for more examples ?