py-multicodec
Multicodec implementation in Python
What it is and what it does
py-multicodec is a Python implementation of the Multicodec specification, a self-describing multiformat standard that wraps data with a tiny varint-encoded header identifying the codec used. The library lets you add codec prefixes to binary data, extract those prefixes, and look up which codec was used—all grounded in a table of supported codecs maintained from the upstream multiformats specification.
The package provides both simple prefix operations (add_prefix, remove_prefix, get_codec) and type-safe codec management through named Code constants and a known_codes registry. It supports modern Python versions (3.10 through 3.14) and depends only on varint for encoding/decoding the multicodec identifiers. The library is commonly used in IPFS and IPLD ecosystems where content addressing and format identification are critical.
Use it for:
- Tag binary data with codec identifiers in IPFS/IPLD applications to enable format-agnostic content addressing.
- Decode multicodec-prefixed data to identify the underlying format before processing.
- Build type-safe codec handling in systems that work with multiple serialization formats (CBOR, JSON, Protocol Buffers).
- Maintain a canonical reference of supported multicodec codes in a Python application.
- Wrap custom or domain-specific data formats with standard multicodec headers for interoperability.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Wraps data with self-describing multicodec prefixes, enabling format identification and codec lookup from varint-encoded headers.
Yes, if you work with IPFS, IPLD, or other multiformats ecosystems. The package is stable (Production/Stable classifier), has no known vulnerabilities, and installs with minimal friction. Maintenance is aging (239 days since last release), but the repository is active and the API is mature. Install it for multicodec prefix operations; avoid it if you have no need for format-agnostic codec tagging.
Install
py-multicodec on PyPI
pip
pip install py-multicodecuv
uv add py-multicodecpoetry
poetry add py-multicodecInstalling py-multicodec
Before you install
Low friction install with a single runtime dependency (varint). Last release was recent; repository is active and not archived, though maintenance status is aging with 239 days since last release.
License in practice
MIT license permits commercial and private use with minimal restrictions—suitable for most projects.
Quickstart
pip install py-multicodec
from multicodec import add_prefix, remove_prefix, get_codec
# Add codec prefix to data
prefixed = add_prefix('sha2-256', b'EiC5TSe5k00')
# Retrieve codec name from prefixed data
codec_name = get_codec(prefixed)
Requires Python 3.10 or later.
Verify before relying
- Whether the 460 known codecs listed in the description are current as of the latest release.
- Performance characteristics when handling large batches of codec operations.
- Stability guarantees for the multicodec table updates and backward compatibility across versions.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (<4.0,>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — varint |
| Maintenance | aging — 239 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 174,588/month — #10,279 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: py_multicodec-1.0.0-py3-none-any.whl
Keywords: multicodec, multiformats, CID, IPFS, IPLD
Tags
More Internet packages
Botocore provides low-level, data-driven access…
permissive · top 100 on PyPI
aiobotocoreProvides an async client for AWS services using…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
filelockProvides a platform-independent file locking…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
googleapis-common-protosProvides common Protocol Buffer message…
permissive · top 100 on PyPI
py-cidpy-cid encodes and decodes CIDs (Content…
permissive · top 15,000 on PyPI
py-multibaseEncodes and decodes data using the Multibase…
permissive · top 15,000 on PyPI
multiaddrParses, constructs, and manipulates…
permissive · top 15,000 on PyPI
rlpEncodes and decodes data using Recursive Length…
permissive · top 5,000 on PyPI
eth-rlpProvides RLP (Recursive Length Prefix) encoding…
permissive · top 5,000 on PyPI
prefixedPrefixed provides a Float subclass that formats…
copyleft · top 5,000 on PyPI
scalecodecEncodes and decodes data using the SCALE codec,…
permissive · top 15,000 on PyPI
mbstrdecoderDecodes multi-byte character strings by…
permissive · top 5,000 on PyPI
numcodecsNumcodecs provides buffer compression and…
permissive · top 5,000 on PyPI