StreamGrid provides a REST API for external control and automation. The API allows you to programmatically manage streams and grids.
Base URL: http://localhost:3737 (default port, configurable in settings)
All API endpoints (except /health) require authentication using an API key.
Include your API key in one of these headers:
X-API-Key: your-api-key-here
or
Authorization: Bearer your-api-key-here
- Open StreamGrid Settings
- Navigate to API section
- Click "Generate API Key"
- Enable the API server
- Copy your API key (keep it secure!)
- Limit: 100 requests per 15 minutes per IP address
- Headers: Rate limit info included in response headers
Check if the API server is running.
Endpoint: GET /health or GET /api/health
Authentication: Not required
Response:
{
"status": "ok",
"apiEnabled": true,
"timestamp": "2025-01-24T16:00:00.000Z"
}Get all streams in the current grid.
Endpoint: GET /api/streams
Response:
{
"streams": [
{
"id": "stream-1234567890",
"name": "Stream 1",
"streamUrl": "https://example.com/stream.m3u8",
"logoUrl": "https://example.com/logo.png",
"isMuted": false,
"fitMode": "contain"
}
]
}Add a new stream to the current grid.
Endpoint: POST /api/streams
Request Body:
{
"name": "My Stream",
"streamUrl": "https://example.com/stream.m3u8",
"logoUrl": "https://example.com/logo.png",
"isMuted": false,
"fitMode": "contain"
}Required Fields:
name(string): Stream namestreamUrl(string): Stream URL (HLS, DASH, YouTube, Twitch, RTSP, etc.)
Optional Fields:
logoUrl(string): Logo/thumbnail URLisMuted(boolean): Start muted (default: false)fitMode(string): "contain" or "cover" (default: "contain")
Response:
{
"success": true,
"stream": {
"id": "stream-1234567890",
"name": "My Stream",
"streamUrl": "https://example.com/stream.m3u8",
"logoUrl": "https://example.com/logo.png",
"isMuted": false,
"fitMode": "contain"
}
}Update an existing stream's properties.
Endpoint: PUT /api/streams/:id
URL Parameters:
id(string): Stream ID
Request Body:
{
"name": "Updated Name",
"isMuted": true,
"fitMode": "cover"
}Response:
{
"success": true,
"id": "stream-1234567890",
"updates": {
"name": "Updated Name",
"isMuted": true,
"fitMode": "cover"
}
}Remove a stream from the current grid.
Endpoint: DELETE /api/streams/:id
URL Parameters:
id(string): Stream ID
Response:
{
"success": true,
"id": "stream-1234567890"
}Get all saved grids.
Endpoint: GET /api/grids
Response:
{
"grids": [
{
"id": "grid-1234567890",
"name": "My Grid",
"createdAt": "2025-01-24T16:00:00.000Z",
"lastModified": "2025-01-24T16:30:00.000Z",
"streamCount": 4,
"fileName": "grid-1234567890.json"
}
]
}Create a new saved grid.
Endpoint: POST /api/grids
Request Body:
{
"name": "My New Grid",
"streams": [],
"layout": [],
"chats": []
}Required Fields:
name(string): Grid name
Optional Fields:
streams(array): Array of stream objectslayout(array): Grid layout configurationchats(array): Chat windows configuration
Response:
{
"success": true,
"grid": {
"id": "grid-1234567890",
"name": "My New Grid",
"createdAt": "2025-01-24T16:00:00.000Z",
"lastModified": "2025-01-24T16:00:00.000Z",
"streams": [],
"layout": [],
"chats": []
}
}Switch to a different saved grid.
Endpoint: PUT /api/grids/:id/load
URL Parameters:
id(string): Grid ID
Response:
{
"success": true,
"id": "grid-1234567890"
}{
"error": "Missing required fields: name, streamUrl"
}{
"error": "Missing API key",
"message": "Provide API key in X-API-Key header or Authorization: Bearer <key>"
}{
"error": "Invalid API key",
"message": "The provided API key is invalid"
}{
"error": "Stream not found"
}{
"error": "Too many requests",
"message": "Rate limit exceeded. Try again later."
}{
"error": "Failed to add stream"
}{
"error": "API is disabled",
"message": "The REST API is currently disabled. Enable it in settings."
}Add a stream:
curl -X POST http://localhost:3737/api/streams \
-H "X-API-Key: your-api-key-here" \
-H "Content-Type: application/json" \
-d '{
"name": "My Stream",
"streamUrl": "https://example.com/stream.m3u8",
"logoUrl": "https://example.com/logo.png"
}'List all streams:
curl -X GET http://localhost:3737/api/streams \
-H "X-API-Key: your-api-key-here"Delete a stream:
curl -X DELETE http://localhost:3737/api/streams/stream-1234567890 \
-H "X-API-Key: your-api-key-here"Load a grid:
curl -X PUT http://localhost:3737/api/grids/grid-1234567890/load \
-H "X-API-Key: your-api-key-here"import requests
API_URL = "http://localhost:3737/api"
API_KEY = "your-api-key-here"
headers = {
"X-API-Key": API_KEY,
"Content-Type": "application/json"
}
# Add a stream
response = requests.post(
f"{API_URL}/streams",
headers=headers,
json={
"name": "My Stream",
"streamUrl": "https://example.com/stream.m3u8"
}
)
print(response.json())
# List all streams
response = requests.get(f"{API_URL}/streams", headers=headers)
streams = response.json()["streams"]
print(f"Total streams: {len(streams)}")const API_URL = 'http://localhost:3737/api';
const API_KEY = 'your-api-key-here';
const headers = {
'X-API-Key': API_KEY,
'Content-Type': 'application/json'
};
// Add a stream
async function addStream() {
const response = await fetch(`${API_URL}/streams`, {
method: 'POST',
headers: headers,
body: JSON.stringify({
name: 'My Stream',
streamUrl: 'https://example.com/stream.m3u8'
})
});
const data = await response.json();
console.log(data);
}
// List all streams
async function listStreams() {
const response = await fetch(`${API_URL}/streams`, { headers });
const data = await response.json();
console.log(`Total streams: ${data.streams.length}`);
}- Keep your API key secret - Never commit it to version control
- Use HTTPS in production - Consider using a reverse proxy with SSL
- Restrict network access - Use firewall rules to limit API access
- Rotate API keys regularly - Generate new keys periodically
- Monitor API usage - Check logs for suspicious activity
- Disable when not needed - Turn off the API server when not in use
Problem: Port already in use
Solution: Change the API port in settings or stop the conflicting service
Problem: 403 Forbidden response
Solution:
- Verify API key is correct
- Check that API is enabled in settings
- Ensure API key header is properly formatted
Problem: 429 Too Many Requests
Solution: Wait 15 minutes or reduce request frequency
For issues or questions:
- GitHub Issues: https://github.com/LordKnish/StreamGrid/issues
- Documentation: https://github.com/LordKnish/StreamGrid