BetterAuth's API is language-agnostic — it's a standard REST API that speaks JSON over HTTPS. That means you can integrate it from virtually any programming language. This guide covers the core endpoints with working examples in 5 languages.
API Base URL
https://betterauth.online/api/v2/
We recommend using v2 for all new integrations. It features stricter validation, cleaner error messages, and custom path-based routing. The v1 API remains available for backward compatibility.
Authentication
All API requests require your Application Secret in the request body. Never expose this secret in client-side JavaScript or public repositories. For desktop applications, the secret is embedded in your binary — consider using obfuscation to make extraction harder.
License Validation (C++)
#include <curl/curl.h>
#include <string>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
size_t WriteCallback(void* contents, size_t size, size_t nmemb, std::string* userp) {
userp->append((char*)contents, size * nmemb);
return size * nmemb;
}
bool validateLicense(const std::string& key, const std::string& secret) {
CURL* curl = curl_easy_init();
std::string response;
json body = {
{"key", key},
{"secret", secret}
};
std::string payload = body.dump();
struct curl_slist* headers = NULL;
headers = curl_slist_append(headers, "Content-Type: application/json");
curl_easy_setopt(curl, CURLOPT_URL, "https://betterauth.online/api/v2/license/validate");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, payload.c_str());
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response);
CURLcode res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
if (res != CURLE_OK) return false;
auto resp = json::parse(response);
return resp["success"].get<bool>();
}
License Validation (C#)
using System.Net.Http;
using System.Text;
using System.Text.Json;
public class BetterAuthClient
{
private static readonly HttpClient http = new HttpClient();
private const string ApiBase = "https://betterauth.online/api/v2/";
public static async Task<bool> ValidateLicense(string key, string secret)
{
var payload = new {
key = key,
secret = secret
};
var content = new StringContent(
JsonSerializer.Serialize(payload),
Encoding.UTF8,
"application/json"
);
var response = await http.PostAsync(ApiBase + "license/validate", content);
var body = await response.Content.ReadAsStringAsync();
var result = JsonSerializer.Deserialize<JsonElement>(body);
return result.GetProperty("success").GetBoolean();
}
}
License Validation (Python)
import requests
API_BASE = "https://betterauth.online/api/v2/"
def validate_license(key: str, secret: str) -> dict:
response = requests.post(
f"{API_BASE}license/validate",
json={"key": key, "secret": secret}
)
data = response.json()
if data.get("success"):
return data["data"] # user info, expiry, level
else:
raise Exception(data.get("message", "Validation failed"))
License Validation (Node.js)
const axios = require('axios');
const API_BASE = 'https://betterauth.online/api/v2/';
async function validateLicense(key, secret) {
const { data } = await axios.post(`${API_BASE}license/validate`, {
key,
secret
});
if (!data.success) {
throw new Error(data.message || 'Validation failed');
}
return data.data; // { username, expires, level, hwid }
}
module.exports = { validateLicense };
License Validation (PHP)
<?php
$apiBase = 'https://betterauth.online/api/v2/';
function validateLicense($key, $secret) {
global $apiBase;
$ch = curl_init($apiBase . 'license/validate');
$payload = json_encode(['key' => $key, 'secret' => $secret]);
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 10,
]);
$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response, true);
return isset($data['success']) && $data['success'] ? $data['data'] : false;
}
Error Handling
All error responses follow a consistent format:
{
"success": false,
"message": "License key has expired",
"code": "KEY_EXPIRED"
}
Common error codes you should handle in your client:
KEY_NOT_FOUND— Invalid key format or key doesn't existKEY_EXPIRED— Key has passed its expiration dateKEY_BANNED— Key was revoked by the developerHWID_MISMATCH— Hardware doesn't match the bound machineUSER_BANNED— The user account was suspendedNO_ACTIVE_SUB— No active subscription for this key level
For the complete endpoint reference covering all 30+ operations, visit our API documentation.