This example page demonstrates how to use the Homey API to interact with devices and create automation flows.
Here's an example of how to retrieve a list of devices using our API:
GET https://api.athom.com/api/v1/devices
Authorization: Bearer {your_access_token}
To create a new automation flow:
POST https://api.athom.com/api/v1/flows
Authorization: Bearer {your_access_token}
Content-Type: application/json
{
"name": "Evening Routine",
"trigger": {
"type": "time",
"time": "19:00"
},
"actions": [
{
"type": "device",
"uri": "homey:device:living-room-lamp",
"action": "turnOn"
},
{
"type": "device",
"uri": "homey:device:thermostat",
"action": "setTemperature",
"args": { "temperature": 20 }
}
]
}
Note: This is a simulated example. In a real implementation, you would need to authenticate and use actual device IDs and access tokens.
With the Homey API, you can create powerful integrations and applications. Some popular use cases include:
Subscribe to realtime events using WebSockets:
const socket = new WebSocket('wss://api.athom.com/realtime');
socket.onopen = () => {
socket.send(JSON.stringify({
type: 'authenticate',
access_token: '{your_access_token}'
}));
};
socket.onmessage = (event) => {
const data = JSON.parse(event.data);
console.log('Received event:', data);
};
Ready to start building with Homey?
Get API Access