Get Account Balance
curl --request GET \
--url https://api.oneclickdz.com/v3/account/balance \
--header 'X-Access-Token: <api-key>'import requests
url = "https://api.oneclickdz.com/v3/account/balance"
headers = {"X-Access-Token": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'X-Access-Token': '<api-key>'}};
fetch('https://api.oneclickdz.com/v3/account/balance', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.oneclickdz.com/v3/account/balance",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"X-Access-Token: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.oneclickdz.com/v3/account/balance"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("X-Access-Token", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.oneclickdz.com/v3/account/balance")
.header("X-Access-Token", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.oneclickdz.com/v3/account/balance")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["X-Access-Token"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"balance": 123
},
"meta": {
"timestamp": "<string>"
}
}Account
Get Account Balance
Retrieve your current account balance
GET
/
v3
/
account
/
balance
Get Account Balance
curl --request GET \
--url https://api.oneclickdz.com/v3/account/balance \
--header 'X-Access-Token: <api-key>'import requests
url = "https://api.oneclickdz.com/v3/account/balance"
headers = {"X-Access-Token": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'X-Access-Token': '<api-key>'}};
fetch('https://api.oneclickdz.com/v3/account/balance', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.oneclickdz.com/v3/account/balance",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"X-Access-Token: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.oneclickdz.com/v3/account/balance"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("X-Access-Token", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.oneclickdz.com/v3/account/balance")
.header("X-Access-Token", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.oneclickdz.com/v3/account/balance")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["X-Access-Token"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"balance": 123
},
"meta": {
"timestamp": "<string>"
}
}Overview
Get your current account balance in Algerian Dinar (DZD). The balance represents available funds that can be used for top-ups, orders, and other services.When your balance reaches a low threshold, a notification will be sent to your
registered email address.
Response
boolean
required
true for successful requestsExample Request
curl --request GET \
--url https://api.oneclickdz.com/v3/account/balance \
--header 'X-Access-Token: YOUR_API_KEY'
const response = await fetch("https://api.oneclickdz.com/v3/account/balance", {
headers: {
"X-Access-Token": process.env.ONECLICKDZ_API_KEY,
},
});
const data = await response.json();
if (data.success) {
console.log(`Balance: ${data.data.balance} DZD`);
}
import requests
import os
response = requests.get(
'https://api.oneclickdz.com/v3/account/balance',
headers={'X-Access-Token': os.getenv('ONECLICKDZ_API_KEY')}
)
data = response.json()
if data['success']:
print(f"Balance: {data['data']['balance']} DZD")
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.oneclickdz.com/v3/account/balance');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'X-Access-Token: ' . getenv('ONECLICKDZ_API_KEY')
]);
$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response, true);
if ($data['success']) {
echo "Balance: " . $data['data']['balance'] . " DZD\n";
}
?>
Example Response
{
"success": true,
"data": {
"balance": 1326.13
},
"meta": {
"timestamp": "2025-10-29T00:35:58.710Z"
}
}
Use Cases
Pre-Transaction Check
Verify sufficient funds before processing orders
Balance Display
Show current balance in your application UI
Low Balance Alerts
Monitor balance and alert when running low
Financial Reports
Track balance changes over time
Integration Examples
Pre-Transaction Validation
async function canProcessTransaction(amount) {
const response = await fetch(
"https://api.oneclickdz.com/v3/account/balance",
{
headers: { "X-Access-Token": API_KEY },
}
);
const data = await response.json();
if (!data.success) {
throw new Error("Failed to check balance");
}
const balance = data.data.balance;
if (balance < amount) {
throw new Error(
`Insufficient balance. Required: ${amount} DZD, Available: ${balance} DZD`
);
}
return true;
}
// Usage
try {
await canProcessTransaction(500);
// Proceed with transaction
} catch (error) {
console.error(error.message);
// Show error to user
}
Balance Monitoring
class BalanceMonitor {
constructor(apiKey, lowBalanceThreshold = 1000) {
this.apiKey = apiKey;
this.lowBalanceThreshold = lowBalanceThreshold;
this.lastBalance = null;
}
async checkBalance() {
const response = await fetch(
"https://api.oneclickdz.com/v3/account/balance",
{
headers: { "X-Access-Token": this.apiKey },
}
);
const data = await response.json();
if (!data.success) {
console.error("Failed to check balance:", data.error);
return;
}
const currentBalance = data.data.balance;
// Check for low balance
if (currentBalance < this.lowBalanceThreshold) {
this.onLowBalance(currentBalance);
}
// Check for significant changes
if (this.lastBalance !== null) {
const change = currentBalance - this.lastBalance;
if (Math.abs(change) > 100) {
this.onBalanceChange(change, currentBalance);
}
}
this.lastBalance = currentBalance;
return currentBalance;
}
onLowBalance(balance) {
console.warn(`⚠️ Low balance alert: ${balance} DZD`);
// Send notification to admin
this.sendNotification({
type: "low_balance",
balance: balance,
threshold: this.lowBalanceThreshold,
});
}
onBalanceChange(change, newBalance) {
const changeType = change > 0 ? "increased" : "decreased";
console.log(
`Balance ${changeType} by ${Math.abs(
change
)} DZD. New balance: ${newBalance} DZD`
);
}
sendNotification(data) {
// Implement your notification logic
console.log("Notification:", data);
}
startMonitoring(intervalMinutes = 5) {
// Initial check
this.checkBalance();
// Periodic checks
setInterval(() => {
this.checkBalance();
}, intervalMinutes * 60 * 1000);
}
}
// Usage
const monitor = new BalanceMonitor(API_KEY, 1000);
monitor.startMonitoring(5); // Check every 5 minutes
Balance Caching
class BalanceCache {
constructor(apiKey, cacheSeconds = 30) {
this.apiKey = apiKey;
this.cacheSeconds = cacheSeconds;
this.cache = {
balance: null,
timestamp: 0,
};
}
async getBalance(forceRefresh = false) {
const now = Date.now();
const cacheAge = (now - this.cache.timestamp) / 1000;
// Return cached value if valid
if (
!forceRefresh &&
this.cache.balance !== null &&
cacheAge < this.cacheSeconds
) {
return this.cache.balance;
}
// Fetch fresh balance
const response = await fetch(
"https://api.oneclickdz.com/v3/account/balance",
{
headers: { "X-Access-Token": this.apiKey },
}
);
const data = await response.json();
if (!data.success) {
throw new Error(`Failed to fetch balance: ${data.error.message}`);
}
// Update cache
this.cache = {
balance: data.data.balance,
timestamp: now,
};
return this.cache.balance;
}
invalidateCache() {
this.cache.timestamp = 0;
}
}
// Usage
const balanceCache = new BalanceCache(API_KEY, 30);
// First call - fetches from API
const balance1 = await balanceCache.getBalance();
// Second call within 30 seconds - returns cached value
const balance2 = await balanceCache.getBalance();
// Force refresh
const balance3 = await balanceCache.getBalance(true);
Best Practices
Check Before Transactions
Check Before Transactions
Always verify sufficient balance before initiating transactions
// ✅ Good
const balance = await getBalance();
if (balance >= requiredAmount) {
await sendTopUp(...);
}
// ❌ Bad
await sendTopUp(...); // Might fail with NO_BALANCE error
Cache Wisely
Cache Wisely
Cache balance for 30-60 seconds to reduce API calls
javascript // Cache balance but invalidate after transactions const balance = await balanceCache.getBalance(); await sendTopUp(...); balanceCache.invalidateCache(); // Refresh after transaction Handle Errors Gracefully
Handle Errors Gracefully
Implement proper error handling
async function getSafeBalance() {
try {
const response = await fetch('https://api.oneclickdz.com/v3/account/balance', {
headers: { 'X-Access-Token': API_KEY }
});
const data = await response.json();
if (!data.success) {
console.error('Balance check failed:', data.error);
return null;
}
return data.data.balance;
} catch (error) {
console.error('Network error:', error);
return null;
}
}
Monitor Low Balance
Monitor Low Balance
Set up alerts for low balance
const LOW_BALANCE_THRESHOLD = 1000;
async function checkAndAlert() {
const balance = await getBalance();
if (balance < LOW_BALANCE_THRESHOLD) {
await sendAlert({
type: 'low_balance',
balance: balance,
message: `Balance is low: ${balance} DZD`
});
}
}
Error Responses
401 - Unauthorized
401 - Unauthorized
{
"success": false,
"error": {
"code": "INVALID_ACCESS_TOKEN",
"message": "The provided access token is invalid"
},
"requestId": "req_abc123"
}
500 - Internal Server Error
500 - Internal Server Error
{
"success": false,
"error": {
"code": "INTERNAL_SERVER_ERROR",
"message": "Developer was notified and will check shortly"
},
"requestId": "req_abc123"
}
Related Endpoints
List Transactions
View transaction history
Send Mobile Top-Up
Send a mobile top-up
⌘I

