Skip to content

Commit

Permalink
docs: Add examples of running airbyte api requests (#870)
Browse files Browse the repository at this point in the history
* Add docs for running dbt core in airflow via cosmos

* Change png to url

* Add examples in python and bash for airbyte api commands
  • Loading branch information
chrishronek authored Oct 12, 2023
1 parent 48f67cb commit 03de36f
Showing 1 changed file with 50 additions and 1 deletion.
51 changes: 50 additions & 1 deletion airbyte/plural/docs/basic-auth.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,53 @@ then delete them (allowing k8s to restart) with:

```sh
kubectl delete pod <name> -n airbyte
```
```

## Making API Calls

Once you've completed the steps above to configure basic auth, you should be able to make api requests to your Airbyte
instance accordingly:

```python
# python
import base64
import requests
user = "<insert-your-username>" # configured in previous step
password = "<insert-your-password>" # configured in previous step
base_url = "<insert-your-base-url>" # can be found in your project's context.yaml (spec.configuration.airbyte.hostname)
credentials = f"{user}:{password}"
credentials_base64 = base64.b64encode(credentials.encode("utf-8")).decode("utf-8")
response = requests.post(
url=f"https://{base_url}/api/v1/workspaces/list",
headers={
"accept": "application/json",
"authorization": f"Basic {credentials_base64}"
}
)
print(response.json())
```

```bash
user="<insert-your-username>" # configured in previous step
password="<insert-your-password>" # configured in previous step
# Your base URL (can be found in your project's context.yaml - spec.configuration.airbyte.hostname)
base_url="<insert-your-base-url>"
# Combine the username and password with a colon (required for Basic Authentication)
credentials="${user}:${password}"
# Encode the credentials in base64
credentials_base64=$(echo -n "$credentials" | base64)
# Make an HTTP POST request using curl
curl -X POST "https://${base_url}/api/v1/workspaces/list" \
-H "accept: application/json" \
-H "authorization: Basic $credentials_base64"
```

It's also worth noting that the [Airbyte Public API Docs](https://airbyte-public-api-docs.s3.us-east-2.amazonaws.com/)
will serve as a more accurate reference than the [Airbyte Reference API Docs](https://reference.airbyte.com/reference/start)
when building your application.

0 comments on commit 03de36f

Please sign in to comment.