Balance Check API
Check your payin and payout wallet balances.
Check Balance
GET https://api.payvanta.in/balance-checkAuthentication
This endpoint requires Bearer token authentication. The token should be generated by Base64 encoding your API credentials in the format api_key:api_secret.
Authorization: Bearer <base64_encoded_credentials>
Content-Type: application/jsonRequest Headers
| Header | Value | Required |
|---|---|---|
| Authorization | Bearer {token} | Yes |
| Content-Type | application/json | Yes |
Response
Success Response (200 OK)
{
"payin_balance": 490,
"payout_balance": 6.602000000000004
}Response Fields
| Field | Type | Description |
|---|---|---|
payin_balance | number | Available balance for payin operations |
payout_balance | number | Available balance for payout operations |
Error Responses
Unauthorized (401)
{
"success": false,
"message": "UNAUTHORIZED",
"error": "Invalid authentication credentials"
}Forbidden (403)
{
"success": false,
"message": "FORBIDDEN",
"error": "Access denied"
}Server Error (500)
{
"success": false,
"message": "INTERNAL_SERVER_ERROR",
"error": "Failed to retrieve balance information"
}Code Examples
cURL
curl -X GET https://api.payvanta.in/balance-check \
-H "Authorization: Bearer YXBpX2tleTphcGlfc2VjcmV0" \
-H "Content-Type: application/json"Python
import requests
import base64
# Generate Bearer token
api_key = "your_api_key"
api_secret = "your_api_secret"
credentials = f"{api_key}:{api_secret}"
token = base64.b64encode(credentials.encode()).decode()
# API endpoint
url = "https://api.payvanta.in/balance-check"
# Request headers
headers = {
"Authorization": f"Bearer {token}",
"Content-Type": "application/json"
}
# Make the request
response = requests.get(url, headers=headers)
print(response.json())
# Example response handling
if response.status_code == 200:
balance_data = response.json()
print(f"Payin Balance: {balance_data['payin_balance']}")
print(f"Payout Balance: {balance_data['payout_balance']}")
else:
print(f"Error: {response.status_code}")Node.js
const axios = require('axios');
// Generate Bearer token
const apiKey = 'your_api_key';
const apiSecret = 'your_api_secret';
const credentials = `${apiKey}:${apiSecret}`;
const token = Buffer.from(credentials).toString('base64');
// API endpoint
const url = 'https://api.payvanta.in/balance-check';
// Request headers
const headers = {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
};
// Make the request
axios.get(url, { headers })
.then(response => {
console.log('Balance Data:', response.data);
console.log(`Payin Balance: ${response.data.payin_balance}`);
console.log(`Payout Balance: ${response.data.payout_balance}`);
})
.catch(error => {
console.error('Error:', error.response?.data || error.message);
});PHP
<?php
// Generate Bearer token
$api_key = "your_api_key";
$api_secret = "your_api_secret";
$credentials = $api_key . ":" . $api_secret;
$token = base64_encode($credentials);
// API endpoint
$url = "https://api.payvanta.in/balance-check";
// Request headers
$headers = [
"Authorization: Bearer " . $token,
"Content-Type: application/json"
];
// Make the request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($http_code == 200) {
$balance_data = json_decode($response, true);
echo "Payin Balance: " . $balance_data['payin_balance'] . "\n";
echo "Payout Balance: " . $balance_data['payout_balance'] . "\n";
} else {
echo "Error: " . $response . "\n";
}
?>Usage Examples
Check Balance Before Transaction
async function checkBalanceBeforeTransaction(amount, type) {
try {
const balance = await getBalance();
if (type === 'payout' && balance.payout_balance < amount) {
throw new Error('Insufficient payout balance');
}
console.log(`Available ${type} balance: ${balance[type + '_balance']}`);
return true;
} catch (error) {
console.error('Balance check failed:', error.message);
return false;
}
}
// Usage
const canProcessPayout = await checkBalanceBeforeTransaction(100, 'payout');
if (canProcessPayout) {
// Proceed with payout
}Monitor Balance Regularly
async function monitorBalance() {
try {
const balance = await getBalance();
// Alert if balance is low
if (balance.payout_balance < 100) {
console.warn('Low payout balance:', balance.payout_balance);
// Send notification or alert
}
if (balance.payin_balance < 50) {
console.warn('Low payin balance:', balance.payin_balance);
// Send notification or alert
}
return balance;
} catch (error) {
console.error('Balance monitoring failed:', error.message);
}
}
// Monitor every 5 minutes
setInterval(monitorBalance, 5 * 60 * 1000);Rate Limits
| Endpoint | Limit |
|---|---|
| GET /balance-check | 100/min |
Best Practices
-
Regular Monitoring
- Check balance before processing large transactions
- Set up automated balance alerts
- Monitor balance trends
-
Error Handling
- Implement retry logic for network failures
- Handle authentication errors gracefully
- Log balance check failures for debugging
-
Security
- Store API credentials securely
- Use HTTPS for all requests
- Implement rate limiting on your side
-
Integration
- Cache balance data for short periods to reduce API calls
- Update balance after successful transactions
- Use balance data for transaction validation
Related APIs
- Payin API - Collect payments
- Payouts API - Send money
- Status API - Check transaction status
Support
For technical issues or questions about the Balance Check API, contact support@payvanta.in