Utility API
Helper endpoints for quotes and health checks
Utility API
Section titled “Utility API”Helper endpoints for swap quotes, health checks, and version info.
POST /jupiter
Section titled “POST /jupiter”Get a Jupiter swap quote preview.
Request
Section titled “Request”POST /jupiterContent-Type: application/json{ "inputMint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", "outputMint": "So11111111111111111111111111111111111111112", "amount": 100000000, "slippageBps": 50, "dexes": []}| Field | Type | Description |
|---|---|---|
inputMint | string | Input token mint |
outputMint | string | Output token mint |
amount | number | Amount in base units |
slippageBps | number | Slippage in basis points |
dexes | string[] | DEXes to use (empty = all) |
Response
Section titled “Response”Returns Jupiter quote data:
{ "inputMint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", "outputMint": "So11111111111111111111111111111111111111112", "inAmount": "100000000", "outAmount": "450000000", "priceImpactPct": 0.01, "routePlan": [...]}Example
Section titled “Example”interface JupiterQuote { inputMint: string; outputMint: string; inAmount: string; outAmount: string; priceImpactPct: number;}
async function getQuote( inputMint: string, outputMint: string, amount: number, slippageBps: number = 50): Promise<JupiterQuote> { const response = await fetch('https://worker.turbine.cash/jupiter', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ inputMint, outputMint, amount, slippageBps, dexes: [], }), });
return response.json();}
// Preview a 100 USDC -> SOL swapconst quote = await getQuote( 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v', 'So11111111111111111111111111111111111111112', 100_000_000, 50);
console.log(`You'll receive approximately ${quote.outAmount} lamports`);console.log(`Price impact: ${quote.priceImpactPct}%`);Slippage Reference
Section titled “Slippage Reference”| Slippage | bps | Use Case |
|---|---|---|
| 0.1% | 10 | Stablecoin pairs |
| 0.5% | 50 | Standard trades |
| 1.0% | 100 | Volatile pairs |
| 3.0% | 300 | Low liquidity |
GET /health
Section titled “GET /health”Check API server health.
Request
Section titled “Request”GET /healthResponse
Section titled “Response”Healthy:
200 OK"ok"Unhealthy:
503 Service UnavailableExample
Section titled “Example”async function checkHealth(): Promise<boolean> { try { const response = await fetch('https://worker.turbine.cash/health'); return response.ok; } catch { return false; }}GET /version
Section titled “GET /version”Get current API version.
Request
Section titled “Request”GET /versionResponse
Section titled “Response”200 OK"0.1.0"Example
Section titled “Example”async function getVersion(): Promise<string> { const response = await fetch('https://worker.turbine.cash/version'); return response.text();}Status Monitoring
Section titled “Status Monitoring”For production applications, implement health checks:
class TurbineHealthMonitor { private healthy = true; private lastCheck = 0;
async check(): Promise<boolean> { const now = Date.now(); if (now - this.lastCheck < 60000) { return this.healthy; }
try { const response = await fetch('https://worker.turbine.cash/health', { signal: AbortSignal.timeout(5000), }); this.healthy = response.ok; } catch { this.healthy = false; }
this.lastCheck = now; return this.healthy; }
isHealthy(): boolean { return this.healthy; }}