forked from fmtr/amniotic
-
-
Notifications
You must be signed in to change notification settings - Fork 2
API Reference
Synssins edited this page Dec 15, 2025
·
1 revision
Sonorium provides a REST API for automation and integration. All endpoints are accessible at http://YOUR_HA_IP:8008/api/.
GET /stream/{theme_id}
Returns an audio/mpeg stream for direct playback.
GET /stream/channel{n}
Returns the audio stream for channel N (1-6).
Example: GET /stream/channel1
GET /api/status
Response:
{
"version": "1.2.0",
"current_theme": "Tavern",
"themes": [...],
"v2_enabled": true,
"sessions": 2,
"speaker_groups": 1,
"channels": 6,
"active_channels": 1,
"cycling_sessions": 0
}GET /api/sessions
Response:
[
{
"id": "abc123",
"name": "Living Room",
"theme_id": "uuid-here",
"preset_id": "calm_evening",
"volume": 75,
"is_playing": true,
"speakers": ["media_player.living_room"],
"channel_id": 1
}
]POST /api/sessions
Content-Type: application/json
{
"name": "My Session",
"theme_id": "theme-uuid",
"speakers": ["media_player.living_room", "media_player.kitchen"]
}
GET /api/sessions/{session_id}
PUT /api/sessions/{session_id}
Content-Type: application/json
{
"name": "New Name",
"theme_id": "new-theme-uuid",
"preset_id": "intense_storm",
"speakers": ["media_player.bedroom"]
}
DELETE /api/sessions/{session_id}
POST /api/sessions/{session_id}/play
POST /api/sessions/{session_id}/stop
POST /api/sessions/{session_id}/volume
Content-Type: application/json
{
"volume": 50
}
Volume range: 0-100
GET /api/channels
Response:
[
{
"id": 1,
"name": "Channel 1",
"state": "playing",
"current_theme": "tavern",
"current_theme_name": "Tavern",
"client_count": 2,
"stream_path": "/stream/channel1"
}
]GET /api/themes
Response:
[
{
"id": "uuid-here",
"name": "Tavern",
"folder": "Tavern",
"total_tracks": 8,
"enabled_tracks": 8,
"url": "http://192.168.1.100:8008/stream/tavern",
"is_favorite": true,
"categories": ["Fantasy"],
"icon": "🍺",
"description": "A night at a medieval inn."
}
]GET /api/themes/{theme_id}
POST /api/themes/refresh
Rescans the audio folder for new/changed themes.
POST /api/themes/{theme_id}/favorite
GET /api/themes/{theme_id}/export
Returns a zip file containing all theme files.
POST /api/themes/import
Content-Type: multipart/form-data
file: <theme.zip>
GET /api/themes/{theme_id}/tracks
Response:
{
"theme_id": "uuid-here",
"theme_name": "Tavern",
"short_file_threshold": 15.0,
"tracks": [
{
"name": "fireplace_663",
"presence": 1.0,
"muted": false,
"is_enabled": true,
"duration_seconds": 16.2,
"is_short_file": false,
"volume": 1.0,
"playback_mode": "auto",
"seamless_loop": false,
"exclusive": false
}
]
}PUT /api/themes/{theme_id}/tracks/{track_name}/presence
Content-Type: application/json
{
"presence": 0.5
}
PUT /api/themes/{theme_id}/tracks/{track_name}/volume
Content-Type: application/json
{
"volume": 0.8
}
PUT /api/themes/{theme_id}/tracks/{track_name}/muted
Content-Type: application/json
{
"muted": true
}
PUT /api/themes/{theme_id}/tracks/{track_name}/playback_mode
Content-Type: application/json
{
"playback_mode": "sparse"
}
Options: auto, continuous, sparse, presence
PUT /api/themes/{theme_id}/tracks/{track_name}/seamless_loop
Content-Type: application/json
{
"seamless_loop": true
}
PUT /api/themes/{theme_id}/tracks/{track_name}/exclusive
Content-Type: application/json
{
"exclusive": true
}
POST /api/themes/{theme_id}/tracks/reset
Resets all tracks to default settings.
GET /api/themes/{theme_id}/tracks/{track_name}/audio
Returns the audio file for browser preview.
GET /api/themes/{theme_id}/presets
POST /api/themes/{theme_id}/presets
Content-Type: application/json
{
"name": "My Preset"
}
POST /api/themes/{theme_id}/presets/{preset_id}/load
PUT /api/themes/{theme_id}/presets/{preset_id}
Saves current track settings to the preset.
DELETE /api/themes/{theme_id}/presets/{preset_id}
POST /api/themes/{theme_id}/presets/{preset_id}/default
GET /api/themes/{theme_id}/presets/{preset_id}/export
Returns preset as JSON file.
POST /api/themes/{theme_id}/presets/import
Content-Type: multipart/form-data
file: <preset.json>
GET /api/speakers
GET /api/speakers/hierarchy
Returns speakers organized by floor and area.
POST /api/speakers/refresh
GET /api/speaker-groups
POST /api/speaker-groups
Content-Type: application/json
{
"name": "Downstairs",
"speakers": ["media_player.living_room", "media_player.kitchen"]
}
PUT /api/speaker-groups/{group_id}
Content-Type: application/json
{
"name": "New Name",
"speakers": [...]
}
DELETE /api/speaker-groups/{group_id}
service: rest_command.sonorium_play
data:
session_id: "your-session-id"First, create the REST command in configuration.yaml:
rest_command:
sonorium_play:
url: "http://192.168.1.100:8008/api/sessions/{{ session_id }}/play"
method: POSTrest_command:
sonorium_set_theme:
url: "http://192.168.1.100:8008/api/sessions/{{ session_id }}"
method: PUT
content_type: "application/json"
payload: '{"theme_id": "{{ theme_id }}"}'rest_command:
sonorium_volume:
url: "http://192.168.1.100:8008/api/sessions/{{ session_id }}/volume"
method: POST
content_type: "application/json"
payload: '{"volume": {{ volume }}}'