Tags API
Real-time machine data and tag operations. Manage raw signals and variables from industrial automation equipment with type safety and quality indicators.
Overview
Data Types
- • BOOL: Boolean values (True/False)
- • INT: Integer numbers
- • REAL: Floating point numbers
- • STRING: Text strings
Features
- • Real-time value monitoring
- • Data quality indicators
- • Write operation tracking
- • Value validation and limits
- • Audit trail logging
Tag Data Model
{
"machine_id": "machine_001",
"name": "Temperature_Sensor_01",
"datatype": "REAL",
"value": 85.7,
"timestamp": "2024-08-26T10:30:15Z",
"description": "Main reactor temperature sensor",
"unit": "°C",
"min_value": 0,
"max_value": 150,
"quality": "GOOD",
"is_writable": false,
"is_active": true,
"last_write_by": null,
"last_write_at": null,
"write_count": 0,
"created_at": "2024-01-15T09:00:00Z",
"updated_at": "2024-08-26T10:30:15Z"
}Data Quality
Tag value is reliable and within expected parameters. Normal operation.
Tag value may be unreliable due to communication issues or sensor drift.
Tag value is invalid due to communication failure or sensor malfunction.
API Endpoints
/tagsAuth RequiredParameters
machine_idstringFilter tags by machine ID
datatypestringFilter by data type (BOOL, INT, REAL, STRING)
active_onlybooleanShow only active tags (default: true)
writable_onlybooleanShow only writable tags (default: false)
include_valuesbooleanInclude current tag values (default: true)
qualitystringFilter by quality (GOOD, UNCERTAIN, BAD)
searchstringSearch in tag name and description
limitintegerMaximum results (max: 1000, default: 100)
offsetintegerResults to skip (default: 0)
Response
[
{
"machine_id": "machine_001",
"name": "Temperature_Sensor_01",
"datatype": "REAL",
"value": 85.7,
"timestamp": "2024-08-26T10:30:15Z",
"description": "Main reactor temperature",
"unit": "°C",
"quality": "GOOD",
"is_writable": false,
"is_active": true
},
{
"machine_id": "machine_001",
"name": "Motor_Running",
"datatype": "BOOL",
"value": true,
"timestamp": "2024-08-26T10:30:10Z",
"description": "Motor running status",
"quality": "GOOD",
"is_writable": true,
"is_active": true
}
]Try it out
curl -X GET "https://sapienstream.com/api/tags" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json"/tagsAuth RequiredRequest Body
{
"machine_id": "machine_001",
"name": "Pressure_Sensor_02",
"datatype": "REAL",
"description": "Secondary pressure measurement",
"unit": "bar",
"min_value": 0,
"max_value": 10,
"is_writable": false
}Response
{
"machine_id": "machine_001",
"name": "Pressure_Sensor_02",
"datatype": "REAL",
"value": null,
"timestamp": null,
"description": "Secondary pressure measurement",
"unit": "bar",
"min_value": 0,
"max_value": 10,
"quality": null,
"is_writable": false,
"is_active": true,
"last_write_by": null,
"last_write_at": null,
"write_count": 0,
"created_at": "2024-08-26T11:00:00Z",
"updated_at": "2024-08-26T11:00:00Z"
}Try it out
curl -X POST "https://sapienstream.com/api/tags" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json"/tags/{machine_id}/{name}Auth RequiredParameters
machine_idstringRequiredMachine unique identifier
namestringRequiredTag name
Response
{
"machine_id": "machine_001",
"name": "Temperature_Sensor_01",
"datatype": "REAL",
"value": 85.7,
"timestamp": "2024-08-26T10:30:15Z",
"description": "Main reactor temperature sensor",
"unit": "°C",
"min_value": 0,
"max_value": 150,
"quality": "GOOD",
"is_writable": false,
"is_active": true,
"last_write_by": null,
"last_write_at": null,
"write_count": 0,
"created_at": "2024-01-15T09:00:00Z",
"updated_at": "2024-08-26T10:30:15Z"
}Try it out
curl -X GET "https://sapienstream.com/api/tags/{machine_id}/{name}" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json"/tags/{machine_id}/{name}/writeAuth RequiredParameters
machine_idstringRequiredMachine unique identifier
namestringRequiredTag name
Request Body
{
"value": 92.3,
"quality": "GOOD",
"timestamp": "2024-08-26T11:15:00Z"
}Response
{
"success": true,
"message": "Tag value written successfully",
"tag": {
"machine_id": "machine_001",
"name": "Setpoint_Temperature",
"datatype": "REAL",
"value": 92.3,
"timestamp": "2024-08-26T11:15:00Z",
"quality": "GOOD",
"last_write_by": "user_123",
"last_write_at": "2024-08-26T11:15:00Z",
"write_count": 15
}
}Try it out
curl -X PUT "https://sapienstream.com/api/tags/{machine_id}/{name}/write" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json"/tags/{machine_id}/{name}Auth RequiredParameters
machine_idstringRequiredMachine unique identifier
namestringRequiredTag name
Request Body
{
"description": "Updated temperature sensor description",
"unit": "°F",
"min_value": 32,
"max_value": 302,
"is_writable": true,
"is_active": true
}Response
{
"machine_id": "machine_001",
"name": "Temperature_Sensor_01",
"datatype": "REAL",
"value": 185.26,
"timestamp": "2024-08-26T10:30:15Z",
"description": "Updated temperature sensor description",
"unit": "°F",
"min_value": 32,
"max_value": 302,
"quality": "GOOD",
"is_writable": true,
"is_active": true,
"last_write_by": null,
"last_write_at": null,
"write_count": 0,
"created_at": "2024-01-15T09:00:00Z",
"updated_at": "2024-08-26T11:20:00Z"
}Try it out
curl -X PUT "https://sapienstream.com/api/tags/{machine_id}/{name}" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json"/tags/{machine_id}/{name}Auth RequiredParameters
machine_idstringRequiredMachine unique identifier
namestringRequiredTag name
Response
{
"message": "Tag deleted successfully",
"deleted_tag": {
"machine_id": "machine_001",
"name": "Obsolete_Sensor"
},
"deleted_at": "2024-08-26T11:30:00Z"
}Try it out
curl -X DELETE "https://sapienstream.com/api/tags/{machine_id}/{name}" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json"/tags/statsAuth RequiredResponse
{
"total_tags": 450,
"active_tags": 425,
"inactive_tags": 25,
"by_datatype": {
"REAL": 200,
"BOOL": 150,
"INT": 75,
"STRING": 25
},
"by_quality": {
"GOOD": 380,
"UNCERTAIN": 30,
"BAD": 15,
"NULL": 25
},
"writable_tags": 120,
"recent_writes": 45
}Try it out
curl -X GET "https://sapienstream.com/api/tags/stats" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json"Batch Operations
/tags/batch/writeAuth RequiredRequest Body
{
"writes": [
{
"machine_id": "machine_001",
"name": "Setpoint_1",
"value": 85.0,
"quality": "GOOD"
},
{
"machine_id": "machine_001",
"name": "Setpoint_2",
"value": 75.5,
"quality": "GOOD"
},
{
"machine_id": "machine_002",
"name": "Enable_Motor",
"value": true,
"quality": "GOOD"
}
]
}Response
{
"success": true,
"total_writes": 3,
"successful_writes": 3,
"failed_writes": 0,
"results": [
{
"machine_id": "machine_001",
"name": "Setpoint_1",
"success": true,
"timestamp": "2024-08-26T11:45:00Z"
},
{
"machine_id": "machine_001",
"name": "Setpoint_2",
"success": true,
"timestamp": "2024-08-26T11:45:00Z"
},
{
"machine_id": "machine_002",
"name": "Enable_Motor",
"success": true,
"timestamp": "2024-08-26T11:45:00Z"
}
]
}Try it out
curl -X POST "https://sapienstream.com/api/tags/batch/write" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json"Error Responses
400 Bad Request
{
"detail": "Invalid datatype: 'INVALID' not in ['BOOL', 'INT', 'REAL', 'STRING']"
}404 Not Found
{
"detail": "Tag 'NonExistent_Tag' not found on machine 'machine_001'"
}403 Forbidden
{
"detail": "Tag 'Temperature_Sensor_01' is not writable"
}422 Validation Error
{
"detail": "Value 250.0 exceeds maximum limit of 150.0 for tag 'Temperature_Sensor_01'"
}