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 | 25
Part no.9036931-00 Rev AA February 2021
r = requests.get('HTTPS://httpbin.org/delay/4', timeout=3)
Add a delay of 4 seconds for the answer with a timeout of 3 seconds. Running the script gives you a
traceback:
Traceback (most recent call last):
[…]
raise ReadTimeout(e, request=request)
requests.exceptions.ReadTimeout: HTTPSConnectionPool(host='httpbin.org',
port=443): Read timed out. (read timeout=3)
You can also use a Python try/except, which provides a cleaner result without breaking code.
import requests
try:
r = requests.get('HTTPS://httpbin.org/delay/4', timeout=3)
except requests.exceptions.Timeout:
print("Server is too long to answer")
2.6.3 Testing a REST API
Now that you are familiar with REST and Python, another useful tool when working with a REST API is
Postman
.
Note: You can add Postman to some browsers via plug-in or it can be run as an external application on
most systems.
When you work with an API, you must know exactly what URL to use, and which data format to send or
receive. Having the ability to quickly test a CALL and interpret the results without having to write the
code for it is extremely useful. This is where Postman can help.
The Postman GUI can be broken down into three main sections, as shown below:










