Overview
Explore our collection of demo applications and code examples to accelerate your integration with KillB API.
Sample Applications
On-Ramp Demo
Complete on-ramp flow from fiat to crypto
Off-Ramp Demo
Convert crypto back to local fiat currency
Savings Dashboard
Custodial savings account interface
Webhook Listener
Handle real-time event notifications
On-Ramp Demo
A complete implementation of the on-ramp flow (COP/MXN → USDC).
Features
- User creation and KYC
- Real-time quotation display
- PSE/SPEI payment integration
- Transaction status tracking
- Webhook handling
Code Example
import { useState } from 'react';
function OnRampWidget() {
const [quote, setQuote] = useState(null);
const [amount, setAmount] = useState('');
const getQuote = async () => {
const response = await fetch('/api/v2/quotations', {
method: 'POST',
headers: {
'Authorization': `Bearer ${accessToken}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
fromCurrency: 'COP',
toCurrency: 'USDC',
amount: parseFloat(amount),
amountIsToCurrency: false,
cashInMethod: 'PSE',
cashOutMethod: 'POLYGON'
})
});
const data = await response.json();
setQuote(data);
};
const createRamp = async () => {
const response = await fetch('/api/v2/ramps', {
method: 'POST',
headers: {
'Authorization': `Bearer ${accessToken}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
quotationId: quote.id,
userId: currentUser.id,
accountId: walletAccount.id
})
});
const ramp = await response.json();
// Redirect to PSE payment URL
window.location.href = ramp.paymentInfo[0].url;
};
return (
<div>
<input
type="number"
value={amount}
onChange={(e) => setAmount(e.target.value)}
placeholder="Amount in COP"
/>
<button onClick={getQuote}>Get Quote</button>
{quote && (
<div>
<p>You will receive: {quote.toAmount} USDC</p>
<p>Rate: {quote.rate}</p>
<button onClick={createRamp}>Continue to Payment</button>
</div>
)}
</div>
);
}
View Full Demo
See the complete on-ramp demo application on GitHub
Off-Ramp Demo
Convert cryptocurrency back to local fiat currency.
Features
- Wallet balance check
- Quote calculation
- Bank account validation
- Transaction monitoring
- Receipt generation
Code Example
export default function OffRampPage() {
const createOffRamp = async (formData) => {
// Step 1: Get quote
const quoteRes = await fetch('/api/v2/quotations', {
method: 'POST',
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
fromCurrency: 'USDC',
toCurrency: 'COP',
amount: formData.amount,
amountIsToCurrency: false,
cashInMethod: 'POLYGON',
cashOutMethod: 'PSE'
})
});
const quote = await quoteRes.json();
// Step 2: Create ramp
const rampRes = await fetch('/api/v2/ramps', {
method: 'POST',
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
quotationId: quote.id,
userId: formData.userId,
accountId: formData.bankAccountId
})
});
const ramp = await rampRes.json();
// Step 3: Show payment instructions
return ramp;
};
return (
<form onSubmit={(e) => {
e.preventDefault();
createOffRamp(formData);
}}>
{/* Form fields */}
</form>
);
}
Savings Demo
Implement a custodial savings account interface.
Code Example
// Create savings account
const createSavingsAccount = async (userId) => {
const response = await fetch('/api/v2/savings', {
method: 'POST',
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
userId: userId,
acceptedTermsAndConditions: true
})
});
return await response.json();
};
// Get balance
const getBalance = async (savingsAccountId) => {
const response = await fetch(
`/api/v2/savings/${savingsAccountId}/balance`,
{
headers: {
'Authorization': `Bearer ${token}`
}
}
);
return await response.json();
};
// Get deposit instructions
const getDepositInstructions = async (savingsAccountId, type) => {
const response = await fetch(
`/api/v2/savings/${savingsAccountId}/deposit-instructions/${type}`,
{
headers: {
'Authorization': `Bearer ${token}`
}
}
);
return await response.json();
};
Webhook Listener Demo
Handle real-time webhook events from KillB.
Code Example
const express = require('express');
const crypto = require('crypto');
const app = express();
app.use(express.json());
app.post('/webhooks/killb', (req, res) => {
// Verify webhook signature
const signature = req.headers['x-signature-sha256'];
const payload = JSON.stringify(req.body);
const expectedSignature = crypto
.createHmac('sha256', process.env.WEBHOOK_SECRET)
.update(payload)
.digest('hex');
if (signature !== expectedSignature) {
return res.status(401).json({ error: 'Invalid signature' });
}
// Process webhook event
const { event, data } = req.body;
switch(event) {
case 'ramp.completed':
handleRampCompleted(data);
break;
case 'ramp.failed':
handleRampFailed(data);
break;
case 'user.kyc_updated':
handleKYCUpdate(data);
break;
}
res.status(200).json({ received: true });
});
app.listen(3000);
Learn More
Read the complete webhook security guide
Code Snippets
User Management
const createUser = async (userData) => {
const response = await fetch('/api/v2/users', {
method: 'POST',
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
type: 'PERSON',
externalId: userData.externalId,
data: {
firstName: userData.firstName,
lastName: userData.lastName,
email: userData.email,
phone: userData.phone,
dateOfBirth: userData.dateOfBirth,
address: userData.address,
document: userData.document
}
})
});
return await response.json();
};
Account Creation
const createWalletAccount = async (userId, walletAddress) => {
const response = await fetch('/api/v2/accounts', {
method: 'POST',
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
type: 'WALLET',
userId: userId,
externalId: `wallet-${userId}`,
data: {
firstName: 'John',
lastName: 'Doe',
email: '[email protected]',
phone: '+573001234567',
currency: 'USDC',
network: 'POLYGON',
address: walletAddress,
countryCode: 'CO',
document: {
type: 'PASSPORT',
number: 'AB123456',
issuedCountryCode: 'CO'
}
}
})
});
return await response.json();
};
Ramp Creation
const executeRamp = async (userId, accountId, amount, direction) => {
try {
// 1. Create quotation
const quote = await fetch('/api/v2/quotations', {
method: 'POST',
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
fromCurrency: direction === 'ON' ? 'COP' : 'USDC',
toCurrency: direction === 'ON' ? 'USDC' : 'COP',
amount: amount,
amountIsToCurrency: false,
cashInMethod: direction === 'ON' ? 'PSE' : 'POLYGON',
cashOutMethod: direction === 'ON' ? 'POLYGON' : 'PSE'
})
}).then(r => r.json());
console.log('Quote:', quote);
// 2. Create ramp
const ramp = await fetch('/api/v2/ramps', {
method: 'POST',
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
quotationId: quote.id,
userId: userId,
accountId: accountId
})
}).then(r => r.json());
console.log('Ramp:', ramp);
return ramp;
} catch (error) {
console.error('Ramp creation failed:', error);
throw error;
}
};
Testing in Sandbox
Use these helper functions to test your integration:
Simulate Cash-In
curl --request POST \
--url https://teste-94u93qnn.uc.gateway.dev/api/v2/faker/cash-in \
--header 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
--header 'Content-Type: application/json' \
--data '{
"rampId": "ramp-id-here"
}'
Simulate Cash-Out Completion
curl --request POST \
--url https://teste-94u93qnn.uc.gateway.dev/api/v2/faker/cash-out \
--header 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
--header 'Content-Type: application/json' \
--data '{
"rampId": "ramp-id-here"
}'
Faker endpoints only work in sandbox environment and are used for testing purposes.
Integration Checklist
Set Up Authentication
Implement login and token refresh logic
Create User Management
Build user creation and KYC submission flows
Implement Account Creation
Add bank account and wallet management
Build Quotation UI
Show real-time prices to users
Handle Ramp Flow
Create and monitor ramp transactions
Set Up Webhooks
Receive real-time status updates
Add Error Handling
Implement proper error handling and retry logic
Test Thoroughly
Use sandbox environment for end-to-end testing
Additional Resources
API Reference
Complete API documentation
Webhooks Guide
Set up real-time notifications
Error Handling
Best practices for error management
Best Practices
Tips for production-ready integration