DataKitchen DataOps Documention

Introduction

Authentication

Username and Password

The same credentials used to access DataKitchen's web app and command line tools are used to authenticate against DataKitchen's API.

Session Token

After a successful authentication via username and password, a session token is generated. After four hours, this token expires and you will need to re-authenticate.

User Role and Kitchen Staff

Beyond a valid API session token, API features and access privileges are limited by user role and Kitchen-Staff rights.

Examples

Bash

#!/bin/bash

LOGIN_URL="https://cloud.datakitchen.io/v2/login"
JSON_HEADER="Content-type: application/json"

# Define credentials
USERNAME="[email protected]"
PASSWORD="mypassword"

# Gather Token with curl command
TOKEN=`curl -f -s -X POST -d "username=$USERNAME&password=$PASSWORD" -H "$JSON_HEADER" "$LOGIN_URL"`

Python

import requests
import json

# Gather Token
payload = {'username': '[email protected]', 'password': 'password'}
response = requests.post('https://cloud.datakitchen.io/v2/login', data = payload)
token = response.text

This session token must be included in all API calls, using the Authorization header with a Bearer value.

Bash

#!/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

import requests
import json

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)

Submitting Orders

DataKitchen's API offers the ability to start or schedule Recipe Orders, allowing you to programmatically manage your data flows. To submit an Order through the API, you need to specify the Kitchen, Recipe, and Variation. You also can specify Overrides for Variables, but this is not required.

Bash

#!/bin/bash

TARGET_URL="https://cloud.datakitchen.io/v2/order/create/$KITCHEN/$RECIPE/$VARIATION"
JSON_HEADER="Content-type: application/json"
AUTH_HEADER="Authorization: Bearer $TOKEN"
OVERRIDES = '{"parameters": {"some key": "some value"}}'

RESULT = curl -f -s -X PUT -H "$JSON_HEADER" -H "$AUTH_HEADER" $TARGET_URL

Python

import requests
import json

overrides = {'some key': 'some value'}
parameters = json.dumps({'parameters': overrides})
headers = {'Content-Type': 'application/json', 'Authorization': 'Bearer ' + token}
url = 'https://cloud.datakitchen.io/v2/order/create/%s/%s/%s' % (kitchen, recipe, variation)
response = requests.put(url, headers=headers, data=parameters)
result = response.json()
payload = {‘username’: os.environ[‘username’], ‘password’: os.environ[‘password’]}
   r = requests.post(’https://cloud.datakitchen.io/v2/login', data=payload)
   token = r.text

headers = {‘content-type: ‘application/json’, ‘authorization’: ‘bearer  + token}
   url = ’https://cloud.datakitchen.io/v2/order/create/%s/%s/%s' % (kitchen, recipe, variation)

Response Characteristics

On a successful Order submission, the API will return a response code of 200. The result JSON will indicate the status of the request, the Order ID, and applied Variable Overrides:

{
    "status": "success",
    "serving_hid": "f891ab00-ffcb-11e8-ad07-0242ac110002",
    "variable_overrides": {
        "some key": "some value"
    }
}

If the Order request has problems, the response will have a status code of 417, and there will be details in the JSON result. For example, making an API call for a non-existent Variation will return JSON like this:

{
    "message": {
        "status": "failed",
        "error": {
            "message": "kitchen (test-kitchen),recipe (test-recipe),variation (missing-variation)",
            "detail": "unable to find the variation named missing-variation in the recipe test-recipe variations.json"
        }
    }
}

Updated 4 months ago


Next Up:

Quickstart

Introduction


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.