API Reference / Tham chiếu API
English | Tiếng Việt
English
Base URL
Production: https://api.olympay.xyz/v1
Testnet: https://api-testnet.olympay.xyz/v1
Authentication
All API requests require authentication using your API key:
const headers = {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
};
Rate Limits
Free Tier: 100 requests/hour
Pro Tier: 1,000 requests/hour
Enterprise: 10,000 requests/hour
Endpoints
StableCoin
Get Balance
GET /stablecoin/balance/{address}
Parameters:
address
(string): Wallet addressnetwork
(string): Network (ethereum, solana, polygon)
Response:
{
"success": true,
"data": {
"address": "0x...",
"balance": "1000.00",
"network": "ethereum",
"timestamp": "2024-01-01T00:00:00Z"
}
}
Transfer Tokens
POST /stablecoin/transfer
Request Body:
{
"from": "0x...",
"to": "0x...",
"amount": "100.00",
"network": "ethereum"
}
Response:
{
"success": true,
"data": {
"transactionHash": "0x...",
"status": "pending",
"gasUsed": "21000"
}
}
On/Off Ramp
Create Ramp Request
POST /ramp/create
Request Body:
{
"type": "on-ramp",
"amount": "100.00",
"currency": "USD",
"network": "ethereum",
"paymentMethod": "credit-card"
}
Get Ramp Status
GET /ramp/status/{requestId}
CCIP Cross-Chain
Create Cross-Chain Transfer
POST /ccip/transfer
Request Body:
{
"sourceChain": "ethereum",
"destinationChain": "polygon",
"amount": "100.00",
"token": "USDC",
"recipient": "0x..."
}
Earning Platform
Get Earning Stats
GET /earning/stats/{address}
Response:
{
"success": true,
"data": {
"totalEarned": "500.00",
"activeQuests": 3,
"completedQuests": 15,
"yieldFarming": {
"totalDeposited": "1000.00",
"currentAPY": "4.2%",
"earned": "42.00"
}
}
}
Start Quest
POST /earning/quest/start
Request Body:
{
"questType": "challenger",
"category": "defi",
"difficulty": "beginner"
}
Error Handling
All API responses follow a consistent error format:
{
"success": false,
"error": {
"code": "INVALID_ADDRESS",
"message": "The provided address is invalid",
"details": {
"field": "address",
"value": "invalid-address"
}
}
}
Error Codes
INVALID_ADDRESS
Invalid wallet address
INSUFFICIENT_BALANCE
Insufficient token balance
NETWORK_ERROR
Network connection error
RATE_LIMIT_EXCEEDED
API rate limit exceeded
UNAUTHORIZED
Invalid API key
QUEST_NOT_AVAILABLE
Quest not available
SDK Examples
JavaScript/TypeScript
import { OlymPaySDK } from '@olympay/sdk';
const sdk = new OlymPaySDK({
apiKey: 'your-api-key',
network: 'mainnet'
});
// Get balance
const balance = await sdk.stablecoin.getBalance('0x...');
// Transfer tokens
const tx = await sdk.stablecoin.transfer({
to: '0x...',
amount: '100.00'
});
// Start earning quest
const quest = await sdk.earning.startQuest({
type: 'challenger',
category: 'defi'
});
Python
from olympay import OlymPaySDK
sdk = OlymPaySDK(api_key='your-api-key', network='mainnet')
# Get balance
balance = sdk.stablecoin.get_balance('0x...')
# Transfer tokens
tx = sdk.stablecoin.transfer(to='0x...', amount='100.00')
# Start earning quest
quest = sdk.earning.start_quest(type='challenger', category='defi')
Tiếng Việt
Base URL
Production: https://api.olympay.xyz/v1
Testnet: https://api-testnet.olympay.xyz/v1
Xác thực
Tất cả yêu cầu API cần xác thực bằng API key của bạn:
const headers = {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
};
Giới hạn Tốc độ
Gói Miễn phí: 100 yêu cầu/giờ
Gói Pro: 1,000 yêu cầu/giờ
Doanh nghiệp: 10,000 yêu cầu/giờ
Endpoints
StableCoin
Lấy Số dư
GET /stablecoin/balance/{address}
Tham số:
address
(string): Địa chỉ vínetwork
(string): Mạng (ethereum, solana, polygon)
Phản hồi:
{
"success": true,
"data": {
"address": "0x...",
"balance": "1000.00",
"network": "ethereum",
"timestamp": "2024-01-01T00:00:00Z"
}
}
Chuyển Token
POST /stablecoin/transfer
Nội dung Yêu cầu:
{
"from": "0x...",
"to": "0x...",
"amount": "100.00",
"network": "ethereum"
}
Phản hồi:
{
"success": true,
"data": {
"transactionHash": "0x...",
"status": "pending",
"gasUsed": "21000"
}
}
On/Off Ramp
Tạo Yêu cầu Ramp
POST /ramp/create
Nội dung Yêu cầu:
{
"type": "on-ramp",
"amount": "100.00",
"currency": "USD",
"network": "ethereum",
"paymentMethod": "credit-card"
}
Lấy Trạng thái Ramp
GET /ramp/status/{requestId}
CCIP Chuỗi chéo
Tạo Chuyển Chuỗi chéo
POST /ccip/transfer
Nội dung Yêu cầu:
{
"sourceChain": "ethereum",
"destinationChain": "polygon",
"amount": "100.00",
"token": "USDC",
"recipient": "0x..."
}
Nền tảng Earning
Lấy Thống kê Earning
GET /earning/stats/{address}
Phản hồi:
{
"success": true,
"data": {
"totalEarned": "500.00",
"activeQuests": 3,
"completedQuests": 15,
"yieldFarming": {
"totalDeposited": "1000.00",
"currentAPY": "4.2%",
"earned": "42.00"
}
}
}
Bắt đầu Quest
POST /earning/quest/start
Nội dung Yêu cầu:
{
"questType": "challenger",
"category": "defi",
"difficulty": "beginner"
}
Xử lý Lỗi
Tất cả phản hồi API tuân theo định dạng lỗi nhất quán:
{
"success": false,
"error": {
"code": "INVALID_ADDRESS",
"message": "Địa chỉ được cung cấp không hợp lệ",
"details": {
"field": "address",
"value": "invalid-address"
}
}
}
Mã Lỗi
INVALID_ADDRESS
Địa chỉ ví không hợp lệ
INSUFFICIENT_BALANCE
Số dư token không đủ
NETWORK_ERROR
Lỗi kết nối mạng
RATE_LIMIT_EXCEEDED
Vượt quá giới hạn tốc độ API
UNAUTHORIZED
API key không hợp lệ
QUEST_NOT_AVAILABLE
Quest không khả dụng
Ví dụ SDK
JavaScript/TypeScript
import { OlymPaySDK } from '@olympay/sdk';
const sdk = new OlymPaySDK({
apiKey: 'your-api-key',
network: 'mainnet'
});
// Lấy số dư
const balance = await sdk.stablecoin.getBalance('0x...');
// Chuyển token
const tx = await sdk.stablecoin.transfer({
to: '0x...',
amount: '100.00'
});
// Bắt đầu quest earning
const quest = await sdk.earning.startQuest({
type: 'challenger',
category: 'defi'
});
Python
from olympay import OlymPaySDK
sdk = OlymPaySDK(api_key='your-api-key', network='mainnet')
# Lấy số dư
balance = sdk.stablecoin.get_balance('0x...')
# Chuyển token
tx = sdk.stablecoin.transfer(to='0x...', amount='100.00')
# Bắt đầu quest earning
quest = sdk.earning.start_quest(type='challenger', category='defi')