Solutions
Topic Registry
REST API Endpoints
6min
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 name you can set a timeout in milliseconds with the timeout parameter (maximum 60,000 ms) post /api/subscribe?topic=topic name\&timeout=60000 if 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/subscribe this endpoint returns all active subscriptions and their topics