Skip to content

REST API

The REST API provides a simplified interface for reading device state, controlling devices, and running scenes. Authenticate with an access token (hc_...) or OAuth Bearer token.

Base URL: https://api.homecast.cloud/rest

GET /rest/state

Read the current state of all accessible homes, rooms, and accessories.

bash
curl https://api.homecast.cloud/rest/state \
  -H "Authorization: Bearer hc_your_token"

Query parameters

ParameterTypeDescription
filter_by_homestringOnly accessories in this home (by name)
filter_by_roomstringOnly accessories in this room (by name)
filter_by_typestringOnly this accessory type (e.g., lightbulb, thermostat)
filter_by_namestringOnly accessories matching this name

Example with filters:

bash
curl "https://api.homecast.cloud/rest/state?filter_by_type=lightbulb&filter_by_room=Bedroom" \
  -H "Authorization: Bearer hc_your_token"

Response

json
{
  "homes": [
    {
      "id": "home-uuid",
      "name": "My Home",
      "rooms": [
        {
          "id": "room-uuid",
          "name": "Living Room",
          "accessories": [
            {
              "id": "acc-uuid",
              "name": "Floor Lamp",
              "type": "lightbulb",
              "reachable": true,
              "services": [
                {
                  "type": "lightbulb",
                  "characteristics": [
                    { "type": "on", "value": true },
                    { "type": "brightness", "value": 75 }
                  ]
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}

POST /rest/state

Control one or more devices. Send an array of update objects.

bash
curl -X POST https://api.homecast.cloud/rest/state \
  -H "Authorization: Bearer hc_your_token" \
  -H "Content-Type: application/json" \
  -d '[{
    "home": "My Home",
    "room": "Living Room",
    "accessory": "Floor Lamp",
    "on": true,
    "brightness": 80
  }]'

Update fields

Each object must include home, room, and accessory (by name). All other fields are optional.

FieldTypeDescription
homestringHome name (required)
roomstringRoom name (required)
accessorystringAccessory name (required)
onbooleanPower state
brightnessintegerBrightness 0–100
hueintegerColor hue 0–360
saturationintegerColor saturation 0–100
color_tempintegerColor temperature in mireds
activebooleanActive state (air purifiers, humidifiers)
heat_targetfloatHeating target temperature
cool_targetfloatCooling target temperature
hvac_modestringHVAC mode: off, heat, cool, auto
lock_targetintegerLock state: 1 (secured), 0 (unsecured)
alarm_targetintegerSecurity alarm target state
speedintegerFan speed 0–100
volumeintegerSpeaker volume 0–100
mutebooleanSpeaker mute
targetintegerGeneric target position 0–100 (blinds, garage doors)

Response

json
{
  "updated": 1,
  "failed": 0,
  "changes": ["Floor Lamp: on=true, brightness=80"],
  "errors": [],
  "message": "Updated 1 accessories"
}

POST /rest/scene

Execute a HomeKit scene by name.

bash
curl -X POST https://api.homecast.cloud/rest/scene \
  -H "Authorization: Bearer hc_your_token" \
  -H "Content-Type: application/json" \
  -d '{"home": "My Home", "name": "Good Night"}'

Request body

FieldTypeRequiredDescription
homestringYesHome name
namestringYesScene name

Response

json
{ "success": true }

On error:

json
{ "error": "Scene 'Good Night' not found in home 'My Home'" }

Background endpoints

Manage dashboard background images.

GET /rest/background/presets

List available preset background images.

bash
curl https://api.homecast.cloud/rest/background/presets \
  -H "Authorization: Bearer hc_your_token"

Response:

json
[
  { "id": "preset-1", "name": "Mountain", "url": "https://...", "category": "nature" }
]

POST /rest/background

Upload a custom background image.

bash
curl -X POST https://api.homecast.cloud/rest/background \
  -H "Authorization: Bearer hc_your_token" \
  -F "file=@background.jpg"

Content-Type: multipart/form-data

Response:

json
{ "success": true, "url": "https://..." }

DELETE /rest/background

Delete a background image. Pass filename as a query parameter to delete one, or omit to delete all.

bash
curl -X DELETE "https://api.homecast.cloud/rest/background?filename=background.jpg" \
  -H "Authorization: Bearer hc_your_token"

Response:

json
{ "success": true, "deleted": "background.jpg" }

GET /rest/background/

Serve a background image by its path. Used internally by the dashboard.

Error responses

All REST errors return JSON with an error field:

json
{ "error": "Scene 'Good Night' not found in home 'My Home'" }

See API Errors for a full list of status codes and common errors.