Registry / serialization / py-multibase

py-multibase

JSON →
library2.0.0pypypi✓ verified 87d ago

py-multibase is a Python library that provides an implementation of the Multibase protocol. Multibase is designed to distinguish base encodings (like base64, base58btc, etc.) and other simple string encodings, ensuring compatibility across different systems by making the encoding self-describing. The library is currently at version 2.0.0 and is actively maintained, facilitating encoding and decoding of data with various Multibase formats.

pip install py-multibase
INSTALL
IMPORT
SIG · PY-MULTIBASE
P
py-multibase
serializationpythonv2.0.0
Install
2.6s avg
Import
7ms
Disk
17MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.0.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.003s · 19.4MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 2.6s · import 0.000s · 20MB
17MB installed
● package 17MB
Code
Verified usage

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

encode, decode
from multibase import encode, decode
Encoder, Decoder
from multibase import Encoder, Decoder
get_encoding_info, list_encodings
from multibase import get_encoding_info, list_encodings

This quickstart demonstrates how to encode and decode data using various multibase formats, including `base58btc` and `base64`. It also shows the use of reusable `Encoder` and `Decoder` classes for multiple operations and how to list supported encodings. Remember that `encode` takes `str` or `bytes` and `decode` returns `bytes`, so you might need to convert to `str` for printing.

from multibase import encode, decode, list_encodings # Encode a string to base58btc data_to_encode = 'hello world' encoded_base58 = encode('base58btc', data_to_encode) print(f"Encoded (base58btc): {encoded_base58}") # Encode a string to base64 encoded_base64 = encode('base64', data_to_encode) print(f"Encoded (base64): {encoded_base64}") # Decode a multibase string decoded_data = decode(encoded_base64) print(f"Decoded: {decoded_data.decode('utf-8')}") # Using reusable Encoder/Decoder classes from multibase import Encoder, Decoder base64_encoder = Encoder('base64') encoded_reusable = base64_encoder.encode(b'reusable data') print(f"Encoded (reusable base64): {encoded_reusable}") decoder = Decoder() decoded_reusable = decoder.decode(encoded_reusable) print(f"Decoded (reusable): {decoded_reusable.decode('utf-8')}") # List available encodings # print(list_encodings())
Debug
Known issues
breakingVersion 2.0.0 and higher of `py-multibase` requires Python 3.10 or newer. Users on older Python versions (e.g., 3.9 or earlier) must remain on `py-multibase` 1.x or upgrade their Python interpreter.
fix
Upgrade Python to 3.10+ or pin `py-multibase` to a 1.x release: `pip install 'py-multibase<2.0.0'`
affects: <2.0.0
gotchaNot all multibase encodings from the official specification may be fully implemented in `py-multibase` 2.0.0. GitHub issues indicate ongoing work to achieve 100% compatibility with reference implementations. Verify support for specific or less common encodings if they are critical to your application.
fix
Consult the `py-multibase` GitHub repository or documentation for the most up-to-date list of supported encodings. Consider contributing or using alternative libraries for unsupported formats.
affects: 2.0.0
gotchaThe `encode` function can accept both string and bytes input, but `decode` always returns `bytes`. Attempting to treat `bytes` output directly as a Python `str` without explicit decoding (e.g., `.decode('utf-8')`) will lead to `TypeError` or unexpected behavior.
fix
Ensure proper type handling: encode strings to bytes before passing to `encode` if implicit conversion isn't desired, and always `decode()` the output of `multibase.decode` if a `str` is required.
affects: All
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'multibase'
The `py-multibase` library is either not installed or not available in the current Python environment.
fix
Install the library using pip: `pip install py-multibase`
TypeError: a bytes-like object is required, not 'str'
You are passing a Python string to a function (e.g., `multibase.encode`) that expects `bytes` or a bytes-like object, without explicitly encoding the string first.
fix
Convert your string to bytes before passing it to the function: `my_string.encode('utf-8')`. Example: `encode('base64', 'hello world'.encode('utf-8'))` or ensure the function handles string input if it's designed to.
ValueError: Unknown multibase encoding: 'some_invalid_base'
The specified multibase encoding (e.g., 'some_invalid_base') is not recognized or supported by the library.
fix
Use a valid multibase name as defined in the Multibase specification and supported by `py-multibase`. You can use `multibase.list_encodings()` to see all supported options.
Upgrade
Version history
2.0.0latest on PyPI · released Dec 18, 2025
Audit
Dependencies
basesrequiredProvides core base encoding implementations used by multibase.
Agent activity
10 hits · last 30 days
node
10
Resources
py-multibase — pip install py-multibase · libregistry