Balance Request
You can retrieve your account balance by making a GET request to the following endpoint:
GET https://api.veritel.io/get-balance?token=$token
Parameters
| Field | Type | Required | Value |
|---|---|---|---|
| token | String | yes | Your API key |
Result
A successful request will return a JSON object with your current balance:
{
"success": true,
"response": {
"balance": "9.63",
"temporary_balance": "0.27"
}
}
Possible Errors
If the request fails, you will receive an error response:
{
"success": false,
"error_code": "wrong_token",
"error_msg": "Wrong token!"
}
Example Code
Below is an example of how to make a balance request using modern JavaScript (Fetch API):
async function getBalance(apiUrl, token) {
try {
const url = `${apiUrl}/get-balance?token=${token}`;
const response = await fetch(url, {
method: 'GET',
headers: {
'Content-Type': 'application/json'
}
});
if (response.ok) {
const data = await response.json();
console.log('Balance:', data.response.balance);
return data.response.balance;
} else {
const errorData = await response.json();
throw new Error(`Error: ${errorData.error_msg}`);
}
} catch (error) {
console.error('Error:', error.message);
throw error;
}
}
// Example usage
const apiUrl = 'https://api.veritel.io';
const token = 'your_api_key_here';
getBalance(apiUrl, token)
.then(balance => console.log(`Your balance is: ${balance}`))
.catch(error => console.error(`Failed to retrieve balance: ${error.message}`));
Security
- APIKey: Ensure to use your correct API key when making requests.
Responses
- 200 OK: The request was successful. Example response:
{
"success": true,
"response": {
"balance": "9.63",
"temporary_balance": "0.27"
}
} - Error Response: Example response for an incorrect token:
{
"success": false,
"error_code": "wrong_token",
"error_msg": "Wrong token!"
}