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 | 18
Part no.9036931-00 Rev AA February 2021
{"whisky": [{"name": "Hibiki", "type": "Blended", "age": 17}, {"name": "Old
Pulteney", "type": "Single Malt", "age": 21}], "stock": null, "alcohol":
true}
In this example, a string is the source, but you could also have uploaded information from a file, and
saved it back to a file using the json.load() and json.dump() commands.
2.6 Interact with a REST API using Python
Now that you have a basic understanding of what a REST API is, the following examples show how you
to interact with one using Python.
2.6.1 Urllib
When you are working with Python, you can access HTTP or HTTPS URLs using the standard (included)
Urllib package. For details about how to use Urllib, see the official documentation, or use any of the
many tutorials available online.
HTTPS://docs.python.org/3/library/urllib.html
Urllib has several modules, the request module being the most useful.
HTTPS://docs.python.org/3/library/urllib.request.html#module-urllib.request
2.6.1.1 Urllib examples
Enter dir() of the urllib.request to see the list of available methods and functions.
from urllib import request
print(dir(request))
The output is shown below, with the most useful function highlighted.
['AbstractBasicAuthHandler', 'AbstractDigestAuthHandler',
'AbstractHTTPHandler', 'BaseHandler', 'CacheFTPHandler',
'ContentTooShortError', 'DataHandler', 'FTPHandler', 'FancyURLopener',
'FileHandler', 'HTTPBasicAuthHandler', 'HTTPCookieProcessor',
'HTTPDefaultErrorHandler', 'HTTPDigestAuthHandler', 'HTTPError',
'HTTPErrorProcessor', 'HTTPHandler', 'HTTPPasswordMgr',
'HTTPPasswordMgrWithDefaultRealm', 'HTTPPasswordMgrWithPriorAuth',
'HTTPRedirectHandler', 'HTTPSHandler', 'MAXFTPCACHE', 'OpenerDirector',
'ProxyBasicAuthHandler', 'ProxyDigestAuthHandler', 'ProxyHandler', 'Request',
'URLError', 'URLopener', 'UnknownHandler', '__all__', '__builtins__',
'__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__',
'__spec__', '__version__', '_cut_port_re', '_ftperrors', '_have_ssl',
'_localhost', '_noheaders', '_opener', '_parse_proxy',
'_proxy_bypass_macosx_sysconf', '_randombytes', '_safe_gethostbyname',
'_thishost', '_url_tempfiles', 'addclosehook', 'addinfourl', 'base64',
'bisect', 'build_opener', 'contextlib', 'email', 'ftpcache', 'ftperrors',










