REST API
The Soda Cloud API enables you to trigger actions and query data in your Soda Cloud account.
Last updated
Was this helpful?
Was this helpful?
## 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## 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())## 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())