Python HTTP module defines the classes which provide the client-side integration with Apito's REST API tools and database API over HTTP and HTTPS protocols.
In most programs integrating with our API builder, the HTTP module is not directly used and is combined with the urllib
module to handle URL connections and interaction with HTTP requests to your instant API.
Today we will learn how to use a Python HTTP client to make requests to Apito's REST API tools, parse response status, and get response body data from your database API.
Tip:
Always remember to replace
API_SECRET
in the Bearer Token andproject-id
in the URL with the correct values from the Apito console.
If you are unsure where to find your API secrets and endpoints for your project, visit this page.
import http.client
conn = http.client.HTTPSConnection("https://api.apito.io/secured/rest/project")
headers = {
'content-type': "application/json",
'authorization': "Bearer API_SECRET"
}
conn.request("GET", "/api", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))