# Is it possible to subscribe to MQTT topic on-demand via python script

**URL:** <https://forum.inductiveautomation.com/t/is-it-possible-to-subscribe-to-mqtt-topic-on-demand-via-python-script/61135>\
**Category:** Ignition\
**Created:** [June 23, 2022, 9:09pm UTC](https://forum.inductiveautomation.com/t/is-it-possible-to-subscribe-to-mqtt-topic-on-demand-via-python-script/61135 "2022-06-23T21:09:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![framebuilder](https://avatars.discourse-cdn.com/v4/letter/f/96bed5/32.png) [@framebuilder](https://forum.inductiveautomation.com/u/framebuilder)\
**Post date:** [June 23, 2022, 9:09pm UTC](https://forum.inductiveautomation.com/t/is-it-possible-to-subscribe-to-mqtt-topic-on-demand-via-python-script/61135/1 "2022-06-23T21:09:28Z")

</div>

Assuming we have the MQTT Engine module, is it possible to subscribe to an MQTT topic via python script? At this point, we’re looking at just reading plain vanilla payloads (non-Sparkplug).

I know system.cirruslink.engine.publish exists to publish but haven’t been able to find a subscribe API.

I also understand that we could setup a Custom Namespace with a tag name wildcard filter to only pull the payload of a single topic which would send to the MQTT Engine tag provider as a tag but I was just wondering if we could grab that payload via script without involving a tag provider.

---

<div class="post-metadata">

**Author:** ![framebuilder](https://avatars.discourse-cdn.com/v4/letter/f/96bed5/32.png) [@framebuilder](https://forum.inductiveautomation.com/u/framebuilder)\
**Post date:** [June 23, 2022, 10:22pm UTC](https://forum.inductiveautomation.com/t/is-it-possible-to-subscribe-to-mqtt-topic-on-demand-via-python-script/61135/2 "2022-06-23T22:22:57Z")

</div>

Now that I think about it, this probably doesn’t make much sense. The whole purpose of subscribing to an MQTT topic is to “wait” for changes that get published. But assuming the retained flag is set when published, it would still be nice to subscribe via a button click (python script) and then close the connection. Definitely not looking to create a listener by any means.

I supposed paho.mqtt.client is probably a solution. Am I on the right track?
