Stream
Real-Time Data Stream API - Operations Guide
This article describes the real-time data stream feature, which provides near real-time access to device data. This can be used to replace the REST Search API approach which has inherent delays.
Overview
Two APIs are available for consuming the broker-backed data stream:
API
Use Case
Data Delivery
REST Stream API
Batch polling, periodic data retrieval
Returns batch of messages per request
WebSocket API
Continuous real-time streaming
Pushes individual messages as they arrive
Stream Retention: The stream holds approximately 1 hour of the latest messages.
1. REST API
Endpoint
GET https://[mycloud].ardexa.com/api/v1/tables/{workgroupId}/{tableName}/latest
GET https://[mycloud].ardexa.com/api/v1/tables/{workgroupId}/-/latest # Wildcard "-": all tablesAuthentication
Standard API Token with Bearer authentication
Required scope:
search:readAdditional scope for
audit_logstable or wildcard access:org:audit
Query Parameters
Parameter
Type
Required
Description
offset
BigInt string
No
Resume from a specific offset (returned by previous call).
Default: the start of the stream (which is about 1h ago)
timestamp
ISO string or Unix ms
No
Start from a specific timestamp (server-side append time)
limit
Integer
No
Max messages to return (default & max: 10,000)
Offset Priority: If both offset and timestamp are provided, offset takes precedence.
Response Format
Content-Type: application/cbor
Integration Notes
Offset Management: Customers must persist the
offsetvalue returned by each request. Use this offset in the next request to retrieve subsequent messages without gaps or duplicates.Idle Timeout: The endpoint has a 1-second idle timeout. If no new messages arrive within 1 second, the response is returned with available data.
Initial Request Options:
No params: Returns messages from the beginning of the stream (~1 hour ago)
With
timestamp: Returns messages from the specified time forwardWith
offset: Resumes from exact position (recommended for ongoing polling)
2. WebSocket API
Connection
Connect to the standard WebSocket endpoint with authentication.
Events
Subscribe to Stream
Emit: stream:latest
Receive Data
Listen: stream:latest:data
Telemetry data:
Device online/offline data:
Stop Stream
Emit: stream:latest:stop
Authentication
Same scopes as REST API:
search:read, plusorg:auditfor audit logsAuthentication is handled via the WebSocket connection handshake
Integration Notes
requestIdis mandatory: The server will reject requests without arequestId.Default Behavior: Without
offsetortimestamp, the WebSocket starts fromOffset.next()(newest messages only, no historical data).Stream Lifecycle: Always call
stream:latest:stopwhen done to free server resources.
3. Data Encoding
Both APIs return data encoded in CBOR (Concise Binary Object Representation).
Decoding Examples
JavaScript (Node.js):
Python:
4. Integration Considerations
Stream Health & Availability
Concern
Details
Retention Window
~1 hour of messages. Data older than this is not available via stream
Message Ordering
Messages are ordered by offset. Use offset for reliable sequencing
Duplicates
Possible on reconnection if offset not properly managed
Recommended Practices
Persist Offsets Reliably
Store the last processed offset in durable storage (database, file)
Update offset after successfully processing each batch/message
On restart, resume from the stored offset
Handle Gaps Gracefully
If stored offset is older than 1 hour, it may be invalid
Implement fallback: start from
timestampor beginning of streamLog and alert when gaps are detected
Error Handling
REST: Check for
errorfield in responseWebSocket: Listen for error messages and handle reconnection
Implement exponential backoff for retries
Rate Limiting
REST: Respect the 10,000 message limit per request
Poll at reasonable intervals (recommended: 1-5 seconds)
WebSocket: Implement backpressure if processing can't keep up
Device Group Filtering
If the API token has device group restrictions, only data from permitted devices is returned
This filtering is automatic based on token permissions
Migration from REST Search API
Aspect
REST Search API
WebSocket Stream API
Latency
Minutes delay
Near real-time
Data Window
Historical archive
~1 hour rolling
Query Flexibility
Full search/aggregation
Sequential stream only
Use Case
Analytics, reporting
Live monitoring, alerting
Recommendation: Use Stream API for real-time needs; retain REST Search API integration for historical analysis and complex queries.
5. Quick Reference
REST API Checklist
[ ] API token with
search:readscope[ ] CBOR decoder in client
[ ] Offset persistence mechanism
[ ] Error handling
[ ] Polling interval configured
WebSocket API Checklist
[ ] Socket authentication configured
[ ] UUID
requestIdgenerator[ ] CBOR decoder for binary messages
[ ]
stream:latest:stopcalled on disconnect[ ] Reconnection logic with offset resume
Last updated
Was this helpful?