Installation#
pyfortinet requires Python 3.9 or later and Pydantic 2. Use a virtual environment to keep its dependencies separate from other applications.
Install with uv#
Install uv first if it is not already available. For an application that uses pyfortinet, create a project and add the dependency:
For asynchronous support, use this dependency instead:
Save an example as main.py and run it in the project environment:
uv manages the project's virtual environment and dependency lockfile. Activation is unnecessary
when using uv run. See the uv project guide
for details.
Use uv with a standalone virtual environment#
For a script directory without a uv project, use the uv pip interface:
Activate .venv using the platform-specific commands in the pip section below, then run your
script with python main.py. uv pip install installs into the discovered environment;
it does not add a dependency to pyproject.toml or maintain a project lockfile.
Work on pyfortinet itself#
For this repository, use its checked-in dependency resolution instead of creating a new project:
git clone https://github.com/realvitya/pyfortinet.git
cd pyfortinet
uv sync --locked
uv run invoke docs-serve
The default development group includes optional client dependencies and, on Python 3.11+,
the Zensical documentation tools. Building or previewing docs requires Python 3.11+;
using the library still requires only Python 3.9+.
For a runtime-only source environment, use uv sync --locked --no-dev, adding
--extra async, --extra rich, or --extra all as needed.
See the developer guide for contribution checks.
Install with pip#
Activate it on Linux or macOS:
Or in Windows PowerShell:
Then install the package:
| Installation | Includes |
|---|---|
pyfortinet |
Synchronous clients and object models |
pyfortinet[async] |
Adds aiohttp for asynchronous clients |
pyfortinet[rich] |
Adds Rich for optional formatted output |
pyfortinet[all] |
Adds both optional dependencies |
Quote extras when installing from a shell:
Connect to FortiManager#
Use the FortiManager HTTPS URL, an account with JSON-RPC API access, and an explicit ADOM.
The client appends /jsonrpc if absent from base_url. Username/password authentication is
currently supported. Direct FortiGate connections are not implemented.
Certificate verification defaults to True. For the synchronous requests transport,
REQUESTS_CA_BUNDLE can identify a trusted CA bundle. That setting is specific to requests;
do not assume it configures aiohttp. For asynchronous clients, ensure the certificate is trusted
by the Python SSL environment. verify=False disables certificate verification and should be
limited to environments where you explicitly intend that behavior.
The quickstart reads credentials from environment variables to avoid storing
them in example code. See the generated FMGSettings reference for connection settings and
advanced usage for timeout and retry behavior.
Install from source#
To try the current repository version:
Source installations may differ from a published release. For editable installations, dependency management with uv, and contribution checks, follow the developer guide.