Registry / http-networking / multiaddr

multiaddr

JSON →
library0.2.0pypypi✓ verified 85d ago

Multiaddr is a Python library that provides an implementation of jbenet's multiaddr specification, designed for future-proof, composable, and efficient network addresses. It aims to solve ambiguities in traditional network addressing by making addresses self-describing, specifying both protocol and network address. The library supports various protocols like IPv4, IPv6, TCP, UDP, DNS, and more, offering both human-readable and machine-readable representations. It is currently at version 0.2.0 and receives active development and releases.

pip install multiaddr
INSTALL
IMPORT
SIG · MULTIADDR
M
multiaddr
http-networkingpythonv0.2.0
Install
5.0s avg
Import
33ms
Disk
39MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.2.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.035s · 43MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 5.0s · import 0.031s · 43MB
39MB installed
● package 39MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Multiaddr
from multiaddr import Multiaddr

This quickstart demonstrates how to create Multiaddr instances from strings and bytes, retrieve the list of protocols, and perform encapsulation and decapsulation operations, which are core functionalities of the library.

from multiaddr import Multiaddr # Construct a Multiaddr from a string addr_str = "/ip4/127.0.0.1/tcp/8080" m1 = Multiaddr(addr_str) print(f"Multiaddr from string: {m1}") print(f"Protocols: {[p.name for p in m1.protocols()]}") # Construct from bytes m2 = Multiaddr(m1.to_bytes()) print(f"Multiaddr from bytes: {m2}") # Encapsulate another Multiaddr websocket_addr = Multiaddr("/ws") encapsulated_addr = m1.encapsulate(websocket_addr) print(f"Encapsulated Multiaddr: {encapsulated_addr}") # Decapsulate a protocol decapsulated_addr = encapsulated_addr.decapsulate(websocket_addr) print(f"Decapsulated Multiaddr: {decapsulated_addr}") assert str(m1) == str(decapsulated_addr)
Debug
Known issues
breakingSupport for Python versions prior to 3.10 was dropped starting from version 0.0.10. Attempting to use `multiaddr` on older Python environments (e.g., Python 3.4-3.9) will result in incompatibility errors.
fix
Upgrade your Python environment to version 3.10 or newer. The current PyPI release explicitly requires Python >=3.10 and <4.0.
affects: >=0.0.10
deprecatedThe `bytes_addr` keyword argument for `Multiaddr` constructor when creating an instance from bytes is deprecated. Instead of `Multiaddr(bytes_addr=some_bytes)`, pass the bytes directly: `Multiaddr(some_bytes)`.
fix
Remove the `bytes_addr=` keyword when initializing `Multiaddr` from a byte string, i.e., use `Multiaddr(my_bytes)` instead of `Multiaddr(bytes_addr=my_bytes)`.
affects: All versions up to 0.2.0
gotchaAsynchronous DNS resolution (via the DNSADDR protocol) requires the optional `trio` library. If you intend to use this feature, ensure `trio` is installed alongside `multiaddr`. Without it, attempts to resolve DNS-based multiaddrs might fail or lack async capabilities.
fix
Install `trio` explicitly if you need async DNS resolution: `pip install multiaddr[full]` or `pip install trio`.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'multiaddr'
The 'multiaddr' package is not installed in your Python environment or the Python interpreter being used does not have access to it.
fix
Install the package using pip: `pip install multiaddr`
ValueError: Invalid address type, must be bytes or str
The `Multiaddr` constructor was called without either a `string_addr` or `bytes_addr` argument, or with both, when only one is permitted.
fix
Provide exactly one of `string_addr` (a string) or `bytes_addr` (bytes) to the `Multiaddr` constructor. Example: `m = Multiaddr('/ip4/127.0.0.1/tcp/8080')` or `m = Multiaddr(bytes_addr=b'\x04\x7f\x00\x00\x01\x06\x1f\x90')`
multiaddr.protocols.ProtocolNotFoundException: No protocol with code <some_code>
The multiaddr string being parsed contains a protocol code that is not recognized or supported by the `multiaddr` library's current version.
fix
Ensure the multiaddr string uses standard and supported protocols. If using a custom or newer protocol, check for library updates or verify the protocol's definition.
Error: invalid multiaddr: /some/invalid/address
The string provided to the `Multiaddr` constructor does not conform to the multiaddr specification, often due to incorrect formatting, unknown protocols, or invalid values for a protocol.
fix
Review the multiaddr string for correct syntax and valid protocol values. Refer to the multiaddr specification for proper formatting, e.g., `/ip4/127.0.0.1/tcp/8080`.
Upgrade
Version history
0.2.0latest on PyPI · released Mar 17, 2026
Audit
Dependencies
pythonrequiredRequired Python runtime version.
triooptionalRequired for asynchronous DNS resolution via the DNSADDR protocol.
Agent activity
8 hits · last 30 days
node
6
Resources
multiaddr — pip install multiaddr · libregistry