SSDP (Simple Service Discovery Protocol)

raw JSON →
1.3.1 verified Mon Apr 27 auth: no python

Python asyncio library for Simple Service Discovery Protocol (SSDP). Supports both client and server roles, enabling discovery and advertisement of network services. Current version 1.3.1, released under MIT license. Active development with asyncio-native design.

pip install ssdp
error AttributeError: module 'ssdp' has no attribute 'SSDPClient'
cause Outdated library version (<1.0.0) where API names differ.
fix
Upgrade to latest: pip install --upgrade ssdp
error RuntimeError: This event loop is already running
cause Calling asyncio.run(discover()) inside a running event loop (e.g., Jupyter notebook).
fix
Use await discover() directly or nest in another async function.
breaking Version 1.3.0 removed the old synchronous API. All functionality now requires asyncio.
fix Use async/await pattern. Wrap code in asyncio.run() if needed.
gotcha SSDPClient/SSDPServer must be used as async context managers or have start()/close() called explicitly.
fix Use 'async with client:' or call await client.start() and await client.close().
gotcha The library does not support multicast loopback by default, so discovery may not see services on the same host.
fix Set loopback=True in SSDPClient constructor to enable.

Discover UPnP devices on the network.

import asyncio
from ssdp import SSDPClient

async def discover():
    client = SSDPClient()
    async with client:
        services = await client.discover(st='upnp:rootdevice', mx=3)
        for service in services:
            print(f'Location: {service.location}')

asyncio.run(discover())