Skip to main content

Python API Overview

NSB's Python client library provides the NSBAppClient and NSBSimClient interfaces for integrating applications and network simulators.

Installationโ€‹

Copy the contents of the python/ directory (including the proto/ subdirectory) to your Python project:

your_project/
โ”œโ”€โ”€ nsb_client.py
โ”œโ”€โ”€ proto/
โ”‚ โ””โ”€โ”€ proto/
โ”‚ โ””โ”€โ”€ nsb_pb2.py
โ””โ”€โ”€ your_code.py

Or install in development mode:

cd python/
pip install -e .
echo 'export PYTHONPATH="${PYTHONPATH}:/path/to/nsb/python"' >> ~/.zshrc

Install Python dependencies:

pip install -r python/requirements.txt

For the full installation walkthrough (system prerequisites, build steps, verification), see Get Started.

Importโ€‹

import nsb_client as nsb

Reference Pagesโ€‹

PageCovers
MessageEntryThe object returned by receive(), fetch(), and listen()
NSBAppClientsend(), receive(), listen() โ€” the application-side client
NSBSimClientfetch(), post(), listen() โ€” the simulator-side client
Async ListenersFull asyncio pattern, test files, and Doxygen generation