Ví dụ API
Trang này cung cấp các ví dụ curl có thể sao chép trực tiếp cho những endpoint backend cốt lõi của CloudBank.
URL gốc
bash
export API_ORIGIN="https://docs-test.cloudbank.to"
export API_BASE="$API_ORIGIN/api/v1"POST /api/v1/auth/nonce
Lấy nonce challenge cho đăng nhập bằng chữ ký ví.
Yêu cầu
bash
curl -sS -X POST "$API_BASE/auth/nonce" \
-H "Content-Type: application/json" \
-d '{
"address": "0xYourWalletAddress"
}'Định dạng phản hồi mong đợi
json
{
"nonce": "c7f7a4e0...",
"message": "CloudBank Authentication\n\nAddress: 0x...\nNonce: ...",
"expiresAt": "2026-03-05T00:00:00Z"
}POST /api/v1/auth/login
Đổi signature + challenge message lấy JWT.
Yêu cầu
bash
curl -sS -X POST "$API_BASE/auth/login" \
-H "Content-Type: application/json" \
-d '{
"address": "0xYourWalletAddress",
"signature": "0xYourPersonalSignSignature",
"message": "CloudBank Authentication\\n\\nAddress: 0x...\\nNonce: ..."
}'Định dạng phản hồi mong đợi
json
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"custodialWalletAddress": "0xYourCustodialWallet",
"expiresAt": "2026-03-06T00:00:00Z"
}GET /api/v1/wallet/info
Lấy hồ sơ ví của người dùng đã xác thực.
Yêu cầu
bash
curl -sS "$API_BASE/wallet/info" \
-H "Authorization: Bearer $JWT"Định dạng phản hồi mong đợi
json
{
"userAddress": "0xYourWalletAddress",
"custodialWalletAddress": "0xYourCustodialWallet",
"createdAt": "2026-03-05T00:00:00Z"
}POST /api/v1/wallet/sign
Ký và phát giao dịch whitelist bằng ví custodial.
Yêu cầu
bash
curl -sS -X POST "$API_BASE/wallet/sign" \
-H "Authorization: Bearer $JWT" \
-H "Content-Type: application/json" \
-d '{
"to": "0xContractAddress",
"data": "0xabcdef12...",
"value": "0",
"product": "predict"
}'Định dạng phản hồi mong đợi
json
{
"txHash": "0xSignedTxHash",
"gasMode": "user",
"status": "pending",
"createdAt": "2026-03-05T00:00:00Z"
}GET /api/v1/orderbook/book
Đọc độ sâu orderbook.
Yêu cầu
bash
curl -sS "$API_BASE/orderbook/book?marketId=0xYourMarketId&outcomeTokenId=12345&depth=20"Định dạng phản hồi mong đợi
json
{
"marketId": "0xYourMarketId",
"outcomeTokenId": "12345",
"bids": [
{
"price": "0.55000000",
"makerAmount": "100",
"takerAmount": "55",
"orderCount": 1
}
],
"asks": [],
"updatedAt": "2026-03-05T00:00:00Z"
}POST /api/v1/orderbook/orders
Gửi lệnh đã ký.
Yêu cầu
bash
curl -sS -X POST "$API_BASE/orderbook/orders" \
-H "Authorization: Bearer $JWT" \
-H "Content-Type: application/json" \
-d '{
"marketId": "0xYourMarketId",
"timeInForce": "GTC",
"domain": {
"name": "Polymarket CTF Exchange",
"version": "1",
"chainId": 97,
"verifyingContract": "0xExchangeContract"
},
"order": {
"salt": "1700000000000000000",
"maker": "0xYourWalletAddress",
"signer": "0xYourWalletAddress",
"taker": "0x0000000000000000000000000000000000000000",
"tokenId": "12345",
"makerAmount": "1000000",
"takerAmount": "550000",
"expiration": "1767225600",
"nonce": "1",
"feeRateBps": "0",
"side": "buy",
"signatureType": "0"
},
"signature": "0xYourEip712OrderSignature"
}'Định dạng phản hồi mong đợi
json
{
"orderHash": "0xOrderHash",
"marketId": "0xYourMarketId",
"outcomeTokenId": "12345",
"maker": "0xYourWalletAddress",
"signer": "0xYourWalletAddress",
"side": "buy",
"timeInForce": "GTC",
"price": "0.55000000",
"makerAmount": "1000000",
"takerAmount": "550000",
"expiration": "1767225600",
"nonce": "1",
"status": "live",
"createdAt": "2026-03-05T00:00:00Z",
"updatedAt": "2026-03-05T00:00:00Z"
}GET /api/v1/health
/api/v1/health có thể được expose qua gateway; route backend gốc là /health.
Yêu cầu
bash
curl -sS "$API_ORIGIN/health"Định dạng phản hồi mong đợi
json
{
"status": "healthy",
"version": "v1.0.0",
"uptimeSeconds": 12345,
"database": { "ok": true, "latencyMs": 2 },
"redis": { "ok": true, "latencyMs": 1 },
"bsc": { "ok": true, "latencyMs": 45 }
}