Skip to content
Advertisement

How to connect to HTTPS connection to use an API in Python?

This is the requirement from the API’s documentation

  • A HTTPS connection is needed to use the API. This means that you will require a secure SSL/TLS connection to be able to communicate with our API Server.

This is the Curl command of getting the clients in their documentation

curl -i -X GET -H "X-KEYALI-API:{API_KEY}" -u {API_USERNAME}:{API_PASSWORD} https://aliphia.com/v1/api_public/clients/

So, I need to implement the same thing in Python

Advertisement

Answer

import requests

headers = {
    'X-KEYALI-API': '{API_KEY}',
}

response = requests.get('https://aliphia.com/v1/api_public/clients/', headers=headers, auth=('{API_USERNAME}', '{API_PASSWORD}'))
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement