API

REST API

HTTP endpoints for any language. No SDK needed — just HTTP calls. Try them live below.

Note
Base URL: https://buff.finance. All endpoints return JSON with { ok: boolean, data: ... } or { ok: false, error: "..." }.

Authentication

Public endpoints (GET /api/plans, GET /api/price, GET /api/auth) require no auth. All other endpoints require one of two methods:

Sign a message with any Solana wallet. No registration, no API keys, no database. Your wallet IS your identity.

auth.ts
typescript
1// 1. Get the message to sign
2const res = await fetch("https://buff.finance/api/auth")
3const { data } = await res.json()
4// data.message = "Buff API Authentication"
5
6// 2. Sign it with your wallet
7const message = new TextEncoder().encode(data.message)
8const signature = await wallet.signMessage(message)
9const sigBase64 = btoa(String.fromCharCode(...signature))
10
11// 3. Use on any protected endpoint
12fetch("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.

bash
bash
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.

POST/api/keys/generate

Rate Limiting

All API endpoints are rate-limited to 60 requests per minute per IP.

GET /api/auth

Get the authentication message to sign.

GET/api/auth

GET /api/plans

List all available plan tiers and defaults.

GET/api/plans

GET /api/price

Get real-time token prices (cached 30s).

GET/api/price

GET /api/portfolio/:address

Read all token balances and USD values for any Solana wallet.

GET/api/portfolio/:address

GET /api/accumulator/:address

Check if a wallet has reached the investment threshold.

GET/api/accumulator/:address

POST /api/roundup

Calculate the round-up for a transaction value.

FieldTypeRequiredDescription
txValueUsdnumberYesTotal transaction value in USD
planstringNoPlan tier: seed, sprout, tree, forest
roundToUsdnumberNoCustom round-up increment (overrides plan)
ceilingnumberNoMax round-up (default: 1.00)
POST/api/roundup

POST /api/wrap

Get server-built transfer instructions with fees enforced. The treasury address is never exposed.

FieldTypeRequiredDescription
txValueUsdnumberYesTotal transaction value in USD
userPubkeystringYesUser's main wallet public key
buffWalletPubkeystringYesUser's Buff wallet public key
planstringNoPlan tier (default: sprout)
POST/api/wrap

POST /api/swap/quote

Get a Jupiter swap quote (SOL → target asset).

FieldTypeRequiredDescription
inputLamportsnumberYesAmount of SOL in lamports (1 SOL = 1e9)
targetAssetstringNoBTC, ETH, SOL, USDC, USDT (default: BTC)
slippageBpsnumberNoSlippage in basis points (default: 100 = 1%)
POST/api/swap/quote

POST /api/swap/build

Build unsigned Jupiter swap transactions. Server checks balance, validates threshold, and builds the swap.

FieldTypeRequiredDescription
buffWalletPubkeystringYesBuff wallet to swap from
targetAssetstringNoBTC, ETH, USDC, USDT (default: BTC)
thresholdnumberNoUSD threshold (default: 5)
slippageBpsnumberNoSlippage in bps (default: 100)
POST/api/swap/build

POST /api/wallet/derive

Derive a Buff wallet public key from a signature. Returns only the public key — never the private key.

POST/api/wallet/derive

POST /api/swap/execute

Submit a pre-signed transaction to the Solana network. The transaction must already be signed.

POST/api/swap/execute