Automation API¶
The Automation API is a set of endpoints used by both the Automation system and DKCloudCommand.
A portion of this REST API is exposed, which allows you to use the API to perform different Automation actions directly.
API authentication¶
Username and password¶
You can use the same credentials to access the Automation UI and DKCloudCommand and to authenticate the Automation API.
Session token¶
A session token is generated following successful authentication. This token expires after four hours and a user must be re-authenticated.
Note
User role and kitchen access: API features and privileges are limited by user role and access granted to a kitchen.
Bash example¶
#!/bin/bash
LOGIN_URL="https://cloud.datakitchen.io/v2/login"
# Define credentials
USERNAME="me@example.com"
PASSWORD="mypassword"
# Gather Token with curl command
TOKEN=`curl -X POST --data-urlencode "username=$USERNAME" --data-urlencode "password=$PASSWORD" $LOGIN_URL`
Python example¶
import requests
# Gather Token
payload = {'username': 'me@example.com', 'password': 'password'}
response = requests.post('https://cloud.datakitchen.io/v2/login', data=payload)
token = response.text
Authorization header¶
The session authentication token must be included in all API calls, using the Authorization header with a
Bearer value.
Bash example¶
#!/bin/bash
TARGET_URL="https://cloud.datakitchen.io/v2/some/api"
JSON_HEADER="Content-type: application/json"
# Use this header after authenticating and storing your session token
AUTH_HEADER="Authorization: Bearer $TOKEN"
# Example curl command
curl -f -s -X POST -H "$JSON_HEADER" -H "$AUTH_HEADER" $TARGET_URL
Python example¶
import requests
target_url = 'https://cloud.datakitchen.io/v2/some/api'
payload = {'some key': 'some value'}
headers = {'Content-Type': 'application/json', 'Authorization': 'Bearer ' + token}
response = requests.post(target_url, headers=headers, data=payload)
DKUtils¶
DataKitchen provides a Python package, DKUtils, to help facilitate work with the Automation API.
To learn more, see DKUtils.