Extreme API with Python
Table Of Contents
- 1 Preface
- 2 Introduction
- 3 EXOS APIs
- 4 VOSS API
- 5 XMC API
- 6 ExtremeCloud IQ API
- 7 Extreme Campus Controller API
Extreme API with Python
Page | 99
Part no.9036931-00 Rev AA February 2021
This example clearly shows the GraphQL query syntax and the expected output to expect. The output is
formatted in JSON in GraphiQL, but the data is returned as a Java hashmap within a script. This should
be treated as a regular Python dictionary. From here, you have all the tools you need to include NBI
CALLs within your Python scripts and workflows.
Using this same query example in a Python script is easy:
query = '''
{
network {
devices {
baseMac
firmware
sitePath
}
}
}
'''
res = emc_nbi.query(query)
i = 0
j = 0
for item in res['network']['devices']:
if item['sitePath'] == "/World/Extreme Fabric Connect":
i += 1
elif item['sitePath'] == "/World/IP Campus":
j += 1
else:
continue
print "There are {} devices in Extreme Fabric Connect site".format(i)
print "There are {} devices in IP Campus site".format(j)
Copy and paste your query from GraphiQL as a string in your Python code, and then CALL it using the
provided emc_nbi Python object, with the query method.
The hashmap data format is natively converted to a Python dictionary. This data should not be treated
as JSON, which will trigger an error.
The output is:
Script Name: NBI Test
Date and Time: 2020-06-27T17:56:20.166










