Pyfsense Client is a Python API client for pfSense API endpoints provided by the package at https://github.com/jaredhendrickson13/pfsense-api.
This repository is a rewrite of the code at https://github.com/yaleman/pfsense-api-client.
This code is currently being tested against pfSense 24.03 and the v1.7.6 API endpoints.
Project is under development and likely will not have working methods for all endpoints.
All the integration tests copied from yaleman don't work, and many endpoints that I don't personally use have not been tested. Writing mocked tests for all the endpoints is a large task and is unlikely to be finished considering the API has been recently upgraded to version 2. It makes more sense to transition this project to using version 2 endpoints and write tests for those instead.
Technically this library supports all authentication methods, but we are only testing with API token.
config_data = {
"hostname": "example.com",
"mode": "api_token",
"client_id": "3490580384",
"client_token": "3495739084",
"verify_ssl": False,
}
config = ClientConfig(**config_data)
client = PFSenseAPIClient(config=config)
Support exists for passing credentials as a JSON file.
{
"username" : "me",
"password" : "mysupersecretpassword",
"hostname" : "example.com",
"port" : 8443
}
Pass verify_ssl=False
into the config to disable SSL checking.
You can build a docker image of the source code using docker compose. This will install all the dependencies from the requirements file and volume mount the code for development.
docker compose -f local.yml build
You can run the unit tests with:
docker compose -f local.yml up