Skip to main content

pyfortinet

pyfortinet is a Python library for the FortiManager JSON-RPC API. Work with addresses, groups, services, policies, and other supported resources as Python objects. The library handles session authentication, request construction, and typed GET responses.

Features

  • High-level configuration models with Pydantic validation and API field aliases.
  • Synchronous and asynchronous clients with consistent object operations.
  • ADOM workspace locking and connection cleanup.
  • Background task polling with progress callbacks.
  • Dictionary requests and low-level clients for endpoints without a model.

Coverage is evolving. Check the code reference for available models and the target firmware's API reference for supported fields. Direct FortiGate connections, token/SAML authentication, and workflow session approval automation are not implemented.

Installation

Python 3.9 or later is required.

python -m pip install pyfortinet
# Optional asynchronous support:
python -m pip install "pyfortinet[async]"
# Both asynchronous support and Rich output:
python -m pip install "pyfortinet[all]"

Read firewall addresses

Set the example's environment variables for your FortiManager account and selected ADOM. The account needs JSON-RPC API access. TLS certificate verification is enabled by default.

import os

from pyfortinet import FMG
from pyfortinet.fmg_api.common import F
from pyfortinet.fmg_api.firewall import Address

config = {
    "base_url": os.environ["FMG_URL"],
    "username": os.environ["FMG_USERNAME"],
    "password": os.environ["FMG_PASSWORD"],
    "adom": os.environ["FMG_ADOM"],
}

with FMG(**config) as fmg:
    for address in fmg.get(Address, F(name__like="server%")).data:
        print(address.name, address.subnet)

Use async with FMG(**config) as fmg: and await fmg.get(...) for asynchronous code. AsyncFMG is also available directly.

Documentation

  • Quickstart: connect, read objects, and make a targeted update.
  • API concepts: move from JSON-RPC operations to high-level Python objects.
  • How-tos: filtering, object lifecycle, groups, mappings, workspace locks, and installation tasks.
  • Developer guide: setup, implementing models, testing, and documentation maintenance.

If you use How to FortiManager API, start with the API concepts page. That guide provides broad API context; pyfortinet's user guide shows workflows using the models implemented by this library.

Metadata

Release files for pyfortinet 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyfortinet 0.0.2
File Size Uploaded Provenance Actions
pyfortinet-0.0.2.tar.gz 102.1 kB With provenance Details for pyfortinet-0.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pyfortinet 0.0.2
File Interpreter ABI Platform Actions
pyfortinet-0.0.2-py3-none-any.whl Python 3 none any Details for pyfortinet-0.0.2-py3-none-any.whl

Total release size: 218.3 kB

Release files / pyfortinet-0.0.2.tar.gz

Download URL pyfortinet-0.0.2.tar.gz
Size 102.1 kB
Tags Source
SHA-256 checksum
How to use checksums
8441bd90f063bc079b5bfdd28fa56e49ba85c33f24cd1c06c7c3982572dfc631
BLAKE2b-256 checksum
How to use checksums
dc22fb7d58513f24d5ebb72fb3be5a04354c95ad1bc88f19822223beb5463b2b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

Release files / pyfortinet-0.0.2-py3-none-any.whl

Download URL pyfortinet-0.0.2-py3-none-any.whl
Size 116.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ef25a79777e8d601634e78d530d4b50c51f108d12afb282cd20c7086fd85959d
BLAKE2b-256 checksum
How to use checksums
099551092654c41f25181fcaef97d5db44d43bd15fe2daf443fc4ccd38849c8a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

Security for pyfortinet 0.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pyfortinet-0.0.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page