Calling APIs on Connect from Python

Requirements

To call APIs hosted in Connect from Python, you’ll need:

  1. URL for the API endpoint hosted on Connect
  2. API key (if your API requires authorization)

Python Example

You can use the requests package in Python to call APIs from Python scripts or Jupyter Notebooks:

import requests

connect_api_url = "https://connect.yourcompany.com/rest-api/route"
connect_api_key = "YfB5XBRB7slkkBSEi5qr93mWJvbpXQQy"

response = requests.get(connect_api_url,
                        headers={'Authorization': 'Key ' + connect_api_key})
print(response.text)

You can replace the values of connect_api_url and connect_api_key with your API URL and API key from Connect.

Scope

The code examples assume that you are calling a published API in Connect that is:

  • Hosted on a secure server with TLS/SSL at an HTTPS endpoint
  • Using an API key to make an authorized call to an API
  • Making an HTTP GET request to the API

If your use case is different, then you can modify the example code accordingly.

Back to top