Getting Started
This and following pages are about the Website API. If you would like to know more about how to use the API in your Start App, visit Getting Started here instead.
Learn how to use your API key to make successful website API calls and avoid rate limits or blocks. Basic Authentication is required for all requests.
To ensure security and accountability, always use your own account credentials. Avoid giving admin access to restricted users, as this compromises both integrity and traceability.
All API requests must include your API key, username, and a SHA-256 hashed password in the request body. Requests missing any of these will be rejected and may result in your IP being blocked.
Example:
If your API key is 123456abcd, your username is test, and your password is super secret, the JSON object should look like:
{
"apiKey": "123456abcd",
"username": "test",
"password": "EABD522910CCDD77AEF079FEFF0C7BB6486F6AB207AE6D3ED9E671208C92AB0F"
}
To hash your password, use a tool like this SHA-256 generator. Be sure to select Hex (uppercase) for the output format.
Request format
To fight against scrapers, tooling and bad actors, the JSON structure is not being sent in plaintext and is encoded in Base64 with a prefix instead to our servers.
Encode the JSON object in Base64 and add the prefix PanelRequest to create a valid body.
Example:
Let's try sending a request to list all Apps:
- Check the app docs and look for the list request.
- Use all object parameters and set the correct data for optional fields.
- Encode it.
After following the steps, the structure:
{
"apiKey": "123456abcd",
"username": "test",
"password": "EABD522910CCDD77AEF079FEFF0C7BB6486F6AB207AE6D3ED9E671208C92AB0F",
"type": "app",
"action": "list"
}
Should encode to this:
PanelRequesteyJBUElLZXkiOiIxMjM0NTZhYmNkIiwidXNlcm5hbWUiOiJ0ZXN0IiwicGFzc3dvcmQiOiJFQUJENTIyOTEwQ0NERDc3QUVGMDc5RkVGRjBDN0JCNjQ4NkY2QUIyMDdBRTZEM0VEOUU2NzEyMDhDOTJBQjBGIiwidHlwZSI6ImFwcCIsImFjdGlvbiI6Imxpc3QifQ==
Code Examples
- JavaScript
- C++
async function sendRequest() {
const payload = {
apiKey: "<API Key>",
username: "<username>",
password: "<SHA-256 encoded password in uppercase>",
type: "app",
action: "list",
};
// Convert the JSON to a string and encode it
const jsonString = JSON.stringify(payload);
const encoded = "PanelRequest" + btoa(jsonString);
try {
// Send request with body
const response = await fetch("https://api.dtc.zone", {
method: "POST",
headers: {
"Content-Type": "text/plain",
},
body: encoded,
});
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
// data should be a JSON if the response is OK
const data = await response.json();
console.log(data);
} catch (error) {
console.error("JS error: " + error.message);
}
}
You will need nlohmann/json, libcurl, and a Base64 encoding library.
#include <iostream>
#include <string>
#include <vector>
#include <nlohmann/json.hpp>
#include <curl/curl.h>
// Forward declaration for the Base64 utility function
std::string base64_encodestr(const std::string& str);
// Callback function to handle response data from libcurl
size_t WriteCallback(void* contents, size_t size, size_t nmemb, std::string* userp) {
userp->append((char*)contents, size * nmemb);
return size * nmemb;
}
int main() {
nlohmann::json j;
j["apiKey"] = "<API Key>";
j["username"] = "<username>";
j["password"] = "<SHA-256 encoded password in uppercase>";
j["type"] = "app";
j["action"] = "list";
// Encode JSON object and add prefix
const std::string encodedBody = "PanelRequest" + base64_encodestr(j.dump());
CURL* curl = curl_easy_init();
if (curl) {
std::string readBuffer;
curl_easy_setopt(curl, CURLOPT_URL, "https://api.dtc.zone");
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, encodedBody.c_str());
curl_easy_setopt(curl, CURLOPT_POST, 1L);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 1L); // For production
// Set up the callback function to receive data
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);
// Set the Content-Type header
struct curl_slist* headers = nullptr;
headers = curl_slist_append(headers, "Content-Type: text/plain");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
CURLcode res = curl_easy_perform(curl);
if (res != CURLE_OK) {
fprintf(stderr, "curl_easy_perform() failed: %sn", curl_easy_strerror(res));
} else {
// If the request was OK, data should be in readBuffer
std::cout << "Response:n" << readBuffer << std::endl;
// Optionally parse the JSON response
nlohmann::json retJson = nlohmann::json::parse(readBuffer, nullptr, false);
if (retJson.is_discarded()) {
fprintf(stderr, "Failed to parse JSON response.n");
}
}
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
}
return 0;
}
In case you don't have a Base64 encoding file:
static const std::string base64_chars =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz"
"0123456789+/";
std::string base64_encode(unsigned char const* buf, unsigned int bufLen) {
std::string ret;
int i = 0;
int j = 0;
unsigned char char_array_3[3];
unsigned char char_array_4[4];
while (bufLen--) {
char_array_3[i++] = *(buf++);
if (i == 3) {
char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;
char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4);
char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);
char_array_4[3] = char_array_3[2] & 0x3f;
for (i = 0; (i < 4); i++)
ret += base64_chars[char_array_4[i]];
i = 0;
}
}
if (i)
{
for (j = i; j < 3; j++)
char_array_3[j] = '\0';
char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;
char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4);
char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);
char_array_4[3] = char_array_3[2] & 0x3f;
for (j = 0; (j < i + 1); j++)
ret += base64_chars[char_array_4[j]];
while ((i++ < 3))
ret += '=';
}
return ret;
}
std::string base64_encodestr(const std::string& str) {
return base64_encode(reinterpret_cast<const unsigned char*>(str.data()), str.size());
}