# REST API

| **Cloud EU:** | ​<https://cloud.soda.io>​    |
| ------------- | ---------------------------- |
| **Cloud US:** | ​<https://cloud.us.soda.io>​ |

### Connect to the Soda Cloud API

The following example demonstrates how to connect to the Soda Cloud API using **Python**.

#### Requirements

* A **Soda Cloud account**
* **Python 3+**
* **Recommended:** A `.env` file containing `API_KEY_ID` and `API_KEY_SECRET`\
  Example of `.env`:

```
## Replace the following with your credentials
API_KEY_ID=333c3c33-3c33-3c3c-cccc-3c3c3333c333
API_KEY_SECRET=CcC3cCC3C_CCCc33cCC3cCcCC333c_C3Cc3C333CC33cCCC--33cCcC
```

> Learn how to [generate-api-keys](https://docs.soda.io/reference/generate-api-keys "mention").

#### Example connection

You can use this example as a starting point for integrating Soda into your workflows, ensuring that you **replace placeholders** with your own credentials and project-specific details. In one `.py` file, you can:

1. Create a working session
2. Send a POST request
3. Send a GET request

```python
## 1. Create a working session
from dotenv import load_dotenv
import os
import json
import requests
import base64

# (Recommended) Load environment variables from a .env file
load_dotenv()
api_key_id = os.getenv("API_KEY_ID")
api_key_secret = os.getenv("API_KEY_SECRET")

# Create token from your credentials
TOKEN = base64.b64encode(f"{api_key_id}:{api_key_secret}".encode()).decode()

HOST = "cloud.us.soda.io"                  # Or "cloud.soda.io"
HEADERS = {"Authorization": f"Basic {TOKEN}", "Content-Type": "application/json"}

datasetId = "<YOUR_DATASET_ID>"            # Replace with your details
data = {"key": "value", "key2": "value2"}  # Replace with your details
```

```python
## 2. Send a POST request to create or update data for the specified dataset
response = requests.post(
    f"https://{HOST}/api/v1/datasets/{datasetId}",
    headers=HEADERS,
    json=data
)
print(response.json())
```

```python
## 3. Send a GET request to retrieve check results or details
response = requests.get(
    f"https://{HOST}/api/v1/checks",
    headers=HEADERS,
    params={"checkIds": ["abcd"]}          ## (optional) Replace with your details
)
print(response.json())
```

<br>

***

{% if (visitor.claims.plan === 'datasetStandard')%}
{% hint style="success" %}
You are **logged in to Soda** and seeing the **Free license** documentation. Learn more about [documentation-access-and-licensing](https://docs.soda.io/reference/documentation-access-and-licensing "mention").
{% endhint %}
{% endif %}

{% if (visitor.claims.plan === 'enterprise')%}
{% hint style="success" %}
You are **logged in to Soda** and seeing the **Team license** documentation. Learn more about [documentation-access-and-licensing](https://docs.soda.io/reference/documentation-access-and-licensing "mention").
{% endhint %}
{% endif %}

{% if (visitor.claims.plan === 'enterpriseUserBased')%}
{% hint style="success" %}
You are **logged in to Soda** and seeing the **Enterprise license** documentation. Learn more about [documentation-access-and-licensing](https://docs.soda.io/reference/documentation-access-and-licensing "mention").
{% endhint %}
{% endif %}

{% if !(visitor.claims.plan === 'enterprise' || visitor.claims.plan === 'enterpriseUserBased' || visitor.claims.plan === 'datasetStandard')%}
{% hint style="info" %}
You are **not logged in to Soda** and are viewing the default public documentation. Learn more about [documentation-access-and-licensing](https://docs.soda.io/reference/documentation-access-and-licensing "mention").
{% endhint %}
{% endif %}
