Extreme API with Python

Table Of Contents
Extreme API with Python
Page | 22
Part no.9036931-00 Rev AA February 2021
Make a REST CALL, using GET to retrieve data. This service lets you add parameters (arguments) to the
URL in a query string, so that the server also returns this information .
Requests has an integrated JSON function that you can use also, as shown below :
import requests
qstring = {"h2g2": 42, "elite": 1337}
r = requests.get('HTTPS://httpbin.org/get', params=qstring)
print(r.url)
print(r.status_code)
print(r.headers['content-type'])
print(r.encoding)
print(r.text)
data = r.json()
print(type(data))
print(data)
In this example, the query string has been separated from the URL. You could have added the
parameters directly to the URL, but it is a good practice to work this way, which allows you to reuse the
same URL with different parameters. When you test using this method, you use the GET function with
requests and the GET path on httpbin.org.
The result of a test is the shown below: