Skip to main content

A python API client for OPNsense

Project description

You can see the full rendered docs at:

A python API client for the OPNsense API. This provides a python interface for interacting with the OPNsense API.


pyopnsense is available via pypi so all you need to do is run:

pip install -U pyopnsense

to get the latest pyopnsense release on your system. If you need to use a development version of pyopnsense you can clone the repo and install it locally with:

git clone && pip install -e pyopnsense

which will install pyopnsense in your python environment in editable mode for development.


To use pyopnsense you need a couple pieces of information, the API key and the API secret. Both can be created/found from the OPNsense web UI by navigating to: System->Access->Users under API keys.

More information on this can be found in the OPNsense documentation:

Once you have the API key and API secret you can use pyopnsense to interact with your OPNsense installation. You can do this by passing your credentials to a client class. For example:

from pyopnsense import diagnostics

api_key = XXXXXX
opnsense_url ='

netinsight_client = diagnostics.NetworkInsightClient(api_key, api_secret,

which will print a dictionary mapping physical devices to their interface label.

This same formula can be used to access each individual API endpoint you need to access. The basic structure of the library is setup to roughly mirror the endpoint tree of the OPNsense API. Each client module maps to the base endpoint and then there is a client class in those modules for the next level up off that.

You can find more detail on how to use the clients in the API reference documentation found here:

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyopnsense-0.1.0.tar.gz (21.5 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page