The Balance API allows you to retrieve the current balance and balance-related settings for the authenticated user.
Authentication Required: This endpoint requires a valid secret key for authentication.
Retrieves the current balance and balance-related settings for the authenticated user.
GET https://api.lunos.tech/v1/balance
This endpoint requires authentication using a secret key in the Authorization header.
Header | Type | Required | Description |
---|---|---|---|
Authorization | string | Yes | Bearer token containing your secret key |
1curl -X GET "https://api.lunos.tech/v1/balance" \
2 -H "Authorization: Bearer YOUR_SECRET_KEY" \
3 -H "Content-Type: application/json"
1{
2 "success": true,
3 "message": "Balance retrieved successfully",
4 "data": {
5 "balance": 10.5,
6 "email": "user@example.com",
7 "alertBalance": 1.0,
8 "enableAlert": 1,
9 "updatedAt": "2024-01-15T10:30:00.000Z",
10 "isAlertEnabled": true,
11 "isBalanceLow": false
12 }
13}
Field | Type | Description |
---|---|---|
success | boolean | Indicates if the request was successful |
message | string | Success message describing the operation |
data.balance | number | Current balance in credits |
data.email | string | User's email address |
data.alertBalance | number | Threshold for balance alerts |
data.enableAlert | number | Whether alerts are enabled (1 = enabled, 0 = disabled) |
data.updatedAt | string | Last update timestamp |
data.isAlertEnabled | boolean | Whether balance alerts are enabled |
data.isBalanceLow | boolean | Whether balance is below the alert threshold |
1{
2 "success": false,
3 "message": "Missing or invalid secret key",
4 "error": "UNAUTHORIZED"
5}
1{
2 "success": false,
3 "message": "Secret key expired",
4 "error": "UNAUTHORIZED"
5}
1{
2 "success": false,
3 "message": "Internal server error",
4 "error": "INTERNAL_ERROR"
5}
1const response = await fetch('https://api.lunos.tech/v1/balance', {
2 method: 'GET',
3 headers: {
4 'Authorization': 'Bearer YOUR_SECRET_KEY',
5 'Content-Type': 'application/json'
6 }
7});
8
9const data = await response.json();
10console.log('Current balance:', data.data.balance);
1import requests
2
3response = requests.get(
4 'https://api.lunos.tech/v1/balance',
5 headers={
6 'Authorization': 'Bearer YOUR_SECRET_KEY',
7 'Content-Type': 'application/json'
8 }
9)
10
11data = response.json()
12print(f"Current balance: {data['data']['balance']}")
1<?php
2$ch = curl_init();
3curl_setopt($ch, CURLOPT_URL, 'https://api.lunos.tech/v1/balance');
4curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
5curl_setopt($ch, CURLOPT_HTTPHEADER, [
6 'Authorization: Bearer YOUR_SECRET_KEY',
7 'Content-Type: application/json'
8]);
9
10$response = curl_exec($ch);
11curl_close($ch);
12
13$data = json_decode($response, true);
14echo "Current balance: " . $data['data']['balance'];
15?>
Note: If no balance record exists for the user, one will be automatically created with 0 balance.
For more information about other API endpoints, please refer to:
No headings found on this page.