Skip to main content

Python implementation of jbenet's multiaddr

Project description

py-multiaddr Documentation Status
multiaddr implementation in Python



from multiaddr import Multiaddr

# construct from a string
m1 = Multiaddr("/ip4/")

# construct from bytes
m2 = Multiaddr(bytes_addr=m1.to_bytes())

assert str(m1) == "/ip4/"
assert str(m1) == str(m2)
assert m1.to_bytes() == m2.to_bytes()
assert m1 == m2
assert m2 == m1
assert not (m1 != m2)
assert not (m2 != m1)


from multiaddr import Multiaddr

m1 = Multiaddr("/ip4/")

# get the multiaddr protocol description objects
# [Protocol(code=4, name='ip4', size=32), Protocol(code=17, name='udp', size=16)]


from multiaddr import Multiaddr

m1 = Multiaddr("/ip4/")
# <Multiaddr /ip4/>
# <Multiaddr /ip4/>


Multiaddr allows expressing tunnels very nicely.

printer = Multiaddr("/ip4/")
proxy = Multiaddr("/ip4/")
printerOverProxy = proxy.encapsulate(printer)
# /ip4/

proxyAgain = printerOverProxy.decapsulate(printer)
# /ip4/


Original author: @sbuss.


Contributions welcome. Please check out the issues.

Check out our contributing document for more information on how we work, and about contributing in general. Please be aware that all interactions related to multiformats are subject to the IPFS Code of Conduct.




0.0.7 (2019-5-8)

  • include subpackage
  • refactor util and codec

0.0.5 (2019-5-7)

  • unhexilified bytes
  • new exceptions
  • miscellaneous improvements [via alexander255 #42]

0.0.2 (2016-5-4)

  • Fix a bug in decapsulate that threw an IndexError instead of a copy of the Multiaddr when the original multiaddr does not contain the multiaddr to decapsulate. [via fredthomsen #9]
  • Increase test coverage [via fredthomsen #9]

0.0.1 (2016-1-22)

  • First release on PyPI.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for multiaddr, version 0.0.9
Filename, size File type Python version Upload date Hashes
Filename, size multiaddr-0.0.9.tar.gz (24.7 kB) File type Source Python version None Upload date Hashes View
Filename, size multiaddr-0.0.9-py2.py3-none-any.whl (16.3 kB) File type Wheel Python version py2.py3 Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page