Tip, you can download the yaml file containing the REST specification from this page: HiveMQ 4.13.0 REST API documentation and then import the yaml file into Postman.
HiveMQ REST API is automating administrator actions, it supports neither Publish nor Subscribe. You must use a normal MQTT Client to connect to the broker and publish a message on a topic.
you are correct that this endpoint does not exist. I see two solutions to this:
If you have already access to the enterprise SDK you can âsimplyâ create your own extension that adds your own REST endpoint (this need the enterprise SDK) that then uses the PublishService.publish() (this one is in the public SDK). Note that access to the enterprise SDK needs a certification (which costs money).
You donât want to spend money â Again you need to create your own extension that implements a REST server where you then basically create your own endpoint that again uses the PublishService.
I too was hoping to find a HiveMQ REST API Endpoint that would allow me to trigger publishing a message to a topic by making a POST (or GET) to a HiveMQ Endpoint. My use case is I have a Hasura graphql & database running in the cloud, and when a value in a table changes, I want to publish this change to mqtt clients. Hasura offers âactionsâ that will make an API call when the change occurs, but without the ability to call HiveMQ directly, I will need to create an AWS Lambda (or GCP FunctionâŚ) to receive the API Call, fire up an MQTT Client, connect to HiveMQ, publish the message, then terminate. This wonât be hard or expensive, but it another element in my infrastructure I donât necessarily want to maintain.
Hi @autefrum, itâs wonderful to have someone like you whoâs enthusiastic about MQTT and the HiveMQ broker. Welcome to the HiveMQ Community! Weâre excited to see new users like you.
Thank you for sharing your use case and the challenges youâre facing. I understand that youâre looking for a more streamlined way to publish messages to an MQTT topic directly from your Hasura GraphQL and database setup when a table value changes, without having to introduce an additional layer of infrastructure like AWS Lambda or a GCP Function.
Currently, HiveMQ does not offer a REST API endpoint for publishing messages directly. However, I see how such a feature could simplify your architecture by eliminating the need for an intermediary service.
In the meantime, using a serverless function as you described is a common approach to bridge this gap. It might add some complexity, but it offers flexibility and scalability. You can leverage client examples available in different programming languages, which are conveniently located in the âGetting Startedâ section of your HiveMQ Cloud console:
Your feedback is valuable, and I will certainly pass it on to the HiveMQ team. They may consider adding this feature in the future based on user demand.
Thanks Dasha! I could not get my typescript code using the mqtt npm module to connect and subscribe to my hivemq service - but once I read the âGetting Startedâ document you pointed me to, I see that I needed to pass protocol: 'mqtts' to the connect call thus: