HE
hermanwjacobsen/hfortix
Python client library for Fortinet FortiOS REST API automation
HFortix
HFortix is the meta-package that installs all HFortix components for Fortinet automation. Install this package to get the complete suite of tools for FortiOS/FortiGate automation.
๐ Quick Start
pip install hfortixThis single command installs:
hfortix-core- Core infrastructure and utilitieshfortix-fortios- FortiOS/FortiGate API client
from hfortix_fortios import FortiOS
# Connect to your FortiGate
with FortiOS(host="192.168.1.99", token="your-api-token") as fgt:
# Get system status
status = fgt.api.monitor.system.status.get()
print(f"Hostname: {status['hostname']}, Model: {status['model']}")
# Create firewall address
fgt.api.cmdb.firewall.address.post(
name="web-server",
subnet="10.0.1.100/32",
comment="Production web server"
)๐ฆ What's Included
When you install hfortix, you automatically get:
hfortix-fortios
Complete FortiOS/FortiGate API client with:
- 1,348 FortiOS 7.6.5 endpoints
- Full type hints and IDE autocomplete
- Async/await support
- Batch transactions and atomic operations
- Comprehensive error handling
- Rate limiting and retry logic
hfortix-core
Foundational infrastructure including:
- Observable HTTP client
- Event-driven monitoring
- Base abstractions and protocols
- Shared utilities
โจ Key Features
- ๐ฏ Complete API Coverage - All CMDB, Monitor, Log, and Service endpoints
- ๐ช Fully Typed - Complete type hints with .pyi stubs
- โก Modern & Fast - Async/await support, HTTP/2, connection pooling
- ๐ก๏ธ Production Ready - Comprehensive error handling and validation
- ๐ Simplified Syntax - Simple list format auto-converts to FortiOS dict format
- ๐ฆ Batch Transactions - Atomic configuration changes with automatic commit/rollback
- ๐ API Inspection - Debug and audit API interactions
๐ Documentation
- HFortix Documentation - Getting started and guides
- FortiOS Client Docs - Complete API reference
- Core Library Docs - Infrastructure details
๐ Individual Packages
If you only need specific components, you can install them separately:
# Just the FortiOS client (includes hfortix-core as dependency)
pip install hfortix-fortios
# Just the core infrastructure (for custom implementations)
pip install hfortix-core๐ Package Comparison
| Package | Purpose | Dependencies | Use When |
|---|---|---|---|
hfortix |
Meta-package | All packages | You want everything |
hfortix-fortios |
FortiOS API client | hfortix-core | FortiGate automation |
hfortix-core |
Core infrastructure | httpx, typing-extensions | Building custom clients |
๐ Quick Examples
Firewall Management
from hfortix_fortios import FortiOS
with FortiOS(host="192.168.1.99", token="token") as fgt:
# Create firewall policy
fgt.api.cmdb.firewall.policy.post(
name="Allow-Web",
srcintf=["internal"],
dstintf=["wan1"],
srcaddr=["all"],
dstaddr=["web-server"],
service=["HTTP", "HTTPS"],
action="accept"
)Batch Transactions
from hfortix_fortios import FortiOS
with FortiOS(host="192.168.1.99", token="token") as fgt:
# Atomic batch operation
with fgt.transaction() as txn:
txn.add(fgt.api.cmdb.firewall.address.post, name="server1", subnet="10.0.1.1/32")
txn.add(fgt.api.cmdb.firewall.address.post, name="server2", subnet="10.0.1.2/32")
# Both addresses created or both rolled back on errorAsync Support
from hfortix_fortios import AsyncFortiOS
async with AsyncFortiOS(host="192.168.1.99", token="token") as fgt:
status = await fgt.api.monitor.system.status.get()
addresses = await fgt.api.cmdb.firewall.address.get()๐ค Contributing
This is a proprietary library. For support or feature requests, please contact the maintainer.
๐ License
Proprietary License - See individual package LICENSE files for details.
HFortix - Modern Python SDKs for Fortinet automation
On this page
Languages
Makefile91.6%Python8.4%
Other
Created December 17, 2025
Updated February 10, 2026