skillfed

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.

pyangbind v0.8.7 380.9K downloads/30d#7,100 on PyPI216
Permissive license Apache License, Version 2.0 Active released

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 pyangbind

uv

uv add pyangbind

poetry

poetry add pyangbind

Installing 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

Development Status :: 4 - BetaIntended Audience :: DevelopersIntended Audience :: Telecommunications IndustryLicense :: OSI Approved :: Apache Software LicenseProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: Software Development :: Code Generators

Tags

YANG model to Python classesYANG data model bindingpyang Python pluginYANG JSON serializationnetwork configuration modelingYANG schema validation
yang-modelingnetwork-configcode-generation

More Code Generators packages