Semantic Tags API
High-level semantic abstractions over raw machine tags. Transform raw industrial data into meaningful, domain-aware representations with standardized units and safety classification.
Overview
Semantic Types
- • Analog: Continuous measurements (temperature, pressure)
- • Digital: Binary states (on/off, open/closed)
- • State: Enumerated states (running/stopped/fault)
- • Counter: Accumulating values (production count)
Features
- • Normalized data representation
- • Safety criticality classification
- • Operational limits and validation
- • OPC-UA type mappings
- • Auto-scaling configuration
- • Source tag aggregation
Semantic Tag Data Model
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"machine_id": "machine_001",
"canonical_name": "Reactor_Temperature",
"source_tags": ["HT001_PV", "HT001_CV"],
"semantic_type": "Analog",
"unit": "°C",
"criticality": "high",
"limits": {
"min": 0,
"max": 500,
"warning_high": 450,
"alarm_high": 480
},
"validation_rules": {
"rate_of_change_max": 10,
"deadband": 0.1
},
"safety_function": "High Temperature Trip",
"ua_type": "Double",
"ua_namespace": "http://example.com/reactor",
"description": "Primary reactor temperature measurement",
"notes": "Calibrated 2024-01-15, next cal due 2024-07-15",
"is_active": true,
"auto_scaling": {
"enabled": true,
"factor": 1.0,
"offset": 0.0
},
"created_at": "2024-01-01T00:00:00Z",
"updated_at": "2024-01-15T10:30:00Z",
"created_by": "engineer1",
"updated_by": "engineer1"
}
Criticality Levels
Informational only. No operational impact.
Operational concern requiring attention.
Safety critical requiring immediate response.
Emergency shutdown level requiring immediate action.
API Endpoints
/semantic-tags/{machine_id}
Auth RequiredParameters
machine_id
stringRequiredUnique identifier of the machine
active_only
booleanShow only active semantic tags (default: true)
semantic_type
stringFilter by type (Analog, Digital, State, Counter)
criticality
stringFilter by criticality (low, medium, high, critical)
safety_only
booleanShow only safety-related tags (default: false)
search
stringSearch in canonical names and descriptions
limit
integerMaximum results (max: 100, default: 50)
offset
integerNumber of results to skip (default: 0)
Response
[
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"machine_id": "machine_001",
"canonical_name": "Reactor_Temperature",
"semantic_type": "Analog",
"unit": "°C",
"criticality": "high",
"is_active": true,
"source_tag_count": 2,
"safety_function": "High Temperature Trip"
},
{
"id": "550e8400-e29b-41d4-a716-446655440001",
"machine_id": "machine_001",
"canonical_name": "Emergency_Stop_State",
"semantic_type": "Digital",
"unit": "boolean",
"criticality": "critical",
"is_active": true,
"source_tag_count": 1,
"safety_function": "Emergency Shutdown System"
}
]
Try it out
curl -X GET "https://sapienstream.com/api/semantic-tags/{machine_id}" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json"
/semantic-tags/{machine_id}/{semantic_id}
Auth RequiredParameters
machine_id
stringRequiredUnique identifier of the machine
semantic_id
stringRequiredUUID of the semantic tag to retrieve
Response
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"machine_id": "machine_001",
"canonical_name": "Reactor_Temperature",
"source_tags": ["HT001_PV", "HT001_CV"],
"semantic_type": "Analog",
"unit": "°C",
"criticality": "high",
"limits": {
"min": 0,
"max": 500,
"warning_high": 450,
"alarm_high": 480
},
"validation_rules": {
"rate_of_change_max": 10,
"deadband": 0.1
},
"safety_function": "High Temperature Trip",
"ua_type": "Double",
"ua_namespace": "http://example.com/reactor",
"description": "Primary reactor temperature measurement",
"notes": "Calibrated 2024-01-15, next cal due 2024-07-15",
"is_active": true,
"auto_scaling": {
"enabled": true,
"factor": 1.0,
"offset": 0.0
},
"created_at": "2024-01-01T00:00:00Z",
"updated_at": "2024-01-15T10:30:00Z",
"created_by": "engineer1",
"updated_by": "engineer1"
}
Try it out
curl -X GET "https://sapienstream.com/api/semantic-tags/{machine_id}/{semantic_id}" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json"
/semantic-tags/{machine_id}
Auth RequiredParameters
machine_id
stringRequiredUnique identifier of the machine
created_by
stringRequiredUsername of the creator (query parameter)
Request Body
{
"canonical_name": "Reactor_Temperature",
"source_tags": ["HT001_PV", "HT001_CV"],
"semantic_type": "Analog",
"unit": "°C",
"criticality": "high",
"limits": {
"min": 0,
"max": 500,
"warning_high": 450,
"alarm_high": 480
},
"validation_rules": {
"rate_of_change_max": 10,
"deadband": 0.1
},
"safety_function": "High Temperature Trip",
"ua_type": "Double",
"ua_namespace": "http://example.com/reactor",
"description": "Primary reactor temperature measurement",
"notes": "Temperature sensor with redundancy",
"auto_scaling": {
"enabled": true,
"factor": 1.0,
"offset": 0.0
}
}
Response
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"machine_id": "machine_001",
"canonical_name": "Reactor_Temperature",
"source_tags": ["HT001_PV", "HT001_CV"],
"semantic_type": "Analog",
"unit": "°C",
"criticality": "high",
"limits": {
"min": 0,
"max": 500,
"warning_high": 450,
"alarm_high": 480
},
"validation_rules": {
"rate_of_change_max": 10,
"deadband": 0.1
},
"safety_function": "High Temperature Trip",
"ua_type": "Double",
"ua_namespace": "http://example.com/reactor",
"description": "Primary reactor temperature measurement",
"notes": "Temperature sensor with redundancy",
"auto_scaling": {
"enabled": true,
"factor": 1.0,
"offset": 0.0
},
"is_active": true,
"created_at": "2024-08-26T12:00:00Z",
"updated_at": "2024-08-26T12:00:00Z",
"created_by": "engineer1",
"updated_by": "engineer1"
}
Try it out
curl -X POST "https://sapienstream.com/api/semantic-tags/{machine_id}" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json"
/semantic-tags/{machine_id}/{semantic_id}
Auth RequiredParameters
machine_id
stringRequiredUnique identifier of the machine
semantic_id
stringRequiredUUID of the semantic tag to update
updated_by
stringRequiredUsername of the updater (query parameter)
Request Body
{
"description": "Updated reactor temperature with new calibration",
"limits": {
"min": 0,
"max": 520,
"warning_high": 470,
"alarm_high": 500
},
"validation_rules": {
"rate_of_change_max": 15,
"deadband": 0.2
},
"notes": "Recalibrated 2024-08-26, next due 2025-02-26",
"is_active": true
}
Response
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"machine_id": "machine_001",
"canonical_name": "Reactor_Temperature",
"source_tags": ["HT001_PV", "HT001_CV"],
"semantic_type": "Analog",
"unit": "°C",
"criticality": "high",
"limits": {
"min": 0,
"max": 520,
"warning_high": 470,
"alarm_high": 500
},
"validation_rules": {
"rate_of_change_max": 15,
"deadband": 0.2
},
"safety_function": "High Temperature Trip",
"ua_type": "Double",
"ua_namespace": "http://example.com/reactor",
"description": "Updated reactor temperature with new calibration",
"notes": "Recalibrated 2024-08-26, next due 2025-02-26",
"is_active": true,
"auto_scaling": {
"enabled": true,
"factor": 1.0,
"offset": 0.0
},
"created_at": "2024-01-01T00:00:00Z",
"updated_at": "2024-08-26T12:30:00Z",
"created_by": "engineer1",
"updated_by": "engineer1"
}
Try it out
curl -X PUT "https://sapienstream.com/api/semantic-tags/{machine_id}/{semantic_id}" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json"
/semantic-tags/{machine_id}/stats
Auth RequiredParameters
machine_id
stringRequiredUnique identifier of the machine
Response
{
"machine_id": "machine_001",
"total_semantic_tags": 45,
"active_semantic_tags": 42,
"inactive_semantic_tags": 3,
"by_semantic_type": {
"Analog": 25,
"Digital": 15,
"State": 3,
"Counter": 2
},
"by_criticality": {
"low": 20,
"medium": 15,
"high": 8,
"critical": 2
},
"safety_related": 10,
"with_limits": 28,
"with_validation_rules": 35,
"total_source_tags": 89,
"avg_source_tags_per_semantic": 1.98
}
Try it out
curl -X GET "https://sapienstream.com/api/semantic-tags/{machine_id}/stats" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json"
Common Use Cases
Temperature Normalization
Combine multiple temperature sensors into a single "Reactor_Temperature" semantic tag with standardized units and safety limits.
Source: ["HT001_PV", "HT002_PV"] → "Reactor_Temperature"
Motor State Abstraction
Abstract raw motor control signals into meaningful states like "Running", "Stopped", "Fault".
Source: ["M001_RUN", "M001_STOP", "M001_FAULT"] → "Motor_State"
Production Counter
Track production counts with validation rules and accumulation logic.
Source: ["PROD_COUNT"] → "Daily_Production"
Safety Interlock
Combine multiple safety signals into critical safety function monitoring.
Source: ["E_STOP_1", "E_STOP_2"] → "Emergency_Stop_State"
Error Responses
400 Bad Request
{
"detail": "Invalid semantic_type: 'INVALID' not in ['Analog', 'Digital', 'State', 'Counter']"
}
404 Not Found
{
"detail": "Machine 'machine_999' not found"
}
409 Conflict
{
"detail": "Semantic tag 'Reactor_Temperature' already exists on machine 'machine_001'"
}
422 Validation Error
{
"detail": "Source tag 'INVALID_TAG' not found on machine 'machine_001'"
}