API Reference

Complete reference documentation for the SapienStream API. Build powerful industrial applications with our comprehensive REST API.

Getting Started

Base URL
https://sapienstream.com/api
Authentication Required

All API endpoints require authentication via JWT Bearer token.

Authorization: Bearer YOUR_JWT_TOKEN

Core APIs

Machines API
Industrial equipment registry and management
GET

/v1/machines - List all machines

POST

/v1/machines - Create new machine

PUT

/v1/machines/{id} - Update machine

Supported Protocols:

OPC-UAModbusS7EtherNet/IP
Tags API
Real-time machine data and tag operations
GET

/v1/tags - List machine tags

POST

/v1/tags - Create new tag

PUT

/v1/tags/{machine_id}/{name}/write - Write value

Data Types:

BOOLINTREALSTRING
Semantic Tags
High-level abstractions and operational metrics
GET

/v1/semantic-tags - List semantic tags

POST

/v1/semantic-tags - Create semantic tag

PUT

/v1/semantic-tags/{id} - Update tag

Semantic Types:

AnalogDigitalStateCounter
Documents API
Compliance and regulatory documentation
GET

/v1/documents - List documents

POST

/v1/documents - Upload document

DELETE

/v1/documents/{id} - Delete document

Document Types:

ManualCertificateSDS
Components API
Industrial component marketplace and registry
GET

/v1/components/search - Search components

GET

/v1/components/{id} - Component details

GET

/v1/components/categories/stats - Category statistics

Categories:

SensorsActuatorsMotorsValves
Authentication
User management and security
POST

/v1/auth/login - User login

POST

/v1/auth/register - User registration

GET

/v1/auth/me - Current user info

Features:

JWTRBACMFAAPI Keys
Nelo AI API
Industrial AI assistant with 58+ features
POST

/v1/nelo/chat - Send message to Nelo

GET

/v1/nelo/sessions - Chat sessions

POST

/v1/nelo/tools - Execute AI tools

Features:

5 Modes21 ToolsQuery Router
API Keys
Key management and usage analytics
GET

/v1/api-keys - List API keys

POST

/v1/api-keys - Create new key

GET

/v1/api-keys/usage - Usage analytics

Features:

ScopesAnalyticsQuotas
Billing API
Usage tracking and subscription management
GET

/v1/billing/llm/overview - Token usage

GET

/v1/payments/subscription - Status

POST

/v1/payments/checkout-session - Pay

Features:

StripeLLM BillingAlerts
Storage API
Multi-tenant MinIO file storage
POST

/v1/storage/buckets/initialize - Init buckets

POST

/v1/storage/upload - Upload file

GET

/v1/storage/usage - Usage analytics

Features:

Multi-TenantQuotas
Semantic Graph
Knowledge graph and relationship discovery
GET

/v1/semantic-graph/knowledge-graph - Full graph

GET

/v1/semantic-graph/overview - Overview

GET

/v1/semantic-graph/relationships - Relations

Features:

RelationshipsTracing
PDF Processing
Async datasheet extraction with AI
POST

/v1/pdf/extract-component - Extract data

GET

/v1/pdf/processing-status/{id} - Status

POST

/v1/pdf/detect-catalog - Detect type

Features:

AsyncAI Extraction
Dashboard API
Aggregated metrics and activity feeds
GET

/v1/dashboard/overview - All stats

GET

/v1/dashboard/activity - Activity feed

GET

/v1/dashboard/machine-stats - Machine stats

Features:

AnalyticsTrends
Facilities API
Location hierarchy and asset organization
GET

/v1/facilities - List facilities

GET

/v1/units - List units

PUT

/v1/machines/{id}/location - Assign

Features:

HierarchyUnits
Global Files
Organization-wide shared resources
GET

/v1/global-files - List files

POST

/v1/global-files - Upload file

GET

/v1/global-files/{id}/download - Download

Features:

TemplatesVersioning
Real-Time Data
IoT data ingestion and streaming
POST

/v1/realtime-data/ingest - Ingest sensor data

GET

/v1/realtime-data/machines/{id}/data

GET

/v1/realtime-data/machines/{id}/latest

Features:

IoTTime Series

Complete Workflow Example

Industrial Data Collection Setup
End-to-end example showing how to register a machine, create tags, and collect data

1. Authenticate and Get Token

curl -X POST "https://sapienstream.com/api/v1/auth/login" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "username=your_username&password=your_password"

2. Register a New Machine

curl -X POST "https://sapienstream.com/api/v1/machines" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Production Line 1",
    "vendor": "Siemens",
    "model": "S7-1500",
    "location": "Factory Floor A",
    "adapter": "s7",
    "adapter_config": {
      "host": "192.168.1.100",
      "port": 102,
      "rack": 0,
      "slot": 1
    },
    "raw_tags": [],
    "description": "Main production line controller"
  }'

3. Create Tags for Data Points

curl -X POST "https://sapienstream.com/api/v1/tags" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "machine_id": "MACHINE_ID_FROM_STEP_2",
    "name": "Temperature_Sensor_01",
    "datatype": "REAL",
    "description": "Main production temperature",
    "unit": "°C",
    "min_value": 0,
    "max_value": 100,
    "is_writable": false
  }'

4. Create Semantic Tag Abstraction

curl -X POST "https://sapienstream.com/api/v1/semantic-tags" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "machine_id": "MACHINE_ID_FROM_STEP_2",
    "canonical_name": "Production_Temperature",
    "source_tags": ["Temperature_Sensor_01"],
    "semantic_type": "Analog",
    "unit": "°C",
    "criticality": "high",
    "limits": {
      "min": 0,
      "max": 100,
      "warning_high": 85,
      "alarm_high": 95
    },
    "description": "Critical production temperature monitoring"
  }'

5. Read Tag Values

curl -X GET "https://sapienstream.com/api/v1/tags?machine_id=MACHINE_ID" \
  -H "Authorization: Bearer YOUR_TOKEN"

API Guidelines

Rate Limits
  • Standard: 1000 requests/hour
  • Burst: 100 requests/minute
  • Tag Writes: 500 writes/hour
  • File Uploads: 50 uploads/hour
  • • Rate limit headers included in responses
Best Practices
  • • Use appropriate HTTP methods and status codes
  • • Implement exponential backoff for retries
  • • Cache authentication tokens appropriately
  • • Use pagination for large result sets
  • • Monitor API usage and response times