Request a QR code
Start by requesting a QR session from your server-side integration layer. The response returns the QR image as a data URI, a token for polling, and an expiresIn value in seconds. The data URI below is truncated; at runtime it holds the full base64 PNG.
const API_BASE_URL = 'https://api.wahdx.com';
const API_KEY = process.env.WAHDX_API_KEY;
await fetch(API_BASE_URL + '/api/content/qr-login/request', {
method: 'POST',
headers: {
'X-API-Key': API_KEY,
'Content-Type': 'application/json'
},
body: JSON.stringify({
unique_id: 'my_session_12345'
})
});
import os
import requests
API_BASE_URL = 'https://api.wahdx.com'
API_KEY = os.environ['WAHDX_API_KEY']
response = requests.post(
API_BASE_URL + '/api/content/qr-login/request',
headers={
'X-API-Key': API_KEY,
'Content-Type': 'application/json',
},
json={
'unique_id': 'my_session_12345',
},
timeout=30,
)
response.raise_for_status()
print(response.json())
curl -X POST "https://api.wahdx.com/api/content/qr-login/request" \
-H "X-API-Key: $WAHDX_API_KEY" \
-H "Content-Type: application/json" \
--data-raw '{
"unique_id": "my_session_12345"
}'
Example response · 200
{
"success": true,
"data": {
"qrCodeImage": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZAAAAGQCAYAAAC... (base64 PNG)",
"token": "TOKEN_FROM_STEP_1",
"unique_id": "my_session_12345",
"expiresIn": 300
}
}
Poll QR status
After displaying the QR image to the user, poll every 2-3 seconds and always stop polling when the response is not OK, the session expires, the account is confirmed, the code is already used, or 5 minutes have passed. The confirmed response returns the connected account, while new, scanned, and expired return only the status and unique_id.
const API_BASE_URL = 'https://api.wahdx.com';
const API_KEY = process.env.WAHDX_API_KEY;
const qrToken = 'TOKEN_FROM_STEP_1';
const startedAt = Date.now();
const maxPollingMs = 5 * 60 * 1000;
const intervalId = setInterval(async () => {
if (Date.now() - startedAt > maxPollingMs) {
clearInterval(intervalId);
return;
}
const response = await fetch(API_BASE_URL + '/api/content/qr-login/check', {
method: 'POST',
headers: {
'X-API-Key': API_KEY,
'Content-Type': 'application/json'
},
body: JSON.stringify({ token: qrToken })
});
const result = await response.json();
const status = result?.data?.status;
if (!response.ok || ['confirmed', 'expired', 'utilised'].includes(status)) {
clearInterval(intervalId);
}
}, 3000);
import os
import time
import requests
API_BASE_URL = 'https://api.wahdx.com'
API_KEY = os.environ['WAHDX_API_KEY']
QR_TOKEN = 'TOKEN_FROM_STEP_1'
STARTED_AT = time.time()
MAX_POLLING_SECONDS = 5 * 60
while time.time() - STARTED_AT < MAX_POLLING_SECONDS:
response = requests.post(
API_BASE_URL + '/api/content/qr-login/check',
headers={
'X-API-Key': API_KEY,
'Content-Type': 'application/json',
},
json={'token': QR_TOKEN},
timeout=30,
)
result = response.json()
status = result.get('data', {}).get('status')
print(result)
if not response.ok or status in ('confirmed', 'expired', 'utilised'):
break
time.sleep(3)
curl -X POST "https://api.wahdx.com/api/content/qr-login/check" \
-H "X-API-Key: $WAHDX_API_KEY" \
-H "Content-Type: application/json" \
--data-raw '{
"token": "TOKEN_FROM_STEP_1"
}'
Example response · 200
{
"success": true,
"data": {
"status": "confirmed",
"unique_id": "my_session_12345",
"account": {
"accountId": "5f9c2a10-1b2c-4d3e-8f90-abcdef123456",
"display_name": "Wahdx Creator",
"username": "wahdx_creator"
}
}
}