This document describes the REST API and WebSocket interfaces for IoTStudio.
Base URL: http://localhost:8080/api
GET /api/sessions
Response:
[
{
"id": "session-123",
"name": "Factory Floor Monitoring",
"createdAt": "2024-01-01T00:00:00Z",
"updatedAt": "2024-01-01T00:00:00Z",
"status": "running"
}
]GET /api/sessions/{id}
POST /api/sessions
Content-Type: application/json
{
"name": "New Session"
}
PUT /api/sessions/{id}
Content-Type: application/json
{
"name": "Updated Name",
"status": "running"
}
DELETE /api/sessions/{id}
GET /api/sessions/{id}/connections
Response:
[
{
"id": "conn-123",
"sessionId": "session-123",
"type": "modbus_tcp",
"name": "PLC Connection",
"config": "{\"host\":\"192.168.1.100\",\"port\":502}",
"status": "connected",
"createdAt": "2024-01-01T00:00:00Z",
"updatedAt": "2024-01-01T00:00:00Z"
}
]POST /api/sessions/{id}/connections
Content-Type: application/json
{
"type": "modbus_tcp",
"name": "PLC Connection",
"config": {
"host": "192.168.1.100",
"port": 502,
"timeout": 5,
"keepAlive": true
}
}
DELETE /api/connections/{id}
GET /api/sessions/{id}/devices
Response:
[
{
"id": "device-123",
"sessionId": "session-123",
"connectionId": "conn-123",
"address": 1,
"name": "Temperature Sensor",
"description": "Main temperature sensor",
"parserId": "parser-123",
"createdAt": "2024-01-01T00:00:00Z",
"updatedAt": "2024-01-01T00:00:00Z"
}
]POST /api/sessions/{id}/devices
Content-Type: application/json
{
"connectionId": "conn-123",
"address": 1,
"name": "Temperature Sensor",
"parserId": "parser-123"
}
DELETE /api/devices/{id}
GET /api/parsers
Response:
[
{
"id": "parser-123",
"name": "Temperature Parser",
"type": "visual",
"visualRules": "[{\"name\":\"temp\",\"dataType\":\"float\",\"startOffset\":0,\"bitOffset\":0,\"bitWidth\":16,\"endianness\":\"big\",\"scale\":0.1,\"offset\":0}]",
"javascript": "",
"createdAt": "2024-01-01T00:00:00Z",
"updatedAt": "2024-01-01T00:00:00Z"
}
]GET /api/parsers/{id}
POST /api/parsers
Content-Type: application/json
{
"name": "Temperature Parser",
"type": "visual",
"visualRules": [
{
"name": "temperature",
"dataType": "float",
"startOffset": 0,
"bitOffset": 0,
"bitWidth": 16,
"endianness": "big",
"scale": 0.1,
"offset": 0
}
]
}
PUT /api/parsers/{id}
Content-Type: application/json
{
"name": "Updated Parser",
"visualRules": [...]
}
DELETE /api/parsers/{id}
ws://localhost:8080/ws
{
"type": "subscribe",
"sessionId": "session-123"
}{
"type": "unsubscribe",
"sessionId": "session-123"
}{
"type": "data",
"sessionId": "session-123",
"deviceId": "device-456",
"timestamp": 1704067200000,
"data": {
"temperature": 23.5,
"humidity": 65.2
}
}{
"type": "error",
"timestamp": 1704067200000,
"error": "Connection lost to device"
}{
"type": "status",
"sessionId": "session-123",
"timestamp": 1704067200000,
"status": "running"
}| Code | Description |
|---|---|
| 400 | Bad Request - Invalid input |
| 404 | Not Found - Resource doesn't exist |
| 500 | Internal Server Error |
| 503 | Service Unavailable - Try again later |
- API requests: 100 requests/minute per IP
- WebSocket connections: 10 concurrent connections per IP