pyangbind
PyangBind is a plugin for pyang which converts YANG data models into a Python class hierarchy, such that Python can be used to manipulate data that conforms with a YANG model.
What it is and what it does
PyangBind is the runtime library that powers YANG-to-Python code generation. When you use the pyang plugin to convert a YANG network model into Python classes, those generated classes inherit from and rely on PyangBind's base classes and utility functions. The package provides the foundational infrastructure: a base class for all YANG containers and modules, JSON serialization and deserialization, XPATH-based object lookup, and type wrappers that enforce YANG constraints like ranges, patterns, and restricted decimal precision.
You typically use PyangBind indirectly—by installing it alongside pyang, running pyang's code generator on your YANG files, and then importing the generated Python modules. The generated code uses PyangBind's classes and helpers to validate data, convert between Python objects and JSON, and query object hierarchies. It's essential for anyone building network configuration management tools, device simulators, or data-driven applications that work with YANG-modeled network state.
Use it for:
- Generate Python APIs from YANG network models and use PyangBind to serialize/deserialize configuration to JSON for REST APIs.
- Build network device simulators or test harnesses that validate configuration against YANG constraints using generated PyangBind classes.
- Query and manipulate complex network state hierarchies using XPATH expressions through YANGPathHelper.
- Enforce YANG type restrictions (ranges, patterns, decimal precision) on Python objects without manual validation code.
- Migrate or translate network configuration between formats by loading JSON into YANG-derived classes and exporting to other formats.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
PyangBind converts YANG data models into Python class hierarchies, allowing you to manipulate YANG-modeled data programmatically through Python objects with built-in serialization, validation, and XPATH lookup support.
Yes. PyangBind is actively maintained, has no known vulnerabilities, installs with low friction, and is essential infrastructure for anyone using pyang to generate Python bindings from YANG models. The Apache 2.0 license is permissive. Install it as a dependency when you need runtime support for YANG-derived Python classes.
Install
pyangbind on PyPI
pip
pip install pyangbinduv
uv add pyangbindpoetry
poetry add pyangbindInstalling pyangbind
Before you install
Low friction: pure Python wheel with four straightforward runtime dependencies (pyang, lxml, regex, enum34). Actively maintained with a recent release and no known vulnerabilities.
License in practice
Apache License 2.0 is permissive; you can use, modify, and distribute this package freely in commercial or open-source projects with minimal restrictions.
Quickstart
pip install pyangbind
from pyangbind.base import PybindBase
from pyangbind.serialise import pybindJSONEncoder
import json
# Use generated YANG-derived classes to build and serialize data
data = YourYANGGeneratedClass()
json_output = json.dumps(data, cls=pybindJSONEncoder)
Requires pyang to have already generated Python classes from your YANG models; this package provides the runtime support for those generated classes, not the generation itself.
Verify before relying
- Whether enum34 is actually needed for Python 3.8+ (enum is built-in since 3.4)
- Performance characteristics when working with large or deeply nested YANG models
- Completeness of YANG type coverage (e.g., all YANG 1.1 types, extension handling)
Package facts
| License | Apache License, Version 2.0 (permissive) |
| Python support | supports the current Python release (>=3.7) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 4 — pyang, lxml, regex, enum34 |
| Maintenance | actively maintained — 247 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 380,891/month — #7,100 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pyangbind-0.8.7-py3-none-any.whl
Keywords: yang, pyang
Tags
More Code Generators packages
Proto Plus wraps protocol buffers to provide…
permissive · top 1,000 on PyPI
CythonCython is a source code translator that…
permissive · top 1,000 on PyPI
asttokensAnnotates Python abstract syntax trees with the…
permissive · top 1,000 on PyPI
beartypeBeartype is a runtime type checker that…
permissive · top 1,000 on PyPI
llvmlitellvmlite provides a lightweight Python binding…
permissive · top 1,000 on PyPI
astorastor converts Python abstract syntax trees…
permissive · top 5,000 on PyPI
pyangpyang validates YANG data models (RFC 7950),…
permissive · top 15,000 on PyPI
yang.connectorProvides NETCONF and gRPC/GNMI client…
permissive · top 15,000 on PyPI
xml-pythonConverts XML documents into Python objects,…
copyleft · top 5,000 on PyPI
pydantic-xmlPydantic-xml adds XML serialization and…
permissive · top 5,000 on PyPI
dynamic-yamlAdds dynamic string interpolation to YAML…
permissive · top 15,000 on PyPI
py-ubjsonEncodes and decodes data in Universal Binary…
permissive · top 5,000 on PyPI
json-encoderProvides JSON serialization with…
unclear · top 15,000 on PyPI
numpyencoderProvides a custom JSON encoder class that…
permissive · top 15,000 on PyPI
hjsonParses and generates Hjson (a human-friendly…
permissive · top 5,000 on PyPI
simplejsonsimplejson encodes Python objects to JSON and…
permissive · top 1,000 on PyPI