API Reference
Balance Check

Balance Check API

Check your payin and payout wallet balances.

Check Balance

GET https://api.payvanta.in/balance-check

Authentication

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/json

Request Headers

HeaderValueRequired
AuthorizationBearer {token}Yes
Content-Typeapplication/jsonYes

Response

Success Response (200 OK)

{
    "payin_balance": 490,
    "payout_balance": 6.602000000000004
}

Response Fields

FieldTypeDescription
payin_balancenumberAvailable balance for payin operations
payout_balancenumberAvailable 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

EndpointLimit
GET /balance-check100/min

Best Practices

  1. Regular Monitoring

    • Check balance before processing large transactions
    • Set up automated balance alerts
    • Monitor balance trends
  2. Error Handling

    • Implement retry logic for network failures
    • Handle authentication errors gracefully
    • Log balance check failures for debugging
  3. Security

    • Store API credentials securely
    • Use HTTPS for all requests
    • Implement rate limiting on your side
  4. Integration

    • Cache balance data for short periods to reduce API calls
    • Update balance after successful transactions
    • Use balance data for transaction validation

Related APIs

Support

For technical issues or questions about the Balance Check API, contact support@payvanta.in