Datakit

Datakit provides a powerful transformation and integration engine

Table of contents

The demo examples for Datakit are all based on the examples provided in the plugin documentation at https://developer.konghq.com/plugins/datakit/

Demo scenes

The following examples have been added to the demo system to show different typical use cases which can be solved using Datakit.

Cat and dog

Will call out two to different APIs providing facts about cats and dogs and will responed with a combined payload with data from both cats and dogs

Based on

Sequence

Example response

{
    "cat_fact": "Tabby cats are thought to get their name from Attab, a district in Baghdad, now the capital of Iraq.",
    "dog_fact": "All dogs can be traced back 40 million years ago to a weasel-like animal called the Miacis which dwelled in trees and dens. The Miacis later evolved into the Tomarctus, a direct forbear of the genus Canis, which includes the wolf and jackal as well as the dog."
}

Header manipulation

Injects two headers into the request:

  • X-Datakit-Added-Header-1 and
  • X-Datakit-Added-Header-2

Also modifies incoming headers from your request and adds the prefix X-Request- to them. So for example your header foo will become X-Request-Foo

Sequence

Example response

{
  (...)
  "headers": {
    "X-Datakit-Added-Header-1": "This is an auto-added header",
    "X-Datakit-Added-Header-2": "This is another auto-added header",
    "X-Request-Foo": "bar"
  }
}

External authenticatipn

Before reaching the services endpoint will reach out to a token endpoint and inject it's response into the request

For this example we are using the UUID endpoint of httpbin as example for the external auth, but in the code you can see we could inject an api key and use client credentials flow

Sequence

Example response

{
  (...)
  "headers": {
     "Authorization": "Bearer 84d52319-f375-4be4-9524-e999c503a5d1"
  }
}