{
  "id": "task_libraries:mqtt/python",
  "path": "/exapedia/python-mqtt-libraries",
  "template": {
    "id": "task_libraries",
    "version": 4
  },
  "title": "Python MQTT libraries",
  "answer": [
    {
      "t": "text",
      "text": "Python MQTT libraries connect devices and services to an MQTT broker to publish and subscribe to messages on topics. A client either runs its own network loop in a thread or exposes the connection through asyncio. These libraries let IoT devices, home automation systems, and backend services exchange sensor data and commands."
    }
  ],
  "breadcrumb": [
    {
      "label": "Tools"
    },
    {
      "label": "Python MQTT libraries"
    }
  ],
  "sections": [
    {
      "id": "libraries_popularity",
      "anchor": "popularity",
      "heading": "Popularity",
      "blocks": [
        {
          "b": "table",
          "columns": [
            "Library",
            "Monthly downloads",
            "Stars",
            "Last release",
            "License"
          ],
          "rows": [
            [
              [
                {
                  "t": "link",
                  "href": "#paho-mqtt",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F122"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F123"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F129"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F126"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F124"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#aiomqtt",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F140"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F141"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F147"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F144"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F142"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#awsiotsdk",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F158"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F159"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F167"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F162"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F160"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#gmqtt",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F174"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F175"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F181"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F178"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F176"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#amqtt",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F192"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F193"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F199"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F196"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F194"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#awsiotpythonsdk",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F206"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F207"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F215"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F210"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F208"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#mqttools",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F225"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F226"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F234"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F229"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F227"
                }
              ]
            ]
          ],
          "variant": "pop",
          "caption": [
            {
              "t": "text",
              "text": "Downloads: "
            },
            {
              "t": "text",
              "text": "PyPI"
            },
            {
              "t": "text",
              "text": ", last thirty days. Stars and releases: GitHub. Amber: no release in over a year."
            }
          ]
        }
      ],
      "note": [
        {
          "t": "link",
          "href": "#paho-mqtt",
          "label": [
            {
              "t": "fact",
              "fact": "F122"
            }
          ]
        },
        {
          "t": "text",
          "text": " has the most monthly downloads in this comparison, at "
        },
        {
          "t": "fact",
          "fact": "F123"
        },
        {
          "t": "text",
          "text": "."
        }
      ]
    },
    {
      "id": "libraries_capabilities",
      "anchor": "capabilities",
      "heading": "Capabilities",
      "blocks": [
        {
          "b": "table",
          "columns": [
            "Library",
            "MQTT version five",
            "Embedded broker",
            "QoS level two"
          ],
          "rows": [
            [
              [
                {
                  "t": "link",
                  "href": "#paho-mqtt",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F122"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F130"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F131"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F132"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#aiomqtt",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F140"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F148"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F149"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F150"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#awsiotsdk",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F158"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F168"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F169"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F170"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#gmqtt",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F174"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F182"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F183"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F184"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#amqtt",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F192"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F200"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F201"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F202"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#awsiotpythonsdk",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F206"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F216"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F217"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F218"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#mqttools",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F225"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F235"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F236"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F237"
                }
              ]
            ]
          ],
          "variant": "cap"
        }
      ]
    },
    {
      "id": "libraries_entries",
      "anchor": "libraries",
      "heading": "Libraries",
      "blocks": [
        {
          "b": "entry",
          "anchor": "paho-mqtt",
          "name": [
            {
              "t": "fact",
              "fact": "F122"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/eclipse-paho/paho.mqtt.python"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/paho-mqtt"
            },
            {
              "label": "Docs",
              "href": "https://eclipse.dev/paho/files/paho.mqtt.python/html/index.html"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F12"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F123"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F129"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F125"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F124"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://eclipse.dev/paho/files/paho.mqtt.python/html/index.html",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F122"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F13"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F14"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F15"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F16"
                }
              ]
            }
          ],
          "cons": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F17"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F18"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F19"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F20"
                }
              ]
            }
          ],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F138"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F139"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/blakeblackshear/frigate",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F138"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "def _create_client(self) -> mqtt.Client:\n    \"\"\"Build a fresh paho client for a single connect attempt.\"\"\"\n    client = mqtt.Client(\n        callback_api_version=CallbackAPIVersion.VERSION2,\n        client_id=self.mqtt_config.client_id,\n        reconnect_on_failure=False,\n    )\n    client.on_connect = self._on_connect\n    client.on_disconnect = self._on_disconnect\n    client.on_message = self._on_message\n    client.on_subscribe = self._on_subscribe\n    client.on_publish = self._on_publish\n    client.will_set(\n        self.mqtt_config.topic_prefix + \"/available\",\n        payload=\"offline\",\n        qos=1,\n        retain=True,\n    )\n\n    if self.mqtt_config.tls_ca_certs is not None:\n        if (\n            self.mqtt_config.tls_client_cert is not None\n            and self.mqtt_config.tls_client_key is not None\n        ):\n            client.tls_set(\n                self.mqtt_config.tls_ca_certs,\n                self.mqtt_config.tls_client_cert,\n                self.mqtt_config.tls_client_key,\n            )\n        else:\n            client.tls_set(self.mqtt_config.tls_ca_certs)\n\n    if self.mqtt_config.tls_insecure is not None:\n        client.tls_insecure_set(self.mqtt_config.tls_insecure)\n\n    if self.mqtt_config.user is not None:\n        client.username_pw_set(\n            self.mqtt_config.user,\n            password=self.mqtt_config.password,\n        )\n\n    return client",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/blakeblackshear/frigate/blob/ec5f6d4f7fcfb3e9ab45ec63026cf0cf0dc1a7db/frigate/comms/mqtt.py#L276-L317",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F137"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=Python%20projects%20using%20paho-mqtt%20for%20client%20setup%2C%20meter-state%20publication%20and%20subscription-handler%20registration&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F122"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "import paho.mqtt.publish as publish\npublish.single('paho/test/topic', 'hello', hostname='localhost')\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://pypi.org/pypi/paho-mqtt/2.2.0/json#info.description",
                  "label": [
                    {
                      "t": "text",
                      "text": "README.rst"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F127"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "aiomqtt",
          "name": [
            {
              "t": "fact",
              "fact": "F140"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/empicano/aiomqtt"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/aiomqtt"
            },
            {
              "label": "Docs",
              "href": "https://aiomqtt.bo3hm.com"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F37"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F141"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F147"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F143"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F142"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://aiomqtt.bo3hm.com",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F140"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F38"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F39"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F40"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F41"
                }
              ]
            }
          ],
          "cons": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F42"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F43"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F44"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F45"
                }
              ]
            }
          ],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F156"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F157"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/allangood/rtlamr2mqtt",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F156"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "async def publish_reading(self, client, reading: dict):\n    \"\"\"\n    Publish a meter reading: status, state, and attributes.\n    \"\"\"\n    meter_id = reading['meter_id']\n    meter_config = self.meters.get(meter_id, {})\n    consumption = reading['consumption']\n\n    # Format the reading if format is configured\n    fmt = meter_config.get('format')\n    if fmt:\n        formatted = ro.format_number(consumption, fmt)\n    else:\n        formatted = consumption\n\n    # Publish online status\n    await self.publish_status(client, 'online')\n\n    # Publish state\n    timestamp = datetime.now().astimezone().replace(microsecond=0).isoformat()\n    payload = {'reading': formatted, 'lastseen': timestamp}\n    await client.publish(\n        topic=f'{self.base_topic}/{meter_id}/state',\n        payload=dumps(payload),\n        qos=1,\n        retain=False,\n    )\n\n    # Publish attributes\n    attributes = dict(reading['message'])\n    attributes['protocol'] = meter_config.get('protocol', 'unknown')\n    await client.publish(\n        topic=f'{self.base_topic}/{meter_id}/attributes',\n        payload=dumps(attributes),\n        qos=1,\n        retain=False,\n    )\n\n    logger.info('Published reading for meter %s: %s', meter_id, formatted)",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/allangood/rtlamr2mqtt/blob/53ef59d4eaede836252c8e5b49673ec7e63366ef/rtlamr2mqtt-addon/app/mqtt_publisher.py#L190-L228",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F155"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=Python%20projects%20using%20aiomqtt%20for%20client%20setup%2C%20meter-state%20publication%20and%20subscription-handler%20registration&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F140"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "import asyncio\nimport aiomqtt\nasync def main():\n    async with aiomqtt.Client('localhost') as client:\n        await client.publish('temperature/outside', payload=28.4)\nasyncio.run(main())\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://pypi.org/pypi/aiomqtt/2.5.1/json#info.description",
                  "label": [
                    {
                      "t": "text",
                      "text": "reconnection.html"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F145"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "awsiotsdk",
          "name": [
            {
              "t": "fact",
              "fact": "F158"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/aws/aws-iot-device-sdk-python-v2"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/awsiotsdk"
            },
            {
              "label": "Docs",
              "href": "https://pypi.org/project/awsiotsdk/"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F165"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F159"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F167"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F161"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F160"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://pypi.org/project/awsiotsdk/",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F158"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [],
          "cons": [],
          "tabs": [
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "from awsiot import mqtt_connection_builder\nconnection = mqtt_connection_builder.mtls_from_path(\n    endpoint='YOUR_ENDPOINT', client_id='example',\n    cert_filepath='device.pem.crt', pri_key_filepath='private.pem.key',\n)\nconnection.connect().result()\nconnection.disconnect().result()\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://aws.github.io/aws-iot-device-sdk-python-v2/awsiot/mqtt_connection_builder.html",
                  "label": [
                    {
                      "t": "text",
                      "text": "mqtt_connection_builder.py"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=awsiotsdk%20GitHub%20projects",
                  "label": [
                    {
                      "t": "text",
                      "text": "Find projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F158"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F163"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "gmqtt",
          "name": [
            {
              "t": "fact",
              "fact": "F174"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/wialon/gmqtt"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/gmqtt"
            },
            {
              "label": "Docs",
              "href": "https://pypi.org/project/gmqtt/"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F62"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F175"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F181"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F177"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F176"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://pypi.org/project/gmqtt/",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F174"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F63"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F64"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F65"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F66"
                }
              ]
            }
          ],
          "cons": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F67"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F68"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F69"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F70"
                }
              ]
            }
          ],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F190"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F191"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/sabuhish/fastapi-mqtt",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F190"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "def subscribe(\n    self,\n    *topics,\n    qos: int = 0,\n    no_local: bool = False,\n    retain_as_published: bool = False,\n    retain_handling_options: int = 0,\n    subscription_identifier: Any = None,\n) -> Callable[..., Any]:\n    \"\"\"\n    Decorator method used to subscribe for specific topics.\n\n    Topics are subscribed on every (re)connection. If the client is already\n    connected when the decorator runs, they are also subscribed right away.\n\n    Handlers get (client, topic, payload, qos, properties). If a handler has a\n    parameter typed as a pydantic model, the payload is parsed into that model instead,\n    and the other parameters are passed by name:\n\n        @mqtt.subscribe(\"sensors/+/temperature\")\n        async def temperature(item: Temperature, topic: str): ...\n    \"\"\"\n\n    def subscribe_handler(handler: MQTTMessageHandler) -> MQTTMessageHandler:\n        self._logger.debug(\"Subscribe for topics: %s\", topics)\n        message_handler = self._message_handler(handler)\n        for topic in topics:\n            if topic not in self.subscriptions:\n                subscription = Subscription(\n                    topic,\n                    qos,\n                    no_local,\n                    retain_as_published,\n                    retain_handling_options,\n                    subscription_identifier,\n                )\n                self.subscriptions[topic] = (subscription, [message_handler])\n            else:\n                # Use the most restrictive field of the same subscription\n                old_subscription, handlers = self.subscriptions[topic]\n                subscription = Subscription(\n                    topic,\n                    max(qos, old_subscription.qos),\n                    no_local or old_subscription.no_local,\n                    retain_as_published or old_subscription.retain_as_published,\n                    max(\n                        retain_handling_options,\n                        old_subscription.retain_handling_options,\n                    ),\n                    old_subscription.subscription_identifier or subscription_identifier,\n                )\n                handlers.append(message_handler)\n                self.subscriptions[topic] = (subscription, handlers)\n\n            if self.client.is_connected:\n                self._logger.debug(\"Already connected, subscribing for %s\", topic)\n                self.client.subscribe(subscription)\n        return handler\n\n    return subscribe_handler",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/sabuhish/fastapi-mqtt/blob/055a2e4464ff2faeea26197ed84119a12aba7820/fastapi_mqtt/fastmqtt.py#L322-L381",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F189"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=Python%20projects%20using%20gmqtt%20for%20client%20setup%2C%20meter-state%20publication%20and%20subscription-handler%20registration&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F174"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "import asyncio\nfrom gmqtt import Client\nasync def main():\n    client = Client('example')\n    await client.connect('localhost')\n    client.publish('example/topic', 'hello', qos=0)\n    await client.disconnect()\nasyncio.run(main())\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://pypi.org/pypi/gmqtt/0.10.0/json#info.description",
                  "label": [
                    {
                      "t": "text",
                      "text": "README.md"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F179"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "amqtt",
          "name": [
            {
              "t": "fact",
              "fact": "F192"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/Yakifo/amqtt"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/amqtt"
            },
            {
              "label": "Docs",
              "href": "https://pypi.org/project/amqtt/"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F88"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F193"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F199"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F195"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F194"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://pypi.org/project/amqtt/",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F192"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F89"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F90"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F91"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F92"
                }
              ]
            }
          ],
          "cons": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F93"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F94"
                }
              ]
            }
          ],
          "tabs": [
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "import asyncio\nfrom amqtt.client import MQTTClient\nasync def main():\n    client = MQTTClient()\n    await client.connect('mqtt://localhost/')\n    await client.publish('example/topic', b'hello', qos=0)\n    await client.disconnect()\nasyncio.run(main())\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://amqtt.readthedocs.io/en/latest/references/client/",
                  "label": [
                    {
                      "t": "text",
                      "text": "client_publish.py"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=Python%20projects%20using%20amqtt%20for%20client%20setup%2C%20meter-state%20publication%20and%20subscription-handler%20registration&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D",
                  "label": [
                    {
                      "t": "text",
                      "text": "Find projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F192"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F197"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "awsiotpythonsdk",
          "name": [
            {
              "t": "fact",
              "fact": "F206"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/aws/aws-iot-device-sdk-python"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/AWSIoTPythonSDK"
            },
            {
              "label": "Docs",
              "href": "https://pypi.org/project/AWSIoTPythonSDK/"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F213"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F207"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F215"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F209"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F208"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://pypi.org/project/AWSIoTPythonSDK/",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F206"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [],
          "cons": [],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F223"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F224"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/aws-iot-builder-tools/iot-reference-architectures",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F223"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "python",
              "code": "def setup():\n    root_ca_file = \"root-ca.pem\"\n\n    # Get the CA cert if we need it\n    if not path.exists(root_ca_file):\n        request = requests.get('https://www.amazontrust.com/repository/AmazonRootCA1.pem', allow_redirects=True)\n        open(root_ca_file, 'wb').write(request.content)\n\n    # Get the hostname for the customer's ATS endpoint in this region\n    iot_client = boto3.client('iot')\n    iot_data = iot_client.describe_endpoint(endpointType='iot:Data-ATS')\n    host = iot_data['endpointAddress']\n\n    # Get temporary credentials\n    sts_client = boto3.client('sts')\n    sts_data = sts_client.get_session_token()\n\n    # Extract the temporary credential values\n    credentials = sts_data['Credentials']\n    access_key_id = credentials['AccessKeyId']\n    secret_access_key = credentials['SecretAccessKey']\n    session_token = credentials['SessionToken']\n\n    # Create an MQTT client with a random client ID that uses WebSockets\n    mqtt_client = AWSIoTMQTTClient(str(uuid.uuid4()), useWebsocket=True)\n    # Use port 443 + ALPN on the customer's ATS endpoint\n    mqtt_client.configureEndpoint(host, 443)\n    # Explicitly enable the root CA we downloaded\n    mqtt_client.configureCredentials(root_ca_file)\n\n    # Configure the library to use the specified credentials instead of using another provider to fetch them\n    AWSIoTMQTTClient.configureIAMCredentials(mqtt_client, access_key_id, secret_access_key, session_token)\n\n    return mqtt_client",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/aws-iot-builder-tools/iot-reference-architectures/blob/559d50b6f4d63bf1eb8be474f5cf3bc3a75ab273/tools/simple-pub-sub/shared.py#L17-L50",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F222"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=AWSIoTPythonSDK%20GitHub%20projects",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F206"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "from AWSIoTPythonSDK.MQTTLib import AWSIoTMQTTClient\nclient = AWSIoTMQTTClient('example')\nclient.configureEndpoint('YOUR_ENDPOINT', 8883)\nclient.configureCredentials('root-ca.pem', 'private.pem.key', 'device.pem.crt')\nclient.connect()\nclient.disconnect()\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://s3.amazonaws.com/aws-iot-device-sdk-python-docs/html/index.html",
                  "label": [
                    {
                      "t": "text",
                      "text": "index.html"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F211"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "mqttools",
          "name": [
            {
              "t": "fact",
              "fact": "F225"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/eerimoq/mqttools"
            },
            {
              "label": "PyPI",
              "href": "https://pypi.org/project/mqttools"
            },
            {
              "label": "Docs",
              "href": "https://pypi.org/project/mqttools/"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F232"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F226"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F234"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F228"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F227"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://pypi.org/project/mqttools/",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F225"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [],
          "cons": [],
          "tabs": [
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "python",
              "code": "import asyncio\nimport mqttools\nasync def publisher():\n    async with mqttools.Client('localhost', 1883) as client:\n        client.publish(mqttools.Message('/test/mqttools/foo', b'bar'))\nasyncio.run(publisher())\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://pypi.org/pypi/mqttools/0.50.0/json#info.description",
                  "label": [
                    {
                      "t": "text",
                      "text": "README.md"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=mqttools%20GitHub%20projects",
                  "label": [
                    {
                      "t": "text",
                      "text": "Find projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F225"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F230"
            }
          ]
        }
      ]
    }
  ],
  "questions": [
    {
      "q": "Which Python MQTT library should I use?",
      "a": [
        {
          "t": "link",
          "href": "#paho-mqtt",
          "label": [
            {
              "t": "fact",
              "fact": "F122"
            }
          ]
        },
        {
          "t": "text",
          "text": " suits most clients, with callbacks and threaded, blocking, or external network loops. "
        },
        {
          "t": "link",
          "href": "#aiomqtt",
          "label": [
            {
              "t": "text",
              "text": "aiomqtt"
            }
          ]
        },
        {
          "t": "text",
          "text": " suits asyncio applications. "
        },
        {
          "t": "link",
          "href": "#awsiotsdk",
          "label": [
            {
              "t": "fact",
              "fact": "F158"
            }
          ]
        },
        {
          "t": "text",
          "text": " suits devices that connect to AWS IoT."
        }
      ]
    },
    {
      "q": "What is Paho MQTT?",
      "a": [
        {
          "t": "link",
          "href": "#paho-mqtt",
          "label": [
            {
              "t": "fact",
              "fact": "F122"
            }
          ]
        },
        {
          "t": "text",
          "text": " is an MQTT client class with callbacks and a choice of threaded, blocking, or external network loops. It stores session state only in memory."
        }
      ]
    },
    {
      "q": "What is aiomqtt?",
      "a": [
        {
          "t": "link",
          "href": "#aiomqtt",
          "label": [
            {
              "t": "text",
              "text": "aiomqtt"
            }
          ]
        },
        {
          "t": "text",
          "text": " is an asyncio MQTT client built on Paho MQTT. It opens connections as async context managers and delivers incoming messages through its messages property."
        }
      ]
    },
    {
      "q": "Can Python run an MQTT broker?",
      "a": [
        {
          "t": "link",
          "href": "#amqtt",
          "label": [
            {
              "t": "text",
              "text": "aMQTT"
            }
          ]
        },
        {
          "t": "text",
          "text": " includes an asyncio broker with configurable listeners and plugins for authentication and authorization."
        }
      ]
    }
  ],
  "facts": {
    "F1": {
      "label": "Library name, paho-mqtt",
      "display": "Paho MQTT",
      "asOf": "2026-11-17"
    },
    "F2": {
      "label": "Monthly downloads, paho-mqtt",
      "display": "11.2M",
      "asOf": "2026-11-16"
    },
    "F3": {
      "label": "License, paho-mqtt",
      "display": "EPL-2.0 OR BSD-3-Clause",
      "asOf": "2026-11-17"
    },
    "F4": {
      "label": "Package release, paho-mqtt",
      "display": "2.2.0, Nov 2026",
      "asOf": "2026-11-04"
    },
    "F5": {
      "label": "Package release date, paho-mqtt",
      "display": "Nov 2026",
      "asOf": "2026-11-04"
    },
    "F6": {
      "label": "Repository stars, paho-mqtt",
      "display": "2.4K",
      "asOf": "2026-11-17"
    },
    "F7": {
      "label": "Asyncio APIs, paho-mqtt",
      "display": "Via plugin",
      "asOf": "2026-11-17"
    },
    "F8": {
      "label": "Publish and subscribe, paho-mqtt",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F9": {
      "label": "Reconnect controls, paho-mqtt",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F10": {
      "label": "TLS connections, paho-mqtt",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F11": {
      "label": "Install, paho-mqtt",
      "display": "pip install paho-mqtt",
      "asOf": "2026-11-17"
    },
    "F12": {
      "label": "What it does, paho-mqtt",
      "display": "Connects Python applications to MQTT brokers through callback-based publish and subscription APIs.",
      "asOf": "2026-11-17"
    },
    "F13": {
      "label": "strengths lead, paho-mqtt",
      "display": "Supports several MQTT protocol generations",
      "asOf": "2026-11-17"
    },
    "F14": {
      "label": "strengths, paho-mqtt",
      "display": "Connect to brokers using the newer or older supported protocol versions.",
      "asOf": "2026-11-17"
    },
    "F15": {
      "label": "strengths lead, paho-mqtt",
      "display": "Offers several network-loop integrations",
      "asOf": "2026-11-17"
    },
    "F16": {
      "label": "strengths, paho-mqtt",
      "display": "Choose blocking, threaded, or external-event-loop integration for the application.",
      "asOf": "2026-11-17"
    },
    "F17": {
      "label": "limitations lead, paho-mqtt",
      "display": "Persistent sessions remain in memory",
      "asOf": "2026-11-17"
    },
    "F18": {
      "label": "limitations, paho-mqtt",
      "display": "With clean_session=False, recreating the client loses its saved session state.",
      "asOf": "2026-11-17"
    },
    "F19": {
      "label": "limitations lead, paho-mqtt",
      "display": "Accepted publishes can remain pending",
      "asOf": "2026-11-17"
    },
    "F20": {
      "label": "limitations, paho-mqtt",
      "display": "Wait for completion before treating an accepted publish as sent.",
      "asOf": "2026-11-17"
    },
    "F21": {
      "label": "Quickstart, paho-mqtt",
      "display": "import paho.mqtt.client as mqtt\nfrom paho.mqtt.enums import CallbackAPIVersion\n\n# The callback for when the client receives a CONNACK response from the server.\ndef on_connect(client, userdata, flags, reason_code, properties):\n    print(f\"Connected with result code {reason_code}\")\n    # Subscribing in on_connect() means that if we lose the connection and\n    # reconnect then subscriptions will be renewed.\n    client.subscribe(\"$SYS/#\")\n\n# The callback for when a PUBLISH message is received from the server.\ndef on_message(client, userdata, msg):\n    print(msg.topic+\" \"+str(msg.payload))\n\nmqttc = mqtt.Client(CallbackAPIVersion.VERSION2)\nmqttc.on_connect = on_connect\nmqttc.on_message = on_message\n\nmqttc.connect(\"test.mosquitto.org\", 1883, 60)\n\n# Blocking call that processes network traffic, dispatches callbacks and\n# handles reconnecting.\n# Other loop*() functions are available that give a threaded interface and a\n# manual interface.\nmqttc.loop_forever()\n",
      "asOf": "2026-11-17"
    },
    "F22": {
      "label": "Project function, paho-mqtt",
      "display": "def _create_client(self) -> mqtt.Client:\n    # ...\n    client = mqtt.Client(\n        callback_api_version=CallbackAPIVersion.VERSION2,\n        client_id=self.mqtt_config.client_id,\n        reconnect_on_failure=False,\n    )\n    client.on_connect = self._on_connect\n    client.on_disconnect = self._on_disconnect\n    client.on_message = self._on_message\n    client.on_subscribe = self._on_subscribe\n    client.on_publish = self._on_publish\n    client.will_set(\n        self.mqtt_config.topic_prefix + \"/available\",\n        payload=\"offline\",\n        qos=1,\n        retain=True,\n    )\n\n    if self.mqtt_config.tls_ca_certs is not None:\n        if (\n            self.mqtt_config.tls_client_cert is not None\n            and self.mqtt_config.tls_client_key is not None\n        ):\n            client.tls_set(\n                self.mqtt_config.tls_ca_certs,\n                self.mqtt_config.tls_client_cert,\n                self.mqtt_config.tls_client_key,\n            )\n        else:\n            client.tls_set(self.mqtt_config.tls_ca_certs)\n\n    if self.mqtt_config.tls_insecure is not None:\n        client.tls_insecure_set(self.mqtt_config.tls_insecure)\n\n    if self.mqtt_config.user is not None:\n        client.username_pw_set(\n            self.mqtt_config.user,\n            password=self.mqtt_config.password,\n        )\n\n    return client\n",
      "asOf": "2026-11-17"
    },
    "F23": {
      "label": "Project function reference, paho-mqtt",
      "display": "mqtt.py · _create_client()",
      "asOf": "2026-11-17"
    },
    "F24": {
      "label": "Project repository, paho-mqtt",
      "display": "blakeblackshear/frigate",
      "asOf": "2026-11-17"
    },
    "F25": {
      "label": "Project stars, blakeblackshear/frigate",
      "display": "37.5K",
      "asOf": "2026-11-17"
    },
    "F26": {
      "label": "Project push date, blakeblackshear/frigate",
      "display": "Nov 2026",
      "asOf": "2026-11-16"
    },
    "F27": {
      "label": "Library name, aiomqtt",
      "display": "aiomqtt",
      "asOf": "2026-11-17"
    },
    "F28": {
      "label": "Monthly downloads, aiomqtt",
      "display": "1.6M",
      "asOf": "2026-11-16"
    },
    "F29": {
      "label": "License, aiomqtt",
      "display": "BSD",
      "asOf": "2026-11-17"
    },
    "F30": {
      "label": "Package release, aiomqtt",
      "display": "2.5.1, Mar 2026",
      "asOf": "2026-03-05"
    },
    "F31": {
      "label": "Package release date, aiomqtt",
      "display": "Mar 2026",
      "asOf": "2026-03-05"
    },
    "F32": {
      "label": "Repository stars, aiomqtt",
      "display": "581",
      "asOf": "2026-11-17"
    },
    "F33": {
      "label": "Asyncio APIs, aiomqtt",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F34": {
      "label": "Publish and subscribe, aiomqtt",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F35": {
      "label": "TLS connections, aiomqtt",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F36": {
      "label": "Install, aiomqtt",
      "display": "pip install aiomqtt",
      "asOf": "2026-11-17"
    },
    "F37": {
      "label": "What it does, aiomqtt",
      "display": "Wraps stable Paho clients with awaitable MQTT operations and asynchronous context management.",
      "asOf": "2026-11-17"
    },
    "F38": {
      "label": "strengths lead, aiomqtt",
      "display": "Awaits publishing and subscriptions",
      "asOf": "2026-11-17"
    },
    "F39": {
      "label": "strengths, aiomqtt",
      "display": "Use async context management and consume messages through asynchronous iteration.",
      "asOf": "2026-11-17"
    },
    "F40": {
      "label": "strengths lead, aiomqtt",
      "display": "Raises exceptions for MQTT failures",
      "asOf": "2026-11-17"
    },
    "F41": {
      "label": "strengths, aiomqtt",
      "display": "Handle MQTT failures through MqttError in the application.",
      "asOf": "2026-11-17"
    },
    "F42": {
      "label": "limitations lead, aiomqtt",
      "display": "Reconnection needs an application loop",
      "asOf": "2026-11-17"
    },
    "F43": {
      "label": "limitations, aiomqtt",
      "display": "Catch MqttError and re-enter the client context after a suitable delay.",
      "asOf": "2026-11-17"
    },
    "F44": {
      "label": "limitations lead, aiomqtt",
      "display": "Windows needs selector event loops",
      "asOf": "2026-11-17"
    },
    "F45": {
      "label": "limitations, aiomqtt",
      "display": "Use an event loop that supports add_reader on Windows.",
      "asOf": "2026-11-17"
    },
    "F46": {
      "label": "Quickstart, aiomqtt",
      "display": "import asyncio\nimport aiomqtt\n\nasync def main():\n    client = aiomqtt.Client(\"test.mosquitto.org\")\n    interval = 5  # Seconds\n    while True:\n        try:\n            async with client:\n                await client.subscribe(\"humidity/#\")\n                async for message in client.messages:\n                    print(message.payload)\n        except aiomqtt.MqttError:\n            print(f\"Connection lost; Reconnecting in {interval} seconds ...\")\n            await asyncio.sleep(interval)\n\nasyncio.run(main())\n\n",
      "asOf": "2026-11-17"
    },
    "F47": {
      "label": "Project function, aiomqtt",
      "display": "async def publish_reading(self, client, reading: dict):\n    # ...\n    meter_id = reading['meter_id']\n    meter_config = self.meters.get(meter_id, {})\n    consumption = reading['consumption']\n\n    # Format the reading if format is configured\n    fmt = meter_config.get('format')\n    if fmt:\n        formatted = ro.format_number(consumption, fmt)\n    else:\n        formatted = consumption\n\n    # Publish online status\n    await self.publish_status(client, 'online')\n\n    # Publish state\n    timestamp = datetime.now().astimezone().replace(microsecond=0).isoformat()\n    payload = {'reading': formatted, 'lastseen': timestamp}\n    await client.publish(\n        topic=f'{self.base_topic}/{meter_id}/state',\n        payload=dumps(payload),\n        qos=1,\n        retain=False,\n    )\n\n    # Publish attributes\n    attributes = dict(reading['message'])\n    attributes['protocol'] = meter_config.get('protocol', 'unknown')\n    await client.publish(\n        topic=f'{self.base_topic}/{meter_id}/attributes',\n        payload=dumps(attributes),\n        qos=1,\n        retain=False,\n    )\n\n    logger.info('Published reading for meter %s: %s', meter_id, formatted)\n",
      "asOf": "2026-11-17"
    },
    "F48": {
      "label": "Project function reference, aiomqtt",
      "display": "mqtt_publisher.py · publish_reading()",
      "asOf": "2026-11-17"
    },
    "F49": {
      "label": "Project repository, aiomqtt",
      "display": "allangood/rtlamr2mqtt",
      "asOf": "2026-11-17"
    },
    "F50": {
      "label": "Project stars, allangood/rtlamr2mqtt",
      "display": "647",
      "asOf": "2026-11-17"
    },
    "F51": {
      "label": "Project push date, allangood/rtlamr2mqtt",
      "display": "Nov 2026",
      "asOf": "2026-11-16"
    },
    "F52": {
      "label": "Library name, gmqtt",
      "display": "gmqtt",
      "asOf": "2026-11-17"
    },
    "F53": {
      "label": "Monthly downloads, gmqtt",
      "display": "174.6K",
      "asOf": "2026-11-16"
    },
    "F54": {
      "label": "License, gmqtt",
      "display": "MIT",
      "asOf": "2026-11-17"
    },
    "F55": {
      "label": "Package release, gmqtt",
      "display": "0.10.0, Nov 2026",
      "asOf": "2026-11-11"
    },
    "F56": {
      "label": "Package release date, gmqtt",
      "display": "Nov 2026",
      "asOf": "2026-11-11"
    },
    "F57": {
      "label": "Repository stars, gmqtt",
      "display": "454",
      "asOf": "2026-11-17"
    },
    "F58": {
      "label": "Asyncio APIs, gmqtt",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F59": {
      "label": "Publish and subscribe, gmqtt",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F60": {
      "label": "Reconnect controls, gmqtt",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F61": {
      "label": "Install, gmqtt",
      "display": "pip install gmqtt uvloop",
      "asOf": "2026-11-17"
    },
    "F62": {
      "label": "What it does, gmqtt",
      "display": "Provides an asyncio MQTT client with configurable reconnect behavior and protocol properties.",
      "asOf": "2026-11-17"
    },
    "F63": {
      "label": "strengths lead, gmqtt",
      "display": "Connects through native asyncio",
      "asOf": "2026-11-17"
    },
    "F64": {
      "label": "strengths, gmqtt",
      "display": "Await connection and disconnection while retaining MQTT event callbacks.",
      "asOf": "2026-11-17"
    },
    "F65": {
      "label": "strengths lead, gmqtt",
      "display": "Configures reconnect attempts and delays",
      "asOf": "2026-11-17"
    },
    "F66": {
      "label": "strengths, gmqtt",
      "display": "Set retry limits and backoff settings for lost connections.",
      "asOf": "2026-11-17"
    },
    "F67": {
      "label": "limitations lead, gmqtt",
      "display": "Reconnect attempts are unlimited initially",
      "asOf": "2026-11-17"
    },
    "F68": {
      "label": "limitations, gmqtt",
      "display": "Set reconnect_retries when a disconnected client should eventually stop trying.",
      "asOf": "2026-11-17"
    },
    "F69": {
      "label": "limitations lead, gmqtt",
      "display": "Older brokers can reject negotiation",
      "asOf": "2026-11-17"
    },
    "F70": {
      "label": "limitations, gmqtt",
      "display": "Force the older protocol when a broker cannot parse the initial connection.",
      "asOf": "2026-11-17"
    },
    "F71": {
      "label": "Quickstart, gmqtt",
      "display": "import asyncio\nimport os\nimport signal\nimport time\n\nfrom gmqtt import Client as MQTTClient\n\n# gmqtt also compatibility with uvloop  \nimport uvloop\nasyncio.set_event_loop_policy(uvloop.EventLoopPolicy())\n\n\nSTOP = asyncio.Event()\n\n\ndef on_connect(client, flags, rc, properties):\n    print('Connected')\n    client.subscribe('TEST/#', qos=0)\n\n\ndef on_message(client, topic, payload, qos, properties):\n    print('RECV MSG:', payload)\n\n\ndef on_disconnect(client, packet, exc=None):\n    print('Disconnected')\n\ndef on_subscribe(client, mid, qos, properties):\n    print('SUBSCRIBED')\n\ndef ask_exit(*args):\n    STOP.set()\n\nasync def main(broker_host, token):\n    client = MQTTClient(\"client-id\")\n\n    client.on_connect = on_connect\n    client.on_message = on_message\n    client.on_disconnect = on_disconnect\n    client.on_subscribe = on_subscribe\n\n    client.set_auth_credentials(token, None)\n    await client.connect(broker_host)\n\n    client.publish('TEST/TIME', str(time.time()), qos=1)\n\n    await STOP.wait()\n    await client.disconnect()\n\n\nif __name__ == '__main__':\n    loop = asyncio.get_event_loop()\n\n    host = 'mqtt.flespi.io'\n    token = os.environ.get('FLESPI_TOKEN')\n\n    loop.add_signal_handler(signal.SIGINT, ask_exit)\n    loop.add_signal_handler(signal.SIGTERM, ask_exit)\n\n    loop.run_until_complete(main(host, token))\n",
      "asOf": "2026-11-17"
    },
    "F72": {
      "label": "Project function, gmqtt",
      "display": "def subscribe(\n    self,\n    *topics,\n    qos: int = 0,\n    no_local: bool = False,\n    retain_as_published: bool = False,\n    retain_handling_options: int = 0,\n    subscription_identifier: Any = None,\n) -> Callable[..., Any]:\n    # ...\n\n    def subscribe_handler(handler: MQTTMessageHandler) -> MQTTMessageHandler:\n        self._logger.debug(\"Subscribe for topics: %s\", topics)\n        message_handler = self._message_handler(handler)\n        for topic in topics:\n            if topic not in self.subscriptions:\n                subscription = Subscription(\n                    topic,\n                    qos,\n                    no_local,\n                    retain_as_published,\n                    retain_handling_options,\n                    subscription_identifier,\n                )\n                self.subscriptions[topic] = (subscription, [message_handler])\n            else:\n                # Use the most restrictive field of the same subscription\n                old_subscription, handlers = self.subscriptions[topic]\n                subscription = Subscription(\n                    topic,\n                    max(qos, old_subscription.qos),\n                    no_local or old_subscription.no_local,\n                    retain_as_published or old_subscription.retain_as_published,\n                    max(\n                        retain_handling_options,\n                        old_subscription.retain_handling_options,\n                    ),\n                    old_subscription.subscription_identifier or subscription_identifier,\n                )\n                handlers.append(message_handler)\n                self.subscriptions[topic] = (subscription, handlers)\n\n            if self.client.is_connected:\n                self._logger.debug(\"Already connected, subscribing for %s\", topic)\n                self.client.subscribe(subscription)\n        return handler\n\n    return subscribe_handler\n",
      "asOf": "2026-11-17"
    },
    "F73": {
      "label": "Project function reference, gmqtt",
      "display": "fastmqtt.py · subscribe()",
      "asOf": "2026-11-17"
    },
    "F74": {
      "label": "Project repository, gmqtt",
      "display": "sabuhish/fastapi-mqtt",
      "asOf": "2026-11-17"
    },
    "F75": {
      "label": "Project stars, sabuhish/fastapi-mqtt",
      "display": "387",
      "asOf": "2026-11-17"
    },
    "F76": {
      "label": "Project push date, sabuhish/fastapi-mqtt",
      "display": "Oct 2026",
      "asOf": "2026-10-17"
    },
    "F77": {
      "label": "Library name, amqtt",
      "display": "aMQTT",
      "asOf": "2026-11-17"
    },
    "F78": {
      "label": "Monthly downloads, amqtt",
      "display": "87.3K",
      "asOf": "2026-11-16"
    },
    "F79": {
      "label": "License, amqtt",
      "display": "MIT",
      "asOf": "2026-11-17"
    },
    "F80": {
      "label": "Package release, amqtt",
      "display": "0.12.2, Nov 2026",
      "asOf": "2026-11-13"
    },
    "F81": {
      "label": "Package release date, amqtt",
      "display": "Nov 2026",
      "asOf": "2026-11-13"
    },
    "F82": {
      "label": "Repository stars, amqtt",
      "display": "221",
      "asOf": "2026-11-17"
    },
    "F83": {
      "label": "Asyncio APIs, amqtt",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F84": {
      "label": "Publish and subscribe, amqtt",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F85": {
      "label": "Reconnect controls, amqtt",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F86": {
      "label": "TLS connections, amqtt",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F87": {
      "label": "Install, amqtt",
      "display": "pip install amqtt",
      "asOf": "2026-11-17"
    },
    "F88": {
      "label": "What it does, amqtt",
      "display": "Provides both an MQTT broker and a client implemented with Python asyncio.",
      "asOf": "2026-11-17"
    },
    "F89": {
      "label": "strengths lead, amqtt",
      "display": "Embeds a Python MQTT broker",
      "asOf": "2026-11-17"
    },
    "F90": {
      "label": "strengths, amqtt",
      "display": "Run a broker and client within an asyncio-based application.",
      "asOf": "2026-11-17"
    },
    "F91": {
      "label": "strengths lead, amqtt",
      "display": "Supports encrypted MQTT transports",
      "asOf": "2026-11-17"
    },
    "F92": {
      "label": "strengths, amqtt",
      "display": "Use TLS-protected TCP or secure WebSocket connections.",
      "asOf": "2026-11-17"
    },
    "F93": {
      "label": "limitations lead, amqtt",
      "display": "Default broker allows anonymous clients",
      "asOf": "2026-11-17"
    },
    "F94": {
      "label": "limitations, amqtt",
      "display": "Replace the default anonymous plugin when the broker must authenticate its clients.",
      "asOf": "2026-11-17"
    },
    "F95": {
      "label": "Quickstart, amqtt",
      "display": "import asyncio\nimport logging\n\nfrom amqtt.client import ConnectError, MQTTClient\nfrom amqtt.mqtt.constants import QOS_1, QOS_2\n\n\"\"\"\nThis sample shows how to publish messages to broker using different QOS\n\"\"\"\n\nlogger = logging.getLogger(__name__)\n\nconfig = {\n    \"will\": {\n        \"topic\": \"/will/client\",\n        \"message\": b\"Dead or alive\",\n        \"qos\": QOS_1,\n        \"retain\": True,\n    },\n}\n\n\nasync def test_coro1() -> None:\n    client = MQTTClient()\n    await client.connect(\"mqtt://localhost:1883/\")\n    tasks = [\n        asyncio.ensure_future(client.publish(\"a/b\", b\"TEST MESSAGE WITH QOS_0\")),\n        asyncio.ensure_future(client.publish(\"a/b\", b\"TEST MESSAGE WITH QOS_1\", qos=QOS_1)),\n        asyncio.ensure_future(client.publish(\"a/b\", b\"TEST MESSAGE WITH QOS_2\", qos=QOS_2)),\n    ]\n    await asyncio.wait(tasks)\n    logger.info(\"test_coro1 messages published\")\n    await client.disconnect()\n\n\nasync def test_coro2() -> None:\n    try:\n        client = MQTTClient(config={\"auto_reconnect\": False, \"connection_timeout\": 1})\n        await client.connect(\"mqtt://localhost:1884/\")\n        await client.publish(\"a/b\", b\"TEST MESSAGE WITH QOS_0\", qos=0x00)\n        await client.publish(\"a/b\", b\"TEST MESSAGE WITH QOS_1\", qos=0x01)\n        await client.publish(\"a/b\", b\"TEST MESSAGE WITH QOS_2\", qos=0x02)\n        logger.info(\"test_coro2 messages published\")\n        await client.disconnect()\n    except ConnectError:\n        logger.info(\"Connection failed\", exc_info=True)\n\n\ndef __main__():\n\n    formatter = \"[%(asctime)s] :: %(levelname)s :: %(name)s :: %(message)s\"\n    logging.basicConfig(level=logging.INFO, format=formatter)\n\n    asyncio.run(test_coro1())\n    asyncio.run(test_coro2())\n\nif __name__ == \"__main__\":\n    __main__()\n",
      "asOf": "2026-11-17"
    },
    "F96": {
      "label": "Developer need",
      "display": "Callback-based MQTT integration",
      "asOf": "2026-11-17"
    },
    "F97": {
      "label": "Why choose paho-mqtt",
      "display": "blocking, threaded, and external-loop options",
      "asOf": "2026-11-17"
    },
    "F98": {
      "label": "Developer need in introduction",
      "display": "callback-based MQTT integration",
      "asOf": "2026-11-17"
    },
    "F99": {
      "label": "When to consider aiomqtt",
      "display": "the application should await MQTT operations",
      "asOf": "2026-11-17"
    },
    "F100": {
      "label": "Developer need",
      "display": "Awaitable MQTT operations",
      "asOf": "2026-11-17"
    },
    "F101": {
      "label": "Why choose aiomqtt",
      "display": "async context management and message iteration",
      "asOf": "2026-11-17"
    },
    "F102": {
      "label": "Developer need in introduction",
      "display": "awaitable MQTT operations",
      "asOf": "2026-11-17"
    },
    "F103": {
      "label": "When to consider gmqtt",
      "display": "configurable client reconnection is the main requirement",
      "asOf": "2026-11-17"
    },
    "F104": {
      "label": "Developer need",
      "display": "Configurable asynchronous reconnection",
      "asOf": "2026-11-17"
    },
    "F105": {
      "label": "Why choose gmqtt",
      "display": "reconnect attempt limits and delays",
      "asOf": "2026-11-17"
    },
    "F106": {
      "label": "Developer need in introduction",
      "display": "configurable asynchronous reconnection",
      "asOf": "2026-11-17"
    },
    "F107": {
      "label": "Developer need",
      "display": "Embedding a Python MQTT broker",
      "asOf": "2026-11-17"
    },
    "F108": {
      "label": "Why choose amqtt",
      "display": "both asyncio broker and client APIs",
      "asOf": "2026-11-17"
    },
    "F109": {
      "label": "Developer need in introduction",
      "display": "embedding a Python MQTT broker",
      "asOf": "2026-11-17"
    },
    "F110": {
      "label": "Page introduction",
      "display": "Python MQTT libraries let device and application developers publish and subscribe to MQTT messages.",
      "asOf": "2026-11-17"
    },
    "F111": {
      "label": "FAQ: Which Python MQTT library should I choose?",
      "display": "Paho provides several network-loop integration styles.",
      "asOf": "2026-11-17"
    },
    "F112": {
      "label": "FAQ: Which Python MQTT library should I choose?",
      "display": "Stable aiomqtt exposes asynchronous context management over its MQTT connection.",
      "asOf": "2026-11-17"
    },
    "F113": {
      "label": "FAQ: Which Python MQTT library should I choose?",
      "display": "gmqtt supports configurable reconnect attempts and delays.",
      "asOf": "2026-11-17"
    },
    "F114": {
      "label": "FAQ: Which Python MQTT library should I choose?",
      "display": "aMQTT includes both a Python broker and client.",
      "asOf": "2026-11-17"
    },
    "F115": {
      "label": "FAQ: Does publish success mean that a message has reached the broker?",
      "display": "Paho publish success does not always mean sent; its completion callback has different meanings for different delivery levels.",
      "asOf": "2026-11-17"
    },
    "F116": {
      "label": "FAQ: Will a persistent Paho session survive a process restart?",
      "display": "With clean_session disabled, client session state is retained only in memory, and is lost when the client is recreated.",
      "asOf": "2026-11-17"
    },
    "F117": {
      "label": "FAQ: Does stable aiomqtt reconnect automatically?",
      "display": "The stable reconnection pattern catches MqttError and re-enters a reusable client context inside an application loop.",
      "asOf": "2026-11-17"
    },
    "F118": {
      "label": "FAQ: Why can stable aiomqtt fail with the default Windows event loop?",
      "display": "It needs add_reader support; use a compatible selector event loop on Windows.",
      "asOf": "2026-11-17"
    },
    "F119": {
      "label": "FAQ: How can gmqtt stop retrying a failed connection?",
      "display": "Reconnect attempts are unlimited by default; set reconnect_retries to cap them.",
      "asOf": "2026-11-17"
    },
    "F120": {
      "label": "FAQ: Can an older broker reject gmqtt protocol negotiation?",
      "display": "Some brokers cannot parse its initial newer-protocol connection packet; explicitly select the older protocol for those brokers.",
      "asOf": "2026-11-17"
    },
    "F121": {
      "label": "FAQ: Does embedding an aMQTT broker require authentication configuration?",
      "display": "Its default configuration includes anonymous authentication; replace that plugin when the broker must authenticate clients.",
      "asOf": "2026-11-17"
    },
    "F122": {
      "label": "Library name, paho-mqtt",
      "display": "paho-mqtt",
      "asOf": "2026-11-20"
    },
    "F123": {
      "label": "Monthly downloads, paho-mqtt",
      "display": "11.6M",
      "asOf": "2026-11-20"
    },
    "F124": {
      "label": "License, paho-mqtt",
      "display": "EPL-2.0 OR BSD-3-Clause",
      "asOf": "2026-11-20"
    },
    "F125": {
      "label": "Package release, paho-mqtt",
      "display": "2.2.0",
      "asOf": "2026-11-20"
    },
    "F126": {
      "label": "Package release date, paho-mqtt",
      "display": "Nov 2026",
      "asOf": "2026-11-20"
    },
    "F127": {
      "label": "Install, paho-mqtt",
      "display": "python -m pip install paho-mqtt",
      "asOf": "2026-11-20"
    },
    "F128": {
      "label": "Quickstart, paho-mqtt",
      "display": "import paho.mqtt.publish as publish\npublish.single('paho/test/topic', 'hello', hostname='localhost')\n",
      "asOf": "2026-11-20"
    },
    "F129": {
      "label": "Repository stars, paho-mqtt",
      "display": "2.4K",
      "asOf": "2026-11-20"
    },
    "F130": {
      "label": "MQTT version five, paho-mqtt",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F131": {
      "label": "Embedded broker, paho-mqtt",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F132": {
      "label": "QoS level two, paho-mqtt",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F133": {
      "label": "Integration model, paho-mqtt",
      "display": "Callbacks plus threaded, blocking, or external network loop",
      "asOf": "2026-11-20"
    },
    "F134": {
      "label": "Session persistence, paho-mqtt",
      "display": "Session is only stored in memory",
      "asOf": "2026-11-20"
    },
    "F135": {
      "label": "Declared Python requirement, paho-mqtt",
      "display": ">=3.9",
      "asOf": "2026-11-20"
    },
    "F136": {
      "label": "Project function, paho-mqtt",
      "display": "def _create_client(self) -> mqtt.Client:\n    \"\"\"Build a fresh paho client for a single connect attempt.\"\"\"\n    client = mqtt.Client(\n        callback_api_version=CallbackAPIVersion.VERSION2,\n        client_id=self.mqtt_config.client_id,\n        reconnect_on_failure=False,\n    )\n    client.on_connect = self._on_connect\n    client.on_disconnect = self._on_disconnect\n    client.on_message = self._on_message\n    client.on_subscribe = self._on_subscribe\n    client.on_publish = self._on_publish\n    client.will_set(\n        self.mqtt_config.topic_prefix + \"/available\",\n        payload=\"offline\",\n        qos=1,\n        retain=True,\n    )\n\n    if self.mqtt_config.tls_ca_certs is not None:\n        if (\n            self.mqtt_config.tls_client_cert is not None\n            and self.mqtt_config.tls_client_key is not None\n        ):\n            client.tls_set(\n                self.mqtt_config.tls_ca_certs,\n                self.mqtt_config.tls_client_cert,\n                self.mqtt_config.tls_client_key,\n            )\n        else:\n            client.tls_set(self.mqtt_config.tls_ca_certs)\n\n    if self.mqtt_config.tls_insecure is not None:\n        client.tls_insecure_set(self.mqtt_config.tls_insecure)\n\n    if self.mqtt_config.user is not None:\n        client.username_pw_set(\n            self.mqtt_config.user,\n            password=self.mqtt_config.password,\n        )\n\n    return client",
      "asOf": "2026-11-20"
    },
    "F137": {
      "label": "Project source file, paho-mqtt",
      "display": "frigate/comms/mqtt.py",
      "asOf": "2026-11-20"
    },
    "F138": {
      "label": "Project full_name, paho-mqtt",
      "display": "blakeblackshear/frigate",
      "asOf": "2026-11-20"
    },
    "F139": {
      "label": "Project stargazers_count, paho-mqtt",
      "display": "37.6K",
      "asOf": "2026-11-20"
    },
    "F140": {
      "label": "Library name, aiomqtt",
      "display": "aiomqtt",
      "asOf": "2026-11-20"
    },
    "F141": {
      "label": "Monthly downloads, aiomqtt",
      "display": "1.6M",
      "asOf": "2026-11-20"
    },
    "F142": {
      "label": "License, aiomqtt",
      "display": "BSD-3-Clause",
      "asOf": "2026-11-20"
    },
    "F143": {
      "label": "Package release, aiomqtt",
      "display": "2.5.1",
      "asOf": "2026-11-20"
    },
    "F144": {
      "label": "Package release date, aiomqtt",
      "display": "Mar 2026",
      "asOf": "2026-11-20"
    },
    "F145": {
      "label": "Install, aiomqtt",
      "display": "python -m pip install aiomqtt",
      "asOf": "2026-11-20"
    },
    "F146": {
      "label": "Quickstart, aiomqtt",
      "display": "import asyncio\nimport aiomqtt\nasync def main():\n    async with aiomqtt.Client('localhost') as client:\n        await client.publish('temperature/outside', payload=28.4)\nasyncio.run(main())\n",
      "asOf": "2026-11-20"
    },
    "F147": {
      "label": "Repository stars, aiomqtt",
      "display": "581",
      "asOf": "2026-11-20"
    },
    "F148": {
      "label": "MQTT version five, aiomqtt",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F149": {
      "label": "Embedded broker, aiomqtt",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F150": {
      "label": "QoS level two, aiomqtt",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F151": {
      "label": "Published stable API, aiomqtt",
      "display": "2.5.1: async context and client.messages property",
      "asOf": "2026-11-20"
    },
    "F152": {
      "label": "Underlying runtime, aiomqtt",
      "display": "Paho MQTT dependency in selected stable release",
      "asOf": "2026-11-20"
    },
    "F153": {
      "label": "Declared Python requirement, aiomqtt",
      "display": "<4.0,>=3.8",
      "asOf": "2026-11-20"
    },
    "F154": {
      "label": "Project function, aiomqtt",
      "display": "async def publish_reading(self, client, reading: dict):\n    \"\"\"\n    Publish a meter reading: status, state, and attributes.\n    \"\"\"\n    meter_id = reading['meter_id']\n    meter_config = self.meters.get(meter_id, {})\n    consumption = reading['consumption']\n\n    # Format the reading if format is configured\n    fmt = meter_config.get('format')\n    if fmt:\n        formatted = ro.format_number(consumption, fmt)\n    else:\n        formatted = consumption\n\n    # Publish online status\n    await self.publish_status(client, 'online')\n\n    # Publish state\n    timestamp = datetime.now().astimezone().replace(microsecond=0).isoformat()\n    payload = {'reading': formatted, 'lastseen': timestamp}\n    await client.publish(\n        topic=f'{self.base_topic}/{meter_id}/state',\n        payload=dumps(payload),\n        qos=1,\n        retain=False,\n    )\n\n    # Publish attributes\n    attributes = dict(reading['message'])\n    attributes['protocol'] = meter_config.get('protocol', 'unknown')\n    await client.publish(\n        topic=f'{self.base_topic}/{meter_id}/attributes',\n        payload=dumps(attributes),\n        qos=1,\n        retain=False,\n    )\n\n    logger.info('Published reading for meter %s: %s', meter_id, formatted)",
      "asOf": "2026-11-20"
    },
    "F155": {
      "label": "Project source file, aiomqtt",
      "display": "rtlamr2mqtt-addon/app/mqtt_publisher.py",
      "asOf": "2026-11-20"
    },
    "F156": {
      "label": "Project full_name, aiomqtt",
      "display": "allangood/rtlamr2mqtt",
      "asOf": "2026-11-20"
    },
    "F157": {
      "label": "Project stargazers_count, aiomqtt",
      "display": "649",
      "asOf": "2026-11-20"
    },
    "F158": {
      "label": "Library name, awsiotsdk",
      "display": "awsiotsdk",
      "asOf": "2026-11-20"
    },
    "F159": {
      "label": "Monthly downloads, awsiotsdk",
      "display": "1.0M",
      "asOf": "2026-11-20"
    },
    "F160": {
      "label": "License, awsiotsdk",
      "display": "Apache-2.0",
      "asOf": "2026-11-20"
    },
    "F161": {
      "label": "Package release, awsiotsdk",
      "display": "1.31.0",
      "asOf": "2026-11-20"
    },
    "F162": {
      "label": "Package release date, awsiotsdk",
      "display": "Jul 2026",
      "asOf": "2026-11-20"
    },
    "F163": {
      "label": "Install, awsiotsdk",
      "display": "python -m pip install awsiotsdk",
      "asOf": "2026-11-20"
    },
    "F164": {
      "label": "Quickstart, awsiotsdk",
      "display": "from awsiot import mqtt_connection_builder\nconnection = mqtt_connection_builder.mtls_from_path(\n    endpoint='YOUR_ENDPOINT', client_id='example',\n    cert_filepath='device.pem.crt', pri_key_filepath='private.pem.key',\n)\nconnection.connect().result()\nconnection.disconnect().result()\n",
      "asOf": "2026-11-20"
    },
    "F165": {
      "label": "Official description, awsiotsdk",
      "display": "Connects to AWS IoT through the AWS Common Runtime.",
      "asOf": "2026-11-20"
    },
    "F166": {
      "label": "Quickstart source file, awsiotsdk",
      "display": "awsiot/mqtt_connection_builder.py",
      "asOf": "2026-11-20"
    },
    "F167": {
      "label": "Repository stars, awsiotsdk",
      "display": "447",
      "asOf": "2026-11-20"
    },
    "F168": {
      "label": "MQTT version five, awsiotsdk",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F169": {
      "label": "Embedded broker, awsiotsdk",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F170": {
      "label": "QoS level two, awsiotsdk",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F171": {
      "label": "Connection role, awsiotsdk",
      "display": "AWS-specific builders return CRT MQTT connection",
      "asOf": "2026-11-20"
    },
    "F172": {
      "label": "Protocol families, awsiotsdk",
      "display": "MQTT3 connection builder and MQTT5 client builder",
      "asOf": "2026-11-20"
    },
    "F173": {
      "label": "Declared Python requirement, awsiotsdk",
      "display": ">=3.8",
      "asOf": "2026-11-20"
    },
    "F174": {
      "label": "Library name, gmqtt",
      "display": "gmqtt",
      "asOf": "2026-11-20"
    },
    "F175": {
      "label": "Monthly downloads, gmqtt",
      "display": "189.3K",
      "asOf": "2026-11-20"
    },
    "F176": {
      "label": "License, gmqtt",
      "display": "MIT",
      "asOf": "2026-11-20"
    },
    "F177": {
      "label": "Package release, gmqtt",
      "display": "0.10.0",
      "asOf": "2026-11-20"
    },
    "F178": {
      "label": "Package release date, gmqtt",
      "display": "Nov 2026",
      "asOf": "2026-11-20"
    },
    "F179": {
      "label": "Install, gmqtt",
      "display": "python -m pip install gmqtt",
      "asOf": "2026-11-20"
    },
    "F180": {
      "label": "Quickstart, gmqtt",
      "display": "import asyncio\nfrom gmqtt import Client\nasync def main():\n    client = Client('example')\n    await client.connect('localhost')\n    client.publish('example/topic', 'hello', qos=0)\n    await client.disconnect()\nasyncio.run(main())\n",
      "asOf": "2026-11-20"
    },
    "F181": {
      "label": "Repository stars, gmqtt",
      "display": "454",
      "asOf": "2026-11-20"
    },
    "F182": {
      "label": "MQTT version five, gmqtt",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F183": {
      "label": "Embedded broker, gmqtt",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F184": {
      "label": "QoS level two, gmqtt",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F185": {
      "label": "Subscription options, gmqtt",
      "display": "MQTT5 Subscription objects support no_local and retain options",
      "asOf": "2026-11-20"
    },
    "F186": {
      "label": "Reconnect policy, gmqtt",
      "display": "Unlimited retries by default; disconnect stops retries",
      "asOf": "2026-11-20"
    },
    "F187": {
      "label": "Declared Python requirement, gmqtt",
      "display": ">=3.5",
      "asOf": "2026-11-20"
    },
    "F188": {
      "label": "Project function, gmqtt",
      "display": "def subscribe(\n    self,\n    *topics,\n    qos: int = 0,\n    no_local: bool = False,\n    retain_as_published: bool = False,\n    retain_handling_options: int = 0,\n    subscription_identifier: Any = None,\n) -> Callable[..., Any]:\n    \"\"\"\n    Decorator method used to subscribe for specific topics.\n\n    Topics are subscribed on every (re)connection. If the client is already\n    connected when the decorator runs, they are also subscribed right away.\n\n    Handlers get (client, topic, payload, qos, properties). If a handler has a\n    parameter typed as a pydantic model, the payload is parsed into that model instead,\n    and the other parameters are passed by name:\n\n        @mqtt.subscribe(\"sensors/+/temperature\")\n        async def temperature(item: Temperature, topic: str): ...\n    \"\"\"\n\n    def subscribe_handler(handler: MQTTMessageHandler) -> MQTTMessageHandler:\n        self._logger.debug(\"Subscribe for topics: %s\", topics)\n        message_handler = self._message_handler(handler)\n        for topic in topics:\n            if topic not in self.subscriptions:\n                subscription = Subscription(\n                    topic,\n                    qos,\n                    no_local,\n                    retain_as_published,\n                    retain_handling_options,\n                    subscription_identifier,\n                )\n                self.subscriptions[topic] = (subscription, [message_handler])\n            else:\n                # Use the most restrictive field of the same subscription\n                old_subscription, handlers = self.subscriptions[topic]\n                subscription = Subscription(\n                    topic,\n                    max(qos, old_subscription.qos),\n                    no_local or old_subscription.no_local,\n                    retain_as_published or old_subscription.retain_as_published,\n                    max(\n                        retain_handling_options,\n                        old_subscription.retain_handling_options,\n                    ),\n                    old_subscription.subscription_identifier or subscription_identifier,\n                )\n                handlers.append(message_handler)\n                self.subscriptions[topic] = (subscription, handlers)\n\n            if self.client.is_connected:\n                self._logger.debug(\"Already connected, subscribing for %s\", topic)\n                self.client.subscribe(subscription)\n        return handler\n\n    return subscribe_handler",
      "asOf": "2026-11-20"
    },
    "F189": {
      "label": "Project source file, gmqtt",
      "display": "fastapi_mqtt/fastmqtt.py",
      "asOf": "2026-11-20"
    },
    "F190": {
      "label": "Project full_name, gmqtt",
      "display": "sabuhish/fastapi-mqtt",
      "asOf": "2026-11-20"
    },
    "F191": {
      "label": "Project stargazers_count, gmqtt",
      "display": "387",
      "asOf": "2026-11-20"
    },
    "F192": {
      "label": "Library name, amqtt",
      "display": "aMQTT",
      "asOf": "2026-11-20"
    },
    "F193": {
      "label": "Monthly downloads, amqtt",
      "display": "92.8K",
      "asOf": "2026-11-20"
    },
    "F194": {
      "label": "License, amqtt",
      "display": "MIT",
      "asOf": "2026-11-20"
    },
    "F195": {
      "label": "Package release, amqtt",
      "display": "0.12.2",
      "asOf": "2026-11-20"
    },
    "F196": {
      "label": "Package release date, amqtt",
      "display": "Nov 2026",
      "asOf": "2026-11-20"
    },
    "F197": {
      "label": "Install, amqtt",
      "display": "python -m pip install amqtt",
      "asOf": "2026-11-20"
    },
    "F198": {
      "label": "Quickstart, amqtt",
      "display": "import asyncio\nfrom amqtt.client import MQTTClient\nasync def main():\n    client = MQTTClient()\n    await client.connect('mqtt://localhost/')\n    await client.publish('example/topic', b'hello', qos=0)\n    await client.disconnect()\nasyncio.run(main())\n",
      "asOf": "2026-11-20"
    },
    "F199": {
      "label": "Repository stars, amqtt",
      "display": "222",
      "asOf": "2026-11-20"
    },
    "F200": {
      "label": "MQTT version five, amqtt",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F201": {
      "label": "Embedded broker, amqtt",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F202": {
      "label": "QoS level two, amqtt",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F203": {
      "label": "Embedded deployment, amqtt",
      "display": "Async broker with configurable listeners and plugins",
      "asOf": "2026-11-20"
    },
    "F204": {
      "label": "Authentication, amqtt",
      "display": "Plugin framework for authentication and authorization",
      "asOf": "2026-11-20"
    },
    "F205": {
      "label": "Declared Python requirement, amqtt",
      "display": ">=3.10.0",
      "asOf": "2026-11-20"
    },
    "F206": {
      "label": "Library name, AWSIoTPythonSDK",
      "display": "AWSIoTPythonSDK",
      "asOf": "2026-11-20"
    },
    "F207": {
      "label": "Monthly downloads, AWSIoTPythonSDK",
      "display": "45.1K",
      "asOf": "2026-11-20"
    },
    "F208": {
      "label": "License, AWSIoTPythonSDK",
      "display": "Apache-2.0",
      "asOf": "2026-11-20"
    },
    "F209": {
      "label": "Package release, AWSIoTPythonSDK",
      "display": "1.6.2",
      "asOf": "2026-11-20"
    },
    "F210": {
      "label": "Package release date, AWSIoTPythonSDK",
      "display": "Oct 2026",
      "asOf": "2026-11-20"
    },
    "F211": {
      "label": "Install, AWSIoTPythonSDK",
      "display": "python -m pip install AWSIoTPythonSDK",
      "asOf": "2026-11-20"
    },
    "F212": {
      "label": "Quickstart, AWSIoTPythonSDK",
      "display": "from AWSIoTPythonSDK.MQTTLib import AWSIoTMQTTClient\nclient = AWSIoTMQTTClient('example')\nclient.configureEndpoint('YOUR_ENDPOINT', 8883)\nclient.configureCredentials('root-ca.pem', 'private.pem.key', 'device.pem.crt')\nclient.connect()\nclient.disconnect()\n",
      "asOf": "2026-11-20"
    },
    "F213": {
      "label": "Official description, AWSIoTPythonSDK",
      "display": "Connects Python applications to AWS IoT.",
      "asOf": "2026-11-20"
    },
    "F214": {
      "label": "Quickstart source file, AWSIoTPythonSDK",
      "display": "AWSIoTPythonSDK/MQTTLib.py public API",
      "asOf": "2026-11-20"
    },
    "F215": {
      "label": "Repository stars, AWSIoTPythonSDK",
      "display": "688",
      "asOf": "2026-11-20"
    },
    "F216": {
      "label": "MQTT version five, AWSIoTPythonSDK",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F217": {
      "label": "Embedded broker, AWSIoTPythonSDK",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F218": {
      "label": "QoS level two, AWSIoTPythonSDK",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F219": {
      "label": "Maintenance, AWSIoTPythonSDK",
      "display": "Security updates only; new v2 implementation available",
      "asOf": "2026-11-20"
    },
    "F220": {
      "label": "Runtime/API family, AWSIoTPythonSDK",
      "display": "Separate pure-Python v1 MQTT API",
      "asOf": "2026-11-20"
    },
    "F221": {
      "label": "Project function, AWSIoTPythonSDK",
      "display": "def setup():\n    root_ca_file = \"root-ca.pem\"\n\n    # Get the CA cert if we need it\n    if not path.exists(root_ca_file):\n        request = requests.get('https://www.amazontrust.com/repository/AmazonRootCA1.pem', allow_redirects=True)\n        open(root_ca_file, 'wb').write(request.content)\n\n    # Get the hostname for the customer's ATS endpoint in this region\n    iot_client = boto3.client('iot')\n    iot_data = iot_client.describe_endpoint(endpointType='iot:Data-ATS')\n    host = iot_data['endpointAddress']\n\n    # Get temporary credentials\n    sts_client = boto3.client('sts')\n    sts_data = sts_client.get_session_token()\n\n    # Extract the temporary credential values\n    credentials = sts_data['Credentials']\n    access_key_id = credentials['AccessKeyId']\n    secret_access_key = credentials['SecretAccessKey']\n    session_token = credentials['SessionToken']\n\n    # Create an MQTT client with a random client ID that uses WebSockets\n    mqtt_client = AWSIoTMQTTClient(str(uuid.uuid4()), useWebsocket=True)\n    # Use port 443 + ALPN on the customer's ATS endpoint\n    mqtt_client.configureEndpoint(host, 443)\n    # Explicitly enable the root CA we downloaded\n    mqtt_client.configureCredentials(root_ca_file)\n\n    # Configure the library to use the specified credentials instead of using another provider to fetch them\n    AWSIoTMQTTClient.configureIAMCredentials(mqtt_client, access_key_id, secret_access_key, session_token)\n\n    return mqtt_client",
      "asOf": "2026-11-20"
    },
    "F222": {
      "label": "Project source file, AWSIoTPythonSDK",
      "display": "tools/simple-pub-sub/shared.py",
      "asOf": "2026-11-20"
    },
    "F223": {
      "label": "Project full_name, AWSIoTPythonSDK",
      "display": "aws-iot-builder-tools/iot-reference-architectures",
      "asOf": "2026-11-20"
    },
    "F224": {
      "label": "Project stargazers_count, AWSIoTPythonSDK",
      "display": "108",
      "asOf": "2026-11-20"
    },
    "F225": {
      "label": "Library name, mqttools",
      "display": "mqttools",
      "asOf": "2026-11-20"
    },
    "F226": {
      "label": "Monthly downloads, mqttools",
      "display": "3.3K",
      "asOf": "2026-11-20"
    },
    "F227": {
      "label": "License, mqttools",
      "display": "MIT",
      "asOf": "2026-11-20"
    },
    "F228": {
      "label": "Package release, mqttools",
      "display": "0.50.0",
      "asOf": "2026-11-20"
    },
    "F229": {
      "label": "Package release date, mqttools",
      "display": "Dec 2021",
      "asOf": "2026-11-20"
    },
    "F230": {
      "label": "Install, mqttools",
      "display": "python -m pip install mqttools",
      "asOf": "2026-11-20"
    },
    "F231": {
      "label": "Quickstart, mqttools",
      "display": "import asyncio\nimport mqttools\nasync def publisher():\n    async with mqttools.Client('localhost', 1883) as client:\n        client.publish(mqttools.Message('/test/mqttools/foo', b'bar'))\nasyncio.run(publisher())\n",
      "asOf": "2026-11-20"
    },
    "F232": {
      "label": "Official description, mqttools",
      "display": "Provides MQTT tools.",
      "asOf": "2026-11-20"
    },
    "F233": {
      "label": "Quickstart source file, mqttools",
      "display": "README.rst: Scripting/Publish",
      "asOf": "2026-11-20"
    },
    "F234": {
      "label": "Repository stars, mqttools",
      "display": "66",
      "asOf": "2026-11-20"
    },
    "F235": {
      "label": "MQTT version five, mqttools",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F236": {
      "label": "Embedded broker, mqttools",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F237": {
      "label": "QoS level two, mqttools",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F238": {
      "label": "Delivery restriction, mqttools",
      "display": "MQTT5 but only QoS0",
      "asOf": "2026-11-20"
    },
    "F239": {
      "label": "Authentication, mqttools",
      "display": "Not supported",
      "asOf": "2026-11-20"
    }
  },
  "dataCheckedAt": "2026-11-20",
  "agent": {
    "exaCall": {
      "endpoint": "/search",
      "body": {
        "query": "Best Python MQTT libraries Paho aiomqtt gmqtt aMQTT publish subscribe code examples",
        "numResults": 5
      },
      "docsUrl": "https://exa.ai/docs/reference/search"
    },
    "calls": []
  }
}
