Skip to content

Python SDK Overview

IP Fabric is a Python API for connecting to and communicating against an IP Fabric instance using IP Fabric’s Rest API.

The IP Fabric Python SDK allows you to quickly gather data from your network in as little as 3 lines of code.

Installing Python IP Fabric

Minimum Requirements

  • Python 3.8.1+
  • Access to an instance of IP Fabric
  • API Token or Username/Password to IP Fabric

Poetry is a Python package manager that makes spinning up a virtual environment ready to run your code quick and easy.

Make sure you have Poetry installed in your Python environment:

pip install poetry 

Since Poetry manages all the required packages, you only have to run one command to install all the dependencies required for Python IP Fabric:

poetry install  

Want to install all the dependencies required to run our example scripts?

poetry install -E examples

pip

pip install ipfabric

To run scripts in the example directory:

pip install ipfabric[examples]

Using the SDK

Setting Up an API Token

Please follow the instruction on the API Tokens documentation page.

Environment Variables

Please add the following environment variables to your .env file:

Variable Name Python Parameter Default Description
IPF_URL base_url None IP Fabric URL
IPF_TOKEN auth None API Token
IPF_VERIFY verify True Enforce SSL

Initializing

Once you set up your environment variables:

Inventory

To quickly get an inventory of devices or interfaces:

from ipfabric import IPFClient

ipf = IPFClient()
ipf.inventory.devices.all()
ipf.inventory.interfaces.all()

Technology

For each Technology table in IP Fabric, you have a way to quickly gather the data:

>>> ipf.technology.
ipf.technology.addressing       ipf.technology.management                                  
ipf.technology.client           ipf.technology.stp           
ipf.technology.cloud            ipf.technology.serial_ports                
ipf.technology.mpls             ipf.technology.sdwan
ipf.technology.multicast        ipf.technology.security
ipf.technology.dhcp             ipf.technology.neighbors                 
ipf.technology.oam              ipf.technology.sn
ipf.technology.fhrpd            ipf.technology.managed_networks             
ipf.technology.vlans            ipf.technology.routing
ipf.technology.interfaces       ipf.technology.platforms
ipf.technology.ip_telephony     ipf.technology.wireless                      
ipf.technology.port_channels    ipf.technology.qos    
ipf.technology.load_balancing   

Each one of these technologies relates to data IP Fabric has gathered about your network devices.

For example, to view NTP configurations:

ipf.technology.management.ntp_summary.all()