Verify by Base64
Verify a bank slip using a Base64-encoded image.
Endpoint
http
POST /verify/bankFull URL: https://api.easyslip.com/v2/verify/bank
Authentication
Required. See Authentication Guide.
http
Authorization: Bearer YOUR_API_KEY
Content-Type: application/jsonRequest
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
base64 | string | Yes | Base64 encoded image (with or without data URI prefix) |
remark | string | No | Custom remark (1-255 characters) |
matchAccount | boolean | No | Match receiver with registered accounts |
matchAmount | number | No | Expected amount to validate |
checkDuplicate | boolean | No | Check for duplicate slip |
Base64 Format
Both formats are accepted:
# With data URI prefix
data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAA...
# Without prefix
/9j/4AAQSkZJRgABAQAA...Image Requirements
| Requirement | Value |
|---|---|
| Maximum decoded size | 4 MB |
| Supported formats | JPEG, PNG, GIF, WebP |
Type Definitions
typescript
// Request
interface VerifyByBase64Request {
base64: string; // Base64 encoded image
remark?: string; // 1-255 chars
matchAccount?: boolean;
matchAmount?: number;
checkDuplicate?: boolean;
}
// Response
interface VerifyBankResponse {
success: true;
data: VerifyBankData;
message: string;
}
interface VerifyBankData {
remark?: string;
isDuplicate: boolean;
matchedAccount: MatchedAccount | null;
amountInOrder?: number;
amountInSlip: number;
isAmountMatched?: boolean;
rawSlip: RawSlip;
}
// See POST /verify/bank for full type definitionsExamples
bash
curl -X POST https://api.easyslip.com/v2/verify/bank \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"base64": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAA...",
"checkDuplicate": true
}'javascript
// Convert file to Base64
const fileToBase64 = (file) => {
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.onload = () => resolve(reader.result);
reader.onerror = reject;
reader.readAsDataURL(file);
});
};
// Verify slip
const verifyByBase64 = async (base64, options = {}) => {
const response = await fetch('https://api.easyslip.com/v2/verify/bank', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({ base64, ...options })
});
const result = await response.json();
if (!result.success) {
throw new Error(result.error.message);
}
return result.data;
};
// Usage with file input
const fileInput = document.getElementById('slipImage');
fileInput.addEventListener('change', async (e) => {
const file = e.target.files[0];
const base64 = await fileToBase64(file);
try {
const slip = await verifyByBase64(base64, { checkDuplicate: true });
console.log('Amount:', slip.rawSlip.amount.amount);
} catch (error) {
console.error('Error:', error.message);
}
});javascript
import fs from 'fs';
const verifyByBase64 = async (base64, options = {}) => {
const response = await fetch('https://api.easyslip.com/v2/verify/bank', {
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.EASYSLIP_API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({ base64, ...options })
});
const result = await response.json();
if (!result.success) {
throw new Error(result.error.message);
}
return result.data;
};
// Usage with file
const imageBuffer = fs.readFileSync('./slip.jpg');
const base64 = imageBuffer.toString('base64');
const slip = await verifyByBase64(base64, { checkDuplicate: true });
console.log('Amount:', slip.rawSlip.amount.amount);php
function verifyByBase64(string $base64, array $options = []): array
{
$apiKey = getenv('EASYSLIP_API_KEY');
$data = array_merge(['base64' => $base64], $options);
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => 'https://api.easyslip.com/v2/verify/bank',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json'
],
CURLOPT_POSTFIELDS => json_encode($data)
]);
$response = curl_exec($ch);
curl_close($ch);
$result = json_decode($response, true);
if (!$result['success']) {
throw new Exception($result['error']['message']);
}
return $result['data'];
}
// Usage with file
$imageData = file_get_contents('/path/to/slip.jpg');
$base64 = base64_encode($imageData);
$slip = verifyByBase64($base64, ['checkDuplicate' => true]);
echo "Amount: " . $slip['rawSlip']['amount']['amount'];python
import requests
import base64
import os
def verify_by_base64(base64_data: str, **options) -> dict:
response = requests.post(
'https://api.easyslip.com/v2/verify/bank',
headers={
'Authorization': f'Bearer {os.environ["EASYSLIP_API_KEY"]}',
'Content-Type': 'application/json'
},
json={'base64': base64_data, **options}
)
result = response.json()
if not result['success']:
raise Exception(result['error']['message'])
return result['data']
# Usage with file
with open('./slip.jpg', 'rb') as f:
image_data = f.read()
base64_data = base64.b64encode(image_data).decode('utf-8')
slip = verify_by_base64(base64_data, checkDuplicate=True)
print(f"Amount: {slip['rawSlip']['amount']['amount']}")Response
Success (200)
json
{
"success": true,
"data": {
"isDuplicate": false,
"rawSlip": {
"payload": "00000000000000000000000000000000000000000000000",
"transRef": "68370160657749I376388B35",
"date": "2024-01-15T14:30:00+07:00",
"amount": {
"amount": 1500.00
},
"sender": {
"bank": { "id": "004", "name": "กสิกรไทย", "short": "KBANK" },
"account": { "name": { "th": "นาย ผู้โอน ทดสอบ" } }
},
"receiver": {
"bank": { "id": "014", "name": "ไทยพาณิชย์", "short": "SCB" },
"account": { "name": { "th": "นาย รับเงิน ทดสอบ" } }
}
}
},
"message": "Bank slip verified successfully"
}Error Responses
Invalid Base64 (400)
json
{
"success": false,
"error": {
"code": "VALIDATION_ERROR",
"message": "Invalid Base64 data"
}
}Image Size Too Large (400)
json
{
"success": false,
"error": {
"code": "IMAGE_SIZE_TOO_LARGE",
"message": "Image size exceeds 4MB limit"
}
}Notes
- Compress images before encoding to reduce payload size
- Use JPEG quality 0.7-0.9 for sufficient quality
- Including the data URI prefix helps with MIME type detection
- Clear Base64 strings from memory after use in sensitive applications