Valkyrian Labs

forti-api

Latest releaseCILicense

forti-api is a header-only C++23 client for the FortiGate REST API (FortiOS v2). Its types are generated from the FortiGate's own schema, so every attribute of a supported object is available, documented and correctly typed, and writes change exactly what you changed.

1#include <forti_api/firewall.hpp>2using namespace fortiapi;3 4auto address = firewall::Addresses::get("LAN 10.0.0.0/24");5address.comment = "managed by forti-api";6firewall::Addresses::update(address);   // sends {"comment": "managed by forti-api"} and nothing else

What you get

Catalog

Every configuration endpoint

Generated from FortiOS 7.4.8 schemas: 487 endpoints on a FortiGate-60F, one struct per object with every attribute as a fortiapi::Field<T>, and a Table (list, find, get, contains, add, update, del) or Singleton (get, update) per endpoint.

Monitor

Typed monitor reads

The read-only monitor endpoints the web GUI uses, with result types generated from recorded response shapes; everything else through fortiapi::Monitor.

Fields

Exact writes

Fields know whether they are absent, read from the device, modified or cleared. An update sends only modified and cleared attributes.

Transport

A careful transport

Timeouts, one kept-alive connection per client for reads, URL-encoded object names, typed errors, reads retried on throttling and configuration changes never sent twice.

Downloads

Raw downloads

Non-JSON replies such as configuration backups, with a size limit and optional streaming.

Helpers

Domain helpers

DNS filter categories, push threat feeds, schedule days, service port ranges, API-user trusted hosts and live interface addresses.

Packaging

Header-only

Install the libforti-api-dev package or vendor the headers; libcurl is the only system dependency.

Where to go next

Get started

Installation

APT, Homebrew, vendoring or a source build, and how to compile against the headers.

Quick start

Create an API administrator, configure the connection, then read, change and create objects.

Guides

Fields and updates

Field<T> states, changing, clearing and creating objects, nested objects and tables.

Child tables

One entry of a table attribute at a time: a DHCP reservation, an address in a policy's srcaddr.

Runtime schema

Every endpoint as data: decode, validate and build request bodies for endpoints chosen at run time.

Queries

VDOMs, filters, field selection, paging and how object keys are encoded.

Errors and retries

The exception types, what is retried and what never is, and tracing.

Downloads and configuration backups

Client::download, size limits, streaming, and handling backups safely.

DNS filter

FortiGuard category actions on DNS filter profiles.

Threat feeds

Create a push feed, push entries, read them back and delete it safely.

System and firewall helpers

Interface addresses, the monitor API, trusted hosts, schedule days and port ranges.

Reference

Configuration

Environment variables and fortiapi::Config fields, with their defaults.

Supported endpoints

Every generated FortiOS endpoint with its C++ type, endpoint alias and header.

Development

Code generation

How the generated headers are produced, endpoint discovery and adding an endpoint.

Testing

The unit suite, the live FortiGate suite and its safeguards.