Create Virtual Accounts (cURL)
NGN Virtual Account
Copy
curl -X GET "https://api.useonion.xyz/v1/accounts/ngn/user_abc123" \
-H "x-api-key: sk_live_..."
USD Virtual Account
Copy
curl -X GET "https://api.useonion.xyz/v1/accounts/usd/user_abc123" \
-H "x-api-key: sk_live_..."
GBP Virtual Account
Copy
curl -X GET "https://api.useonion.xyz/v1/accounts/gbp/user_abc123" \
-H "x-api-key: sk_live_..."
EUR Virtual Account
Copy
curl -X GET "https://api.useonion.xyz/v1/accounts/eur/user_abc123" \
-H "x-api-key: sk_live_..."
Get All USDC Accounts
Copy
curl -X GET "https://api.useonion.xyz/v1/accounts/usdc/user_abc123" \
-H "x-api-key: sk_live_..."
Get USDC Account for Specific Chain
Copy
curl -X GET "https://api.useonion.xyz/v1/accounts/usdc/user_abc123/ETHEREUM" \
-H "x-api-key: sk_live_..."
Create USDC Account for Chain
Copy
curl -X POST "https://api.useonion.xyz/v1/accounts/usdc/user_abc123" \
-H "x-api-key: sk_live_..." \
-H "Content-Type: application/json" \
-d '{
"chainType": "ETHEREUM"
}'
List Ledger Entries (cURL)
Copy
curl "https://api.useonion.xyz/v1/transactions/ledger/user_abc123" \
-H "x-api-key: sk_live_..."
Convert NGN to USD (Python)
Copy
import requests
resp = requests.get(
'https://api.useonion.xyz/v1/conversion/quote?from=NGN&to=USD&amount=5000',
headers={'x-api-key': 'sk_live_...'}
)
print(resp.json())
Convert USD to INR (Node.js)
Copy
const axios = require('axios');
async function convertUsdToInr() {
try {
const response = await axios.get(
'https://api.useonion.xyz/v1/conversion/quote?from=USD&to=INR&amount=100',
{ headers: { 'x-api-key': 'sk_live_...' } }
);
console.log(response.data);
// Perform actual conversion
const conversion = await axios.post(
'https://api.useonion.xyz/v1/conversion',
{
from: 'USD',
to: 'INR',
amount: 100,
userId: 'user_abc123'
},
{ headers: { 'x-api-key': 'sk_live_...' } }
);
console.log(conversion.data);
} catch (error) {
console.error('Error:', error.response?.data || error.message);
}
}
convertUsdToInr();
Withdraw NGN to Bank Account (Node.js)
Copy
const axios = require('axios');
async function withdrawNgn() {
try {
const response = await axios.post(
'https://api.useonion.xyz/v1/withdrawals/ngn',
{
userId: 'user_abc123',
amount: 10000,
bankName: 'Access Bank',
accountNumber: '0123456789',
accountName: 'John Doe',
bankCode: '044',
narration: 'Withdrawal to bank account'
},
{ headers: { 'x-api-key': 'sk_live_...' } }
);
console.log(response.data);
// Check withdrawal status
const statusResponse = await axios.get(
`https://api.useonion.xyz/v1/withdrawals/${response.data.reference}`,
{ headers: { 'x-api-key': 'sk_live_...' } }
);
console.log(statusResponse.data);
} catch (error) {
console.error('Error:', error.response?.data || error.message);
}
}
withdrawNgn();
Withdraw USDC to Blockchain Wallet (Python)
Copy
import requests
def withdraw_usdc():
try:
# Create USDC withdrawal
response = requests.post(
'https://api.useonion.xyz/v1/withdrawals/usdc',
json={
'userId': 'user_abc123',
'amount': 50,
'walletAddress': '0x1234567890abcdef1234567890abcdef12345678',
'network': 'ethereum',
'chainId': 1
},
headers={'x-api-key': 'sk_live_...'}
)
withdrawal = response.json()
print(f"Created withdrawal: {withdrawal}")
# Get all user withdrawals
withdrawals_response = requests.get(
'https://api.useonion.xyz/v1/withdrawals/user/user_abc123',
headers={'x-api-key': 'sk_live_...'}
)
print(f"All user withdrawals: {withdrawals_response.json()}")
except Exception as e:
print(f"Error: {e}")
withdraw_usdc()

