API Endpoints
Complete reference for all BusyLight Web API endpoints.
API Organization
The API is organized into three main domains:
- Lights - Basic device control (on, off, blink)
- Effects - Advanced light effects (rainbow, pulse, flash)
- System - API health and information
Each domain provides both versioned (/api/v1/
) and compatibility endpoints.
System Endpoints
API Information
Returns comprehensive API information including available versions, domains, and endpoints.
Response:
{
"name": "BusyLight API",
"version": "0.43.1",
"api_versions": {
"v1": {
"prefix": "/api/v1",
"description": "Current stable API version",
"features": ["REST endpoints", "Effects management", "LED targeting"]
},
"legacy": {
"prefix": "/",
"description": "Legacy endpoints for backward compatibility",
"deprecated": true
}
},
"domains": [
{
"name": "lights",
"description": "Basic light control operations",
"endpoints": ["/lights", "/lights/{id}"]
}
]
}
System Health
Check API server and device availability.
Response:
System Information
Get server configuration details.
Response:
{
"title": "Busylight Server: A USB Light Server",
"version": "0.43.1",
"description": "An API server for USB connected presence lights."
}
Lights Domain
Get All Lights
Returns status information for all connected lights.
Response:
[
{
"light_id": 0,
"name": "Blink(1) mk2",
"info": {
"path": "/dev/hidraw0",
"vendor_id": 10168,
"product_id": 493
},
"is_on": true,
"color": "red",
"rgb": [255, 0, 0]
}
]
Get Single Light
Returns detailed status for specific light.
Parameters:
- light_id
(path, int): Light index (0-based)
Response:
{
"light_id": 0,
"name": "Blink(1) mk2",
"info": {
"path": "/dev/hidraw0",
"vendor_id": 10168,
"product_id": 493,
"serial_number": "ABC123"
},
"is_on": true,
"color": "red",
"rgb": [255, 0, 0]
}
Turn Light On (V1)
Turn on all lights or specific light using JSON request body.
Request Body:
Parameters:
- color
(string): Color name or hex value (default: "green")
- dim
(float): Brightness factor 0.0-1.0 (default: 1.0)
- led
(int): LED index for multi-LED devices (default: 0)
- light_id
(path, int): Light index for single light endpoints
Examples:
# Turn all lights red
curl -X POST http://localhost:8000/api/v1/lights/on \
-H "Content-Type: application/json" \
-d '{"color": "red", "dim": 0.8}'
# Turn specific light blue
curl -X POST http://localhost:8000/api/v1/lights/2/on \
-H "Content-Type: application/json" \
-d '{"color": "blue", "led": 1}'
Response:
{
"success": true,
"action": "turned on",
"lights_affected": 1,
"details": [
{
"light_id": 0,
"action": "turned on",
"color": "red",
"rgb": [255, 0, 0],
"dim": 1.0,
"led": 0
}
]
}
Turn Light Off (V1)
Turn off all lights or specific light.
Request Body:
Response:
{
"success": true,
"action": "turned off",
"lights_affected": 2,
"details": [
{
"light_id": 0,
"action": "turned off"
},
{
"light_id": 1,
"action": "turned off"
}
]
}
Blink Light (V1)
Create blinking effect on lights.
Request Body:
Parameters:
- color
(string): Blink color (default: "red")
- dim
(float): Brightness factor 0.0-1.0 (default: 1.0)
- speed
(string): "slow", "medium", "fast" (default: "slow")
- count
(int): Number of blinks, 0=infinite (default: 0)
- led
(int): LED index for multi-LED devices (default: 0)
Effects Domain
Rainbow Effect (V1)
Start rainbow color cycling effect.
Request Body:
Response:
{
"success": true,
"action": "rainbow effect started",
"lights_affected": 1,
"effect": {
"name": "rainbow",
"speed": "slow",
"dim": 1.0,
"led": 0
}
}
Pulse Effect (V1)
Create pulsing/breathing effect.
Request Body:
Flash Effect (V1)
Alternate between two colors.
Request Body:
Compatibility Endpoints (Deprecated)
These endpoints maintain backwards compatibility with the original API. They use GET requests with query parameters and return simplified responses.
Turn Light On (Compatibility)
Parameters:
- color
(query, str): Color name or hex value (default: "green")
- dim
(query, float): Brightness factor 0.0-1.0 (default: 1.0)
- led
(query, int): LED index for multi-LED devices (default: 0)
Examples:
# Basic usage
curl http://localhost:8000/light/0/on
# With parameters
curl "http://localhost:8000/light/0/on?color=red&dim=0.5"
Effects (Compatibility)
GET /light/{light_id}/blink
GET /light/{light_id}/rainbow
GET /light/{light_id}/pulse
GET /light/{light_id}/fli
Query parameters match the original API specification.
Color Specification
Colors can be specified as:
- Named colors:
red
,green
,blue
,yellow
,purple
,white
, etc. - Hex colors:
#ff0000
,0xff0000
,ff0000
- RGB tuples:
rgb(255,0,0)
LED Targeting
For multi-LED devices:
led=0
: Control all LEDs (default)led=1
: Control first/top LEDled=2
: Control second/bottom LEDled=3+
: Control additional LEDs (device-specific)
Error Responses
Validation Error (422)
{
"detail": [
{
"loc": ["body", "dim"],
"msg": "ensure this value is less than or equal to 1.0",
"type": "value_error.number.not_le"
}
]
}
Device Not Found (404)
Authentication Required (401)
No Devices Available (503)
OpenAPI Documentation
Interactive API documentation is available at:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
- OpenAPI JSON: http://localhost:8000/openapi.json
These provide complete endpoint documentation with request/response schemas and testing capabilities.