Examples
Ready-to-run recipes in curl, Python, and JavaScript for balance checks, captchas, mail, and webhooks.
Ready-to-run recipes in curl, Python (requests), and JavaScript (fetch, Node 18+).
All examples use base URL https://draxon.one and read your API key from $DRAXON_KEY.
Check account balance
curl
curl -s -H "Authorization: Bearer $DRAXON_KEY" https://draxon.one/api/account/v1/billing/balance
Python
import os, requests
res = requests.get(
"https://draxon.one/api/account/v1/billing/balance",
headers={"Authorization": f"Bearer {os.environ['DRAXON_KEY']}"},
)
res.raise_for_status()
data = res.json()
print(f"Balance: ${data['balance_usd']} (Available: ${data['available_usd']})")
JavaScript
const res = await fetch("https://draxon.one/api/account/v1/billing/balance", {
headers: { Authorization: `Bearer ${process.env.DRAXON_KEY}` },
});
const data = await res.json();
console.log(`Balance: $${data.balance_usd} (Available: $${data.available_usd})`);
Expected output:
{
"balance_micros": 12500000,
"held_micros": 4000,
"available_micros": 12496000,
"balance_usd": "12.500000",
"available_usd": "12.496000"
}
Solve hCaptcha (create, then wait)
Create the task, then ask for the result with ?wait=60 (the request answers as soon as the task is done).
curl
TASK_ID=$(curl -s -X POST https://draxon.one/api/captcha/v1/tasks \
-H "Authorization: Bearer $DRAXON_KEY" \
-H "Content-Type: application/json" \
-d '{"type":"standard_hcaptcha","website_url":"https://example.com/login","website_key":"10000000-ffff-ffff-ffff-000000000001"}' | jq -r .id)
curl -s -H "Authorization: Bearer $DRAXON_KEY" \
"https://draxon.one/api/captcha/v1/tasks/$TASK_ID?wait=60"
Python
import os, requests
headers = {"Authorization": f"Bearer {os.environ['DRAXON_KEY']}"}
created = requests.post(
"https://draxon.one/api/captcha/v1/tasks",
headers=headers,
json={
"type": "standard_hcaptcha",
"website_url": "https://example.com/login",
"website_key": "10000000-ffff-ffff-ffff-000000000001",
},
).json()
task = requests.get(
f"https://draxon.one/api/captcha/v1/tasks/{created['id']}",
headers=headers,
params={"wait": 60},
timeout=70,
).json()
if task["status"] == "solved":
print("Token:", task["solution"]["token"])
else:
print("Not solved:", task["status"], task["error"]) # you were not charged
JavaScript
const headers = {
Authorization: `Bearer ${process.env.DRAXON_KEY}`,
"Content-Type": "application/json",
};
const created = await (await fetch("https://draxon.one/api/captcha/v1/tasks", {
method: "POST",
headers,
body: JSON.stringify({
type: "standard_hcaptcha",
website_url: "https://example.com/login",
website_key: "10000000-ffff-ffff-ffff-000000000001",
}),
})).json();
const task = await (await fetch(`https://draxon.one/api/captcha/v1/tasks/${created.id}?wait=60`, { headers })).json();
if (task.status === "solved") console.log("Token:", task.solution.token);
else console.log("Not solved:", task.status, task.error); // you were not charged
Expected output (the last request):
{
"id": "7b8a5b2c-623b-410a-8677-2b7e56230f21",
"type": "standard_hcaptcha",
"status": "solved",
"cost_micros": 4000,
"cost_usd": "0.004000",
"charged_micros": 4000,
"solution": {
"token": "P1_eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...",
"user_agent": "Mozilla/5.0 ..."
},
"error": null
}
Solve via 2Captcha compatible endpoints
curl
TASK_ID=$(curl -s "https://draxon.one/api/captcha/compat/in.php?key=$DRAXON_KEY&method=hcaptcha&sitekey=10000000-ffff-ffff-ffff-000000000001&pageurl=https://example.com/login&json=1" | jq -r .request)
sleep 5
curl -s "https://draxon.one/api/captcha/compat/res.php?key=$DRAXON_KEY&action=get&id=$TASK_ID&json=1"
Python
import os, time, requests
key = os.environ["DRAXON_KEY"]
in_data = requests.get(
"https://draxon.one/api/captcha/compat/in.php",
params={"key": key, "method": "hcaptcha", "sitekey": "10000000-ffff-ffff-ffff-000000000001", "pageurl": "https://example.com/login", "json": 1},
).json()
task_id = in_data["request"]
for _ in range(30):
time.sleep(3)
out = requests.get(
"https://draxon.one/api/captcha/compat/res.php",
params={"key": key, "action": "get", "id": task_id, "json": 1},
).json()
if out.get("status") == 1:
print("Token:", out["request"])
break
JavaScript
const key = process.env.DRAXON_KEY;
const inUrl = `https://draxon.one/api/captcha/compat/in.php?key=${key}&method=hcaptcha&sitekey=10000000-ffff-ffff-ffff-000000000001&pageurl=https://example.com/login&json=1`;
const { request: taskId } = await (await fetch(inUrl)).json();
for (let i = 0; i < 30; i++) {
await new Promise((r) => setTimeout(r, 3000));
const out = await (await fetch(`https://draxon.one/api/captcha/compat/res.php?key=${key}&action=get&id=${taskId}&json=1`)).json();
if (out.status === 1) {
console.log("Token:", out.request);
break;
}
}
Expected output:
{
"status": 1,
"request": "P1_eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9..."
}
Create an inbox and wait for a code
curl
ADDR=$(curl -s -X POST https://draxon.one/api/mail/v1/mailboxes \
-H "Authorization: Bearer $DRAXON_KEY" \
-H "Content-Type: application/json" \
-d '{"count":1}' | jq -r '.data[0].address')
curl -s -H "Authorization: Bearer $DRAXON_KEY" \
"https://draxon.one/api/mail/v1/mailboxes/$ADDR/messages/wait?timeout=60"
Python
import os, requests
headers = {"Authorization": f"Bearer {os.environ['DRAXON_KEY']}"}
res = requests.post("https://draxon.one/api/mail/v1/mailboxes", headers=headers, json={"count": 1}).json()
address = res["data"][0]["address"]
wait_res = requests.get(
f"https://draxon.one/api/mail/v1/mailboxes/{address}/messages/wait",
headers=headers,
params={"timeout": 60},
).json()
if wait_res.get("message"):
print("Codes:", wait_res["message"]["codes"])
JavaScript
const headers = { Authorization: `Bearer ${process.env.DRAXON_KEY}` };
const createRes = await (await fetch("https://draxon.one/api/mail/v1/mailboxes", {
method: "POST",
headers: { ...headers, "Content-Type": "application/json" },
body: JSON.stringify({ count: 1 }),
})).json();
const address = createRes.data[0].address;
const { message } = await (await fetch(`https://draxon.one/api/mail/v1/mailboxes/${address}/messages/wait?timeout=60`, { headers })).json();
if (message) console.log("Codes:", message.codes);
Expected output:
{
"message": {
"subject": "Verify your email",
"codes": ["482913"],
"links": ["https://example.com/verify?token=..."]
}
}
Receive and verify a webhook
Every notification has a header X-Draxon-Signature that looks like t=<timestamp>,v1=<signature>. The signature is an HMAC SHA-256 of <timestamp>.<raw body> made with your signing secret (whsec_...). Check it before you trust the message, and answer with a 2xx status.
Python (standard library)
import hmac, hashlib, json, time
from http.server import HTTPServer, BaseHTTPRequestHandler
WEBHOOK_SECRET = "whsec_your_secret_here"
class Handler(BaseHTTPRequestHandler):
def do_POST(self):
body = self.rfile.read(int(self.headers.get("Content-Length", 0)))
header = self.headers.get("X-Draxon-Signature", "")
parts = dict(p.split("=", 1) for p in header.split(",") if "=" in p)
ts, sig = parts.get("t", ""), parts.get("v1", "")
if not ts.isdigit() or abs(time.time() - int(ts)) > 300:
self.send_response(400); return self.end_headers()
expected = hmac.new(WEBHOOK_SECRET.encode(), f"{ts}.".encode() + body, hashlib.sha256).hexdigest()
if not hmac.compare_digest(sig, expected):
self.send_response(400); return self.end_headers()
event = json.loads(body.decode())
print("Received valid webhook:", event["type"])
self.send_response(200); self.end_headers()
HTTPServer(("0.0.0.0", 8080), Handler).serve_forever()
JavaScript (Node.js http)
const http = require("node:http");
const crypto = require("node:crypto");
const WEBHOOK_SECRET = "whsec_your_secret_here";
http.createServer(async (req, res) => {
if (req.method !== "POST") return res.writeHead(405).end();
const chunks = [];
for await (const chunk of req) chunks.push(chunk);
const body = Buffer.concat(chunks);
const parts = Object.fromEntries(
String(req.headers["x-draxon-signature"] || "").split(",").map((p) => p.split("=")),
);
const ts = parts.t || "";
const sig = parts.v1 || "";
if (!/^\d+$/.test(ts) || Math.abs(Date.now() / 1000 - Number(ts)) > 300) {
return res.writeHead(400).end("Expired");
}
const expected = crypto.createHmac("sha256", WEBHOOK_SECRET).update(`${ts}.`).update(body).digest("hex");
const sigBuf = Buffer.from(sig);
const expBuf = Buffer.from(expected);
if (sigBuf.length !== expBuf.length || !crypto.timingSafeEqual(sigBuf, expBuf)) {
return res.writeHead(400).end("Invalid signature");
}
const event = JSON.parse(body.toString("utf-8"));
console.log("Received valid webhook:", event.type);
res.writeHead(200).end("OK");
}).listen(8080);
Expected output:
Received valid webhook: mail.message.received