how to add username and password to API call get d...
# ask-ai
s
how to add username and password to API call get destinations using python
k
To add a username and password to an API call to get destinations using Python, you can use the
requests
library with HTTP Basic Authentication. Below is an example based on the information provided in the knowledge sources:
Copy code
python import requests from requests.auth import HTTPBasicAuth  # Define the API endpoint url = "http://<server_url>:8006/api/v1/destinations"  # Define the username and password username = "<your_username>" password = "<your_password>"  # Define the headers headers = {     "accept": "application/json",     "content-type": "application/json" }  # Make the GET request with basic authentication response = requests.get(     url,     headers=headers,     auth=HTTPBasicAuth(username, password) )  # Print the response print(response.json())
Replace
<server_url>
,
<your_username>
, and
<your_password>
with your actual server URL, username, and password. This example uses the
requests
library to send a GET request to the Airbyte API endpoint for listing destinations, including the necessary authentication headers. For more details on the Airbyte API, you can refer to the [Airbyte Public API - Destinations](https://reference.airbyte.com/reference/start) documentation.