Extreme API with Python

Table Of Contents
Extreme API with Python
Page | 8
Part no.9036931-00 Rev AA February 2021
Note: If you need more information about a function, method or library, Python has a built-in help
system. In the Python interactive shell, type help(<method>) or dir(<method>.
If you use an IDE, you can run code directly from the editor and, with more advanced IDEs, you can
manage virtual environments and execute selected portions of code. Spyder and Jupyter are part of the
Anaconda
distribution, which is a typical environment for data science.
2.2 REST APIs
This document describes with forms and variants of REST APIs, sometimes using Openconfig or GraphQL
for more standard ones, or a specific API for some others. They all share the same generic logic,
requiring you to access a specific URL via HTTP to retrieve data, most likely, formatted in JSON. To do
this, you may need to install some Python libraries.
First it is necessary to understand URLs.
2.2.1 URLs
URL stands for Uniform Resource Locator, which is a string you enter in a browser, typically to access a
site. This string contains a great deal of information.
HTTPS://en.wikipedia.org/wiki/JSON?key=value&data=info#Example
For example, this URL can be broken down into the following elements:
The protocol, which can be HTTPS, HTTP, ftp, etc.
The host, often an IP address, which is the location of the server you want to reach.
The host is sometimes followed by “:” and a value, which is the port number. If this is not
present, then the browser defaults to the default protocol value (HTTP = 80, HTTPS = 443, for
example).
The path at the destination server to reach the content. In the context of a REST API, this is
often called an endpoint.
A query string follows an optional ?, and is used to pass arguments to the server, typically in
name=value pairs. To pass several arguments, use the & character to separate them.
A fragment appears after an optional #, and leads directly to a given part of the content.