Using REST API with Postman examples

Hi, i try to use the REST API with Postman, but with no luck !
First, the free plan accept REST API requests ?

The info is not clear about the PORT
The protocol hhtp or https ?
So, some examples will be appreciated

Exist an API endpoint to publish a topic to my cluster ?
Exist an API endpoint to know if a client is connected ?

Thanks

Hi @GAL,

free plan doesn’t support the REST API. Currently only the dedicated plan supports REST API.

As for what endpoints exist, you can look at the docu or at the specification page: HiveMQ 4.13.0 REST API documentation

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.

Greetings,
Michael from the HiveMQ team

1 Like

Thanks Michael
I read the API doc and can’t find an endpoint to publish a topic, that is what i need .
without that feature the API is useless to me

How can You automate pub without that ?

Regards

Hi @GAL ,

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.

Kind regards,
Dasha from HiveMQ Team

Hi @GAL,

you are correct that this endpoint does not exist. I see two solutions to this:

  1. 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).

  2. 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.

Greetings,
Michael

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.

Best regards,
Dasha from the HiveMQ Team

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:

const client = connect(brokerUrl, {
port,
username,
password,
protocol: ‘mqtts’,
});

Now the messages are flowing!