An unofficial Python 3 client for the OpenNMS REST API (Horizon 35+)
Project description
opennms-api-wrapper
An unofficial, dependency-minimal Python 3 client for the OpenNMS REST API (Horizon 35+). Read-only smoke test validated against OpenNMS Meridian 2024.3.0.
OpenNMS resources: Docs · REST API reference · Community forum
Features
- Covers every v1 (
/opennms/rest/) and v2 (/opennms/api/v2/) endpoint - JSON everywhere — no XML handling required
- Single runtime dependency:
requests - Synchronous and straightforward — no async complexity
TypedDictschemas for all write payloads — field names, types, and docs in your IDE- Typed exception hierarchy — catch
NotFoundError,ForbiddenError, etc. without importingrequests - Pagination helper —
client.paginate()yields all items from any list endpoint automatically - Full test suite with method coverage (mocked HTTP — no live server required)
- Read-only smoke test validated against Meridian 2024.3.0 (write mode untested live)
Installation
pip install opennms-api-wrapper
From source (latest development version):
git clone https://github.com/cnewkirk/opennms-api-wrapper.git
cd opennms-api-wrapper
pip install .
Quick start
import opennms_api_wrapper as opennms
client = opennms.OpenNMS(
url="https://opennms.example.com:8443",
username="admin",
password="admin",
)
# Server info
info = client.get_info()
print(info["displayVersion"])
# List alarms
alarms = client.get_alarms(limit=25, order_by="lastEventTime", order="desc")
for alarm in alarms["alarm"]:
print(alarm["id"], alarm["severity"], alarm["nodeLabel"])
# Acknowledge an alarm
client.ack_alarm(alarm_id=42)
# List alarms with FIQL filter (v2)
alarms = client.get_alarms_v2(fiql="severity==MAJOR")
Error handling
HTTP errors raise typed exceptions — no need to import requests:
import opennms_api_wrapper as opennms
try:
node = client.get_node(99999)
except opennms.NotFoundError:
print("Node does not exist")
except opennms.ForbiddenError:
print("Insufficient permissions")
except opennms.AuthenticationError:
print("Check your credentials")
except opennms.OpenNMSError:
print("Unexpected error")
Full hierarchy: OpenNMSHTTPError (base, exposes .status_code and
.response) → BadRequestError (400), AuthenticationError (401),
ForbiddenError (403), NotFoundError (404), ConflictError (409),
ServerError (5xx).
Pagination
client.paginate() transparently handles limit/offset pagination and
yields individual items:
# Fetch every MAJOR alarm — no manual offset loop required
for alarm in client.paginate(client.get_alarms, "alarm", severity="MAJOR"):
print(alarm["id"], alarm["nodeLabel"])
# Works with any list endpoint
for node in client.paginate(client.get_nodes, "node"):
print(node["id"], node["label"])
The optional page_size argument (default 100) controls how many items are
fetched per request.
API coverage
| Resource group | Methods |
|---|---|
| Alarms (v1 + v2) | list, get, count, ack/unack/clear/escalate, bulk ops |
| Alarm statistics | stats, stats by severity |
| Alarm history | history, history at timestamp, state changes |
| Events | list, get, count, create, ack/unack, bulk ack/unack |
| Nodes | full CRUD + IP interfaces, SNMP interfaces, services, categories, assets, hardware |
| Outages | list, get, count, node outages |
| Notifications | list, get, count, trigger destination path |
| Acknowledgements | list, get, count, create, ack/unack notification |
| Requisitions | full CRUD including nodes, interfaces, services, categories, assets |
| Foreign sources | full CRUD including detectors and policies |
| SNMP configuration | get, set |
| Groups | full CRUD + user and category membership |
| Users | full CRUD + role assignment |
| Categories | full CRUD + node and group associations |
| Scheduled outages | full CRUD + daemon associations |
| KSC reports | list, get, count, create, update |
| Resources | list, get, get for node, select, delete |
| Measurements | single attribute (GET), multi-source (POST) |
| Heatmap | outages + alarms × categories / foreign sources / services / nodes |
| Maps | full CRUD + map elements |
| Topology graphs | containers, graph, graph view (POST), search suggestions, search results |
| Flows | count, exporters, applications, conversations, hosts |
| Device configuration | list, get, get by interface, latest, download, backup |
| Situations (v2) | list, create, add alarms, clear, accept, remove alarms |
| Business services (v2) | full CRUD |
| Metadata (v2) | full CRUD for node, interface, and service metadata |
| Server info | get |
| Discovery (v2) | submit scan configuration |
| IP interfaces (v2) | list with FIQL |
| SNMP interfaces (v2) | list with FIQL |
| EnLinkd (v2) | aggregate, LLDP/CDP/OSPF/IS-IS/Bridge links and elements |
| Monitoring locations | list, get, default, count, create, update, delete |
| Minions | list, get, count |
| If services | list (v1), update (v1), list with FIQL (v2) |
| Availability | summary, by category, by node, per-category-node |
| Health | health check, probe |
| Whoami | current user info |
| Classifications | rules CRUD, groups CRUD, classify, protocols, CSV import |
| Situation feedback | tags, get/submit feedback |
| User-defined links (v2) | list, get, create, delete |
| Applications (v2) | list, get, create, delete |
| Perspective poller (v2) | application status, service status |
| Foreign sources config | policies, detectors, services, assets, categories |
| Requisition names | list all names |
| SNMP metadata (v2) | get by node |
| Provisiond (v2) | daemon status, job status |
| Event configuration (v2) | filter, sources, CRUD, upload, enable/disable, vendors |
| Monitoring systems | main system info |
| Asset suggestions | field suggestions |
| Secure credentials vault | full CRUD |
| Configuration management | names, schemas, config CRUD, sub-parts |
| SNMP trap NBI config | config, status, trap sink CRUD |
| Email NBI config | config, status, destination CRUD |
| Syslog NBI config | config, status, destination CRUD |
| Javamail config | defaults, readmails/sendmails/end2ends CRUD |
Authentication
Basic authentication is used. Pass verify_ssl=False to disable certificate
verification (useful for self-signed certs in lab environments):
client = opennms.OpenNMS(
url="https://opennms.example.com:8443",
username="admin",
password="admin",
verify_ssl=False,
)
Smoke testing
smoke_test.py exercises the wrapper against a real OpenNMS server. It is
intended for use against a dev or staging instance before each release — not
as a substitute for the mocked unit suite.
Tests that depend on optional plugins or heavy endpoints are reported as WARN (non-fatal) rather than FAIL. Each warning includes the specific plugin or feature required.
Read-only mode (default) is safe to run against any server, including production. It issues only GET requests and makes no changes.
export OPENNMS_URL="https://opennms.example.com:8443"
export OPENNMS_USER="admin"
export OPENNMS_PASSWORD="secret"
export OPENNMS_VERIFY_SSL="false" # omit or set to "true" for valid certs
export OPENNMS_TIMEOUT="60" # per-request timeout in seconds (default 60)
python smoke_test.py
Write mode creates and then deletes objects on the server (events, categories, groups, requisitions, maps, etc.). It will prompt for explicit confirmation and print the target URL before running a single write. Only use write mode against a dev or staging instance — never production. Write mode has not yet been validated against a live server — reports and contributions welcome.
python smoke_test.py --write # interactive prompt required
python smoke_test.py --write --yes # skip prompt (CI pipelines only)
python smoke_test.py --no-color # plain output for log files
python smoke_test.py --skip get_resources,get_flow # skip slow tests
The --skip flag accepts a prefix — --skip get_flow skips all tests
whose label starts with get_flow.
Development
git clone https://github.com/cnewkirk/opennms-api-wrapper.git
cd opennms-api-wrapper
python3 -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"
pytest tests/ -v
Contributing
Bug reports and pull requests are welcome on GitHub.
Acknowledgements
This library was designed and tested by a human, with implementation assistance from Claude Code (Anthropic). All API shapes are derived from the official OpenNMS Horizon 35 REST API documentation.
requests handles all HTTP communication. MkDocs Material renders the documentation site.
GitHub, Read the Docs, and PyPI generously provide source hosting, CI, versioned docs, and package distribution free of charge for open source projects.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file opennms_api_wrapper-0.4.4.tar.gz.
File metadata
- Download URL: opennms_api_wrapper-0.4.4.tar.gz
- Upload date:
- Size: 79.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c20fdc33ae3ed7977e2e1d9359620ec6ac7341cb49325bcd6eed4b74351d9d41
|
|
| MD5 |
80f4d62a33834328efd25a25a328331a
|
|
| BLAKE2b-256 |
c4122231c0cb18f747b4b3df4f2cfa8f8f7608367f933d132d94e5db0ffb98fd
|
Provenance
The following attestation bundles were made for opennms_api_wrapper-0.4.4.tar.gz:
Publisher:
publish.yml on cnewkirk/opennms-api-wrapper
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
opennms_api_wrapper-0.4.4.tar.gz -
Subject digest:
c20fdc33ae3ed7977e2e1d9359620ec6ac7341cb49325bcd6eed4b74351d9d41 - Sigstore transparency entry: 1059486642
- Sigstore integration time:
-
Permalink:
cnewkirk/opennms-api-wrapper@145db03a1d2285b64f1b4b6a84443fdc889416af -
Branch / Tag:
refs/tags/v0.4.4 - Owner: https://github.com/cnewkirk
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@145db03a1d2285b64f1b4b6a84443fdc889416af -
Trigger Event:
release
-
Statement type:
File details
Details for the file opennms_api_wrapper-0.4.4-py3-none-any.whl.
File metadata
- Download URL: opennms_api_wrapper-0.4.4-py3-none-any.whl
- Upload date:
- Size: 67.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f2862b57d77cf4af0c45a913ce3b70925ab661551833ba6182edcf10965d7f88
|
|
| MD5 |
9147073716ccc4f802558640fc5d694a
|
|
| BLAKE2b-256 |
546c4cd4092d46d50af51de7edd26a5a3fe7168fa1ecec605f046dc5b068066d
|
Provenance
The following attestation bundles were made for opennms_api_wrapper-0.4.4-py3-none-any.whl:
Publisher:
publish.yml on cnewkirk/opennms-api-wrapper
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
opennms_api_wrapper-0.4.4-py3-none-any.whl -
Subject digest:
f2862b57d77cf4af0c45a913ce3b70925ab661551833ba6182edcf10965d7f88 - Sigstore transparency entry: 1059486645
- Sigstore integration time:
-
Permalink:
cnewkirk/opennms-api-wrapper@145db03a1d2285b64f1b4b6a84443fdc889416af -
Branch / Tag:
refs/tags/v0.4.4 - Owner: https://github.com/cnewkirk
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@145db03a1d2285b64f1b4b6a84443fdc889416af -
Trigger Event:
release
-
Statement type: