Skip to content

GET /info

ดูข้อมูลเกี่ยวกับแอปพลิเคชัน, Branch และการใช้โควต้า

Endpoint

http
GET /info

URL เต็ม: https://api.easyslip.com/v2/info

การยืนยันตัวตน

จำเป็น ใช้ HMAC-SHA256 กับ Branch UUID เป็น X-API-Key ดูคู่มือ Authentication

Headerคำอธิบาย
X-API-KeyBranch UUID ของคุณ
X-TimestampUnix Timestamp (วินาที)
X-NonceUUID v4 ไม่ซ้ำต่อ Request
X-SignatureHMAC-SHA256 Signature

Request

ไม่ต้องมี Request Body

Type Definitions

typescript
// Response Types
interface InfoResponse {
  success: true;
  data: InfoData;
  message: string;
}

interface InfoData {
  application: Application;
  branch: Branch;
  account: Account;
  product: Product;
}

interface Application {
  name: string;
  autoRenew: AutoRenew;
  quota: ApplicationQuota;
}

interface AutoRenew {
  expired: boolean;
  quota: boolean;
  createdAt: string;   // ISO 8601
  expiresAt: string;   // ISO 8601
}

interface ApplicationQuota {
  used: number;
  max: number | null;       // null = ไม่จำกัด
  remaining: number | null;
  totalUsed: number;
}

interface Branch {
  name: string;
  isActive: boolean;
  quota: BranchQuota;
}

interface BranchQuota {
  used: number;
  totalUsed: number;
}

interface Account {
  email: string;
  credit: number;
}

interface Product {
  name: string;
}

// Error Response
interface ErrorResponse {
  success: false;
  error: {
    code: string;
    message: string;
  };
}

ตัวอย่าง

bash
API_KEY="a1b2c3d4-e5f6-7890-abcd-ef1234567890"  # Branch UUID
SECRET_KEY="your_secret_key"
TIMESTAMP=$(date +%s)
NONCE=$(uuidgen | tr '[:upper:]' '[:lower:]')
BODY_HASH=$(printf '' | shasum -a 256 | cut -d' ' -f1)

STRING_TO_SIGN="GET\n/info\n${TIMESTAMP}\n${NONCE}\n${BODY_HASH}"
SIGNATURE=$(printf "${STRING_TO_SIGN}" | openssl dgst -sha256 -hmac "${SECRET_KEY}" | cut -d' ' -f2)

curl -X GET https://api.easyslip.com/v2/info \
  -H "X-API-Key: ${API_KEY}" \
  -H "X-Timestamp: ${TIMESTAMP}" \
  -H "X-Nonce: ${NONCE}" \
  -H "X-Signature: ${SIGNATURE}"
javascript
import crypto from 'crypto'

const apiKey = 'a1b2c3d4-e5f6-7890-abcd-ef1234567890' // Branch UUID
const secretKey = 'your_secret_key'
const timestamp = Math.floor(Date.now() / 1000).toString()
const nonce = crypto.randomUUID()
const bodyHash = crypto.createHash('sha256').update('').digest('hex')

const stringToSign = `GET\n/info\n${timestamp}\n${nonce}\n${bodyHash}`
const signature = crypto.createHmac('sha256', secretKey).update(stringToSign).digest('hex')

const response = await fetch('https://api.easyslip.com/v2/info', {
    headers: {
        'X-API-Key': apiKey,
        'X-Timestamp': timestamp,
        'X-Nonce': nonce,
        'X-Signature': signature,
    },
})

const result = await response.json()
console.log(result.data)
php
<?php
$apiKey = 'a1b2c3d4-e5f6-7890-abcd-ef1234567890'; // Branch UUID
$secretKey = 'your_secret_key';
$timestamp = (string) time();
$nonce = sprintf(
    '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
    mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff),
    mt_rand(0, 0x0fff) | 0x4000, mt_rand(0, 0x3fff) | 0x8000,
    mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff)
);
$bodyHash = hash('sha256', '');

$stringToSign = implode("\n", ['GET', '/info', $timestamp, $nonce, $bodyHash]);
$signature = hash_hmac('sha256', $stringToSign, $secretKey);

$ch = curl_init();
curl_setopt_array($ch, [
    CURLOPT_URL => 'https://api.easyslip.com/v2/info',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        "X-API-Key: $apiKey",
        "X-Timestamp: $timestamp",
        "X-Nonce: $nonce",
        "X-Signature: $signature",
    ],
]);

$response = curl_exec($ch);
curl_close($ch);

$result = json_decode($response, true);
print_r($result['data']);
python
import hashlib
import hmac
import time
import uuid
import requests

api_key = 'a1b2c3d4-e5f6-7890-abcd-ef1234567890'  # Branch UUID
secret_key = 'your_secret_key'
timestamp = str(int(time.time()))
nonce = str(uuid.uuid4())
body_hash = hashlib.sha256(b'').hexdigest()

string_to_sign = f'GET\n/info\n{timestamp}\n{nonce}\n{body_hash}'
signature = hmac.new(secret_key.encode(), string_to_sign.encode(), hashlib.sha256).hexdigest()

response = requests.get(
    'https://api.easyslip.com/v2/info',
    headers={
        'X-API-Key': api_key,
        'X-Timestamp': timestamp,
        'X-Nonce': nonce,
        'X-Signature': signature,
    }
)

result = response.json()
print(result['data'])

Response

Response สำเร็จ (200)

json
{
  "success": true,
  "data": {
    "application": {
      "name": "แอปพลิเคชันของฉัน",
      "autoRenew": {
        "expired": false,
        "quota": true,
        "createdAt": "2024-01-01T00:00:00+07:00",
        "expiresAt": "2025-01-01T00:00:00+07:00"
      },
      "quota": {
        "used": 1500,
        "max": 35000,
        "remaining": 33500,
        "totalUsed": 45000
      }
    },
    "branch": {
      "name": "Main Branch",
      "isActive": true,
      "quota": {
        "used": 500,
        "totalUsed": 12000
      }
    },
    "account": {
      "email": "[email protected]",
      "credit": 5000
    },
    "product": {
      "name": "Pro Plan"
    }
  },
  "message": "Information retrieved successfully"
}

ฟิลด์ใน Response

ฟิลด์ประเภทคำอธิบาย
application.namestringชื่อแอปพลิเคชัน
application.autoRenew.expiredbooleanต่ออายุอัตโนมัติเมื่อหมดอายุ
application.autoRenew.quotabooleanต่ออายุอัตโนมัติเมื่อโควต้าหมด
application.autoRenew.createdAtstringวันที่สร้าง (ISO 8601)
application.autoRenew.expiresAtstringวันหมดอายุ (ISO 8601)
application.quota.usednumberโควต้าที่ใช้ไปในรอบนี้
application.quota.maxnumber | nullโควต้าสูงสุด (null = ไม่จำกัด)
application.quota.remainingnumber | nullโควต้าที่เหลือ
application.quota.totalUsednumberโควต้าที่ใช้ทั้งหมดตลอดการใช้งาน
branch.namestringชื่อ Branch ปัจจุบัน
branch.isActivebooleanสถานะ Branch
branch.quota.usednumberโควต้าที่ใช้ของ Branch
branch.quota.totalUsednumberโควต้ารวมที่ใช้ของ Branch
account.emailstringอีเมลบัญชี
account.creditnumberเครดิตที่มี
product.namestringชื่อแพ็กเกจ

Error Responses

ไม่มี Auth Headers (401)

json
{
  "success": false,
  "error": {
    "code": "MISSING_API_KEY",
    "message": "X-API-Key header is required"
  }
}

API Key ไม่ถูกต้อง (401)

json
{
  "success": false,
  "error": {
    "code": "INVALID_API_KEY",
    "message": "The provided API key is invalid"
  }
}

Branch ไม่ได้เปิดใช้งาน (403)

json
{
  "success": false,
  "error": {
    "code": "BRANCH_INACTIVE",
    "message": "This API branch has been deactivated"
  }
}

หมายเหตุ

  • Endpoint นี้ไม่หักโควต้า
  • โควต้าจะรีเซ็ตทุกเดือนตามรอบบิล
  • max: null หมายถึงโควต้าไม่จำกัด
  • totalUsed ติดตามการใช้งานทั้งหมดตลอดทุกรอบบิล
  • โควต้า Branch ถูกติดตามแยกจากโควต้าแอปพลิเคชัน

Bank Slip Verification API for Thai Banking