API Reference

Complete SDK reference documentation for classes, methods, and type definitions in the HFortix-FortiOS library.

Note

Looking for API endpoints (CMDB, Monitor, Log, Service)? See API Endpoints for the complete endpoint catalog.

SDK Components

Main Client Classes

hfortix_fortios.FortiOS

FortiOS REST API Client

FortiOS is the single entry point for interacting with FortiOS devices. It supports both synchronous (default) and asynchronous operation via the mode parameter: FortiOS(host=..., token=..., mode="async").

API Handlers

The API handlers provide access to the four main API categories:

  • CMDB Handler - Configuration management (561 endpoints)

  • Monitor Handler - Status and statistics (490 endpoints)

  • Log Handler - Historical data queries (286 endpoints)

  • Service Handler - Operations and actions (11 endpoints)

See API Endpoints for complete endpoint documentation.

Response Objects

hfortix_fortios.FortiObject

Zero-maintenance wrapper for FortiOS API responses.

hfortix_fortios.FortiObjectList

A list of FortiObject instances with convenient access to raw API response.

hfortix_fortios.ContentResponse

Response wrapper for endpoints that return binary/text content.

All endpoint methods return FortiObject (single object) or FortiObjectList (collections); content-type endpoints return ContentResponse.

Transactions

hfortix_fortios.Transaction

FortiOS batch transaction manager.

hfortix_fortios.TransactionError

Exception raised for transaction-related errors.

Support for atomic configuration changes (FortiOS 6.4.0+) via with fgt.transaction() as txn:.

Error Handling

hfortix_fortios.FortinetError

Base exception for all Fortinet API errors

hfortix_fortios.APIError

Generic API error with optional metadata

hfortix_fortios.AuthenticationError

HTTP 401 - Authentication failed (invalid credentials)

hfortix_fortios.AuthorizationError

HTTP 403 - Authorization failed (insufficient permissions)

hfortix_fortios.ResourceNotFoundError

HTTP 404 - Resource not found

hfortix_fortios.DuplicateEntryError

Duplicate entry exists (error code -5, -15, -100, etc.)

hfortix_fortios.InvalidValueError

Invalid value provided (error code -651, -1, -50, etc.)

Exception classes re-exported from hfortix_core.exceptions. Note that AuthenticationError and AuthorizationError inherit from FortinetError directly, not from APIError.

Type Definitions

The library includes comprehensive type hints for all endpoints and operations. See the individual endpoint documentation for parameter types and return types.

Advanced Features

Observability & Debugging

The SDK includes built-in observability features:

  • Request/Response Logging

  • Performance Metrics

  • Audit Trail

  • Debug Mode

FortiManager Proxy

The SDK supports managing multiple FortiGates through FortiManager with automatic ADOM and device routing.

hfortix_fortios.FortiManagerProxy

FortiManager Proxy Client.

hfortix_fortios.ProxiedFortiOS

A FortiOS client that routes all API calls through FortiManager.

Custom Wrappers

You can extend the client with your own custom methods and high-level abstractions by subclassing or wrapping FortiOS.