Categories

Category cover

Automation
155 posts

Category cover

Learning paths
119 posts

Category cover

CISO
22 posts

Category cover

Security
20 posts

Category cover

Notes
19 posts

Category cover

Personal Security
18 posts

Category cover

Infrastructure
12 posts

Category cover

OT/ICS
5 posts

Category cover

Books
3 posts

Category cover

UNetLab
3 posts

Category cover

Write-up
3 posts

Category cover

OSInt
2 posts

Category cover

My life
1 posts

Automating Palo Alto Firewall via Python PAN-OS SDK

Andrea Dainese
July 05, 2025
Post cover

In previous posts, we explored how to automate certain operations on Palo Alto Networks firewalls using XML API and REST API directly. According to the official documentation , there are ready-to-use libraries available for several programming languages (PHP, Go, Python).

Personally, I believe Python is the most suitable language for writing automations and integrations. For this reason, we will focus on the Python SDKs. There are two libraries available:

  • pan-python : developed and maintained personally by Kevin Steves. This library allows low-level operations on PAN-OS systems.
  • pan-os-python : officially developed and maintained by Palo Alto Networks, it enables high-level interaction with firewalls, similar to the CLI or Web interface. This library depends on specific versions of pan-python.

The pan-os-python library is officially maintained by Palo Alto Networks. It depends on the pan-python library but is not compatible with its latest version. pan-os-python allows interaction with firewalls and Panorama similarly to the Web interface.

The documentation is available online, and the relationships between APIs are described through diagrams.

On some systems, you may encounter the following error:

from distutils.version import LooseVersion # Used by PanOSVersion class ModuleNotFoundError: No module named 'distutils'

In this case, you need to install a specific version of setuptools:

pip install setuptools>=75.1.0

The library organizes various methods into the following classes:

Continue reading the post on Patreon .