🌊API Example Flow
Step 1 — Get an access token:
curl -X POST https://auth.quant.fun/oauth2/token \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=client_credentials&client_id=<CLIENT_ID>&client_secret=<CLIENT_SECRET>"Step 2 — Submit a trade (go 50% long ETH and 50% short BTC):
curl -X POST https://api.quant.fun/trades/my-vault \
-H "Authorization: Bearer <ACCESS_TOKEN>" \
-H "Content-Type: application/json" \
-d '[
{ "type": "perp", "coin": "ETH", "direction": "long", "portfolioAllocation": 0.5, "leverage": 4 },
{ "type": "perp", "coin": "BTC", "direction": "short", "portfolioAllocation": 0.5, "leverage": 4 }
]'To go flat on a market, submit it with "portfolioAllocation": 0.
Returns immediately with a transaction ID:
{ "result": { "transactionId": "550e8400-e29b-41d4-a716-446655440000" } }Step 3 — Poll for completion:
curl https://api.quant.fun/trades/my-vault/transactions/550e8400-e29b-41d4-a716-446655440000 \
-H "Authorization: Bearer <ACCESS_TOKEN>"{
"result": {
"requestStatus": "COMPLETED",
"portfolioCompositionResponse": [
{ "success": true, "allocation": { "type": "perp", "coin": "ETH", "direction": "long", "portfolioAllocation": 0.5, "leverage": 4 } },
{ "success": true, "allocation": { "type": "perp", "coin": "BTC", "direction": "short", "portfolioAllocation": 0.5, "leverage": 4 } }
]
}
}Poll every 2–3 seconds until requestStatus is COMPLETED or FAILED. Typical execution completes within 30–60 seconds depending on maker fill rates.
Last updated