Template API

Use the Template API to access CloudTruth templates populated for a specific environment.

The following examples demonstrate the usage of the Template API.

The API is accessed via URL with generated token id, similar to:

https://api.cloudtruth.com/t/d12f53fd-c1a6-444e-bece-164aa1b817bc

Template URLs can be obtained from the "Copy URL [for this environment]" link on the Template edit screen.

Python

This sample uses the built-in Python functionality to call the CloudTruth Template URL and parse the results in JSON Format

import requests
req = requests.get('https://api.cloudtruth.com/t/' + TEMPLATE_ID)
req.json()

React/JS

This sample uses the built-in JavaScript functionality to call the CloudTruth Template URL and parse the results in JSON format.

var req = new XMLHttpRequest();
req.open('GET', 'https://api.cloudtruth.com/t/' + TEMPLATE_ID, false);
var obj = JSON.parse(req.responseText);

Java

This sample uses standard libraries to call the CloudTruth Template URL and parse the results in JSON Format

String url = "https://api.cloudtruth.com/t/" + TEMPLATE_ID;
Scanner scanner = new Scanner(new URL(url).openStream(),
StandardCharsets.UTF_8.toString());
scanner.useDelimiter("\\A");
JSONObject obj = readnew JSONObject(scanner.hasNext() ? scanner.next() : "");