Calling APIs on Connect from Python
Requirements
To call APIs hosted in Connect from Python, you’ll need:
- URL for the API endpoint hosted on Connect
- 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
= "https://connect.yourcompany.com/rest-api/route"
connect_api_url = "YfB5XBRB7slkkBSEi5qr93mWJvbpXQQy"
connect_api_key
= requests.get(connect_api_url,
response ={'Authorization': 'Key ' + connect_api_key})
headersprint(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.