REST API Endpoints
The Topic Registry provides REST API endpoints for programmatic access to topic data. This enables integration with other tools or services.
Important: REST API endpoints require a secret key for authentication, set via the X_LITMUS_KEY environment variable during deployment. Include this key in the request headers as X_LITMUS_KEY. The default value is change-me.
Available endpoints
GET /api/streaming/{topic}: Server-Sent Events (SSE) streaming endpoint for a live topic data stream
- Example usage with Curl/Postman

curl -N -H "X_LITMUS_KEY: your-secret-key" \
"http://localhost:3000/api/streaming/devicehub.alias.sensor1.temperature"- Example usage with Javascript/Typescript
const eventSource = new EventSource('/api/streaming/your.topic.name', {
headers: { X_LITMUS_KEY: 'your-secret-key' },
});
eventSource.onmessage = function (event) {
const data = JSON.parse(event.data);
console.log('Received:', data.value, 'at', new Date(data.timestamp));
};
eventSource.onerror = function (event) {
console.error('Connection error:', event);
};POST /api/subscribe: Subscribe to a specific topic to receive real-time updates. Provide the topic name as a query parameter:
POST /api/subscribe?topic=topic-nameYou can set a timeout in milliseconds with the timeout parameter (maximum 60,000 ms):
POST /api/subscribe?topic=topic-name&timeout=60000If the timeout is reached without any data being published, the subscription remains active. You can receive updates using the GET /api/value endpoint.

GET /api/value: Retrieve the last stored value of a topic:
GET /api/value?topic=topic-name
These REST API endpoints provide a convenient way to access topic data programmatically, enabling seamless integration with external systems and services.
Tip: To get a list of real-time subscriptions, use:
GET /api/subscribeThis endpoint returns all active subscriptions and their topics.
