| Description | This article demonstrates how to access a FortiGate via REST API using a Python script. |
| Scope | FortiGate. |
| Solution |
The REST API token needs to be obtained from the FortiGate. Below is the link that has instructions on how to obtain a REST API token: FortiGate 7.4.8 REST API administrator Guide
The script below is an example to retrieve system status, which is equivalent to 'get system status'.
import requests
url = "https://FGT IP/api/v2/monitor/system/status" payload = "" response = requests.request("GET", url, headers=headers, data=payload, verify=False) output = response.json() print(json.dumps(output, indent=4)) The URL can be changed to retrieve different information from the FortiGate. It is recommended to use the certificate by removing 'verify=False'.
Below are the results of the script.
{ |
The Fortinet Security Fabric brings together the concepts of convergence and consolidation to provide comprehensive cybersecurity protection for all users, devices, and applications and across all network edges.
Copyright 2025 Fortinet, Inc. All Rights Reserved.