Skip to main content

Apito REST API Integration with Python Project

Python HTTP module defines the classes which provide the client-side of the HTTP and HTTPS protocols. In most of the programs, the HTTP module is not directly used and is clubbed with the urllib module to handle URL connections and interaction with HTTP requests. Today we will learn how to use a Python HTTP client to fire HTTP request and then parse response status and get response body data.

note

Always remember to replace API_SECRET of the Bearer Token and project-id of the URL with the correct value from apito console. Go to this page if you do not know where to find your api secrets and endpoints for your project

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"))