REST API
HTTP endpoints for any language. No SDK needed — just HTTP calls. Try them live below.
Authentication
Public endpoints (GET /api/plans, GET /api/price, GET /api/auth) require no auth. All other endpoints require one of two methods:
Method 1: Wallet Signature (recommended)
Sign a message with any Solana wallet. No registration, no API keys, no database. Your wallet IS your identity.
1// 1. Get the message to sign2const res = await fetch("https://buff.finance/api/auth")3const { data } = await res.json()4// data.message = "Buff API Authentication"56// 2. Sign it with your wallet7const message = new TextEncoder().encode(data.message)8const signature = await wallet.signMessage(message)9const sigBase64 = btoa(String.fromCharCode(...signature))1011// 3. Use on any protected endpoint12fetch("https://buff.finance/api/roundup", {13 method: "POST",14 headers: {15 "Content-Type": "application/json",16 "x-wallet": wallet.publicKey.toBase58(),17 "x-signature": sigBase64,18 },19 body: JSON.stringify({ txValueUsd: 27.63, plan: "tree" }),20})Method 2: Static API Key
For server-to-server integrations where wallet signing is not practical.
curl -X POST https://buff.finance/api/roundup \ -H "Content-Type: application/json" \ -H "x-api-key: your-api-key" \ -d '{"txValueUsd": 27.63, "plan": "tree"}'Method 3: Generate API Key Programmatically
For agents — sign the auth message with your keypair and get an API key. No browser needed.
/api/keys/generateRate Limiting
All API endpoints are rate-limited to 60 requests per minute per IP.
GET /api/auth
Get the authentication message to sign.
/api/authGET /api/plans
List all available plan tiers and defaults.
/api/plansGET /api/price
Get real-time token prices (cached 30s).
/api/priceGET /api/portfolio/:address
Read all token balances and USD values for any Solana wallet.
/api/portfolio/:addressGET /api/accumulator/:address
Check if a wallet has reached the investment threshold.
/api/accumulator/:addressPOST /api/roundup
Calculate the round-up for a transaction value.
| Field | Type | Required | Description |
|---|---|---|---|
| txValueUsd | number | Yes | Total transaction value in USD |
| plan | string | No | Plan tier: seed, sprout, tree, forest |
| roundToUsd | number | No | Custom round-up increment (overrides plan) |
| ceiling | number | No | Max round-up (default: 1.00) |
/api/roundupPOST /api/wrap
Get server-built transfer instructions with fees enforced. The treasury address is never exposed.
| Field | Type | Required | Description |
|---|---|---|---|
| txValueUsd | number | Yes | Total transaction value in USD |
| userPubkey | string | Yes | User's main wallet public key |
| buffWalletPubkey | string | Yes | User's Buff wallet public key |
| plan | string | No | Plan tier (default: sprout) |
/api/wrapPOST /api/swap/quote
Get a Jupiter swap quote (SOL → target asset).
| Field | Type | Required | Description |
|---|---|---|---|
| inputLamports | number | Yes | Amount of SOL in lamports (1 SOL = 1e9) |
| targetAsset | string | No | BTC, ETH, SOL, USDC, USDT (default: BTC) |
| slippageBps | number | No | Slippage in basis points (default: 100 = 1%) |
/api/swap/quotePOST /api/swap/build
Build unsigned Jupiter swap transactions. Server checks balance, validates threshold, and builds the swap.
| Field | Type | Required | Description |
|---|---|---|---|
| buffWalletPubkey | string | Yes | Buff wallet to swap from |
| targetAsset | string | No | BTC, ETH, USDC, USDT (default: BTC) |
| threshold | number | No | USD threshold (default: 5) |
| slippageBps | number | No | Slippage in bps (default: 100) |
/api/swap/buildPOST /api/wallet/derive
Derive a Buff wallet public key from a signature. Returns only the public key — never the private key.
/api/wallet/derivePOST /api/swap/execute
Submit a pre-signed transaction to the Solana network. The transaction must already be signed.
/api/swap/execute