Skip to content

Kadiska APIs examples

Query API

First, you may certainly be interested in listing all possible fields you can request. You can do this by requesting all definitions. The endpoint is /api/v1/query/definitions and the method is GET.

This is en example of a corresponding Python script:

import requests

url = "https://app.kadiska.com/api/v1/query/definitions"
my_jwt = <YOUR JWT>
headers = {"Authorization": f"Bearer {my_jwt}"}

resp = requests.get(url, headers=headers)

The following example shows the API query and related response corresponding to the network latency metric of a specific Station-Target combination. The endpoint used here is /api/v1/query. The method is GET.

Query:

{
  "begin": "2022-02-23T12:59:24Z",
  "end": "2022-09-24T12:59:24Z",
  "select": [
     {"rtt_furthest:p75": ["p75","rtt_furthest"]}
  ],
  "from": "traceroute",
  "where": ["and",
    ["=", "station_name", ["$", "C-China-HongKong"]],
    ["=", "tracer_id", ["$","tracer:976ca7b56b"]]
    ]
}

As far as "select" arguments are concerned, they can take the form of {"<alias>":<expression>}. Using a literal string is possible through the use of ["$", "<text>"]. This allows you to distinguish literal strings from field names.

Response:

{
  "data": [
    {
      "rtt_furthest:p75": 367038
    }
  ],
  "meta": {
    "call_date": "2022-02-24T17:26:20.972752",
    "elapsed": 0.05843353271484375,
    "fields": [
      "rtt_furthest:p75"
    ],
    "sampling_enabled": true,
    "begin": "2022-02-23T12:59:24",
    "end": "2022-09-24T12:59:24",
  }
}

Example of corresponding Python code:

import requests
from requests.structures import CaseInsensitiveDict

url = "https://app.kadiska.com/api/v1/query"
my_jwt = <YOUR JWT>
headers = {"Authorization": f"Bearer {my_jwt}"}

data = {
  "begin": "2022-02-23T12:59:24Z",
  "end": "2022-09-24T12:59:24Z",
  "select": [
     {"rtt_furthest:p75": ["p75","rtt_furthest"]}
  ],
  "from": "traceroute",
  "where": ["and",
    ["=", "station_name", ["$", "C-China-HongKong"]],
    ["=", "tracer_id", ["$","tracer:977ca8b56b"]]
    ]
}

resp = requests.post(url, headers=headers, json=data)

Configuration API

The following example shows how to create a new Enterprise Station from the configuration API. The endpoint is /api/v1/config/stations and the method is POST.

Query:

{
  "name": "Test-Station",
  "country": "it",
  "city": "Roma",
  "location": {
    "latitude": 41.902782,
    "longitude": 12.496366
  },
  "provider": "Telecom Italia",
  "allowed_ips": [
    "198.51.100.42",
    "2001:0db8:5b96:0000:0000:426f:8e17:642a"
  ],
  "first_hop": 2,
  "gap_limit": 8,
  "sharing": "private",
  "type": "basic"
}

Response:

{
  "name": "Test-Station",
  "country": "it",
  "city": "Roma",
  "location": {
    "latitude": 41.902782,
    "longitude": 12.496366
  },
  "provider": "Telecom Italia",
  "allowed_ips": [
    "198.51.100.42",
    "2001:db8:5b96::426f:8e17:642a"
  ],
  "first_hop": 2,
  "gap_limit": 8,
  "sharing": "private",
  "type": "basic",
  "id": "station:87311a8ecc",
  "tenant_id": "3aFwUp4aosl",
  "revision": "c21891ce-ea51-418f-80f6-b696ce6b33b3",
  "num_nettracers": 0,
  "tenant_name": "My Tenant",
  "is_ours": true,
  "is_alive": null,
  "last_state_date": null,
  "new_errors": null,
  "date_create": "2022-02-25T06:34:28.415442",
  "date_modify": "2022-02-25T06:34:28.415442",
  "date_registered": null,
  "date_checkin": null,
  "info": null,
  "host": "",
  "arch": "",
  "cpu_count": null,
  "ip_security_status": "unknown",
  "last_ip": null,
  "os": "",
  "physical_memory": null,
  "state_minute_period": 30,
  "status": "new"
}

Example of corresponding Python script:

import requests

url = "https://app.kadiska.com/api/v1/config/stations"
my_jwt = <YOUR JWT>
headers = {"Authorization": f"Bearer {my_jwt}"}

data = {
  "name": "Test-Station",
  "country": "IT",
  "city": "Roma",
  "provider": "Telecom Italia",
  "sharing": "private",
}

resp = requests.post(url, headers=headers, json=data)

© 2022 Kadiska | Digital Experience Monitoring DEM. All rights reserved