2026-03-16 · 7 min read · Developer
Solana Trading API: Buy & Sell Tokens
RefundYourSOL's Trading API lets you buy and sell tokens on 12+ Solana DEXes with automatic routing, Jito MEV protection, and sub-400ms execution.
RefundYourSOL isn't just a wallet cleanup tool — it also offers a full Trading API that lets you buy and sell tokens on every major Solana DEX programmatically. Whether you're building a trading bot, an analytics dashboard, or automating a portfolio strategy, the API handles routing, pool detection, and transaction building for you.
What the API Supports
- 12+ DEXes: PumpSwap, Pump.fun, Raydium (AMM, CPMM, LaunchLab), Meteora (DLMM, DAMM, DBC), Orca, FluxBeam, Moonit, Heaven
- Automatic DEX detection: Send a token mint, the API figures out which DEX and pool to use
- Two execution modes: Server-side (fire and forget) or client-side (returns unsigned transaction)
- Fast mode: ~150-400ms response time for latency-sensitive bots
- Jito MEV protection: Sandwich-resistant trades via Jito bundles
- Percentage sells: Sell "100%" or "50%" of your holdings without calculating exact amounts
- Auto account closure: Recover ~0.002 SOL rent after selling by closing the token account in the same transaction
Quick Start
1. Detect the DEX for a token
Before trading, find out which DEX a token trades on:
Response:
2. Buy a token
3. Sell a token (100%)
Setting closeAccount: true closes the token account after selling, recovering the ~0.002 SOL rent automatically.
Execution Modes
Server-side (default)
Send your private key and the API executes the trade for you. Keys are never logged or stored.
Fast mode skips confirmation and verification, giving you ~150-400ms response times — ideal for sniping or high-frequency strategies.
Stable mode (default) waits for on-chain confirmation and verifies the trade landed — takes 1-4 seconds but guarantees you know the result.
Client-side (returnTx)
Don't want to share your private key? Set returnTx: true and the API returns an unsigned base64-encoded transaction. Sign it locally with your wallet and submit it yourself.
MEV Protection with Jito
Worried about sandwich attacks? Enable Jito bundles:
The priorityFee becomes your Jito tip. Your trade gets bundled privately, so MEV bots can't front-run or sandwich you.
Fee Optimization
The API can simulate your transaction to find the minimum compute units needed, then rebuild with an optimized CU limit — saving 30-50% on transaction fees:
This adds ~200-400ms latency but significantly reduces fees for each trade.
Token Metadata, Prices & Market Data
The API includes dedicated endpoints for market data — no trading required:
DEX Detection & Market Data:
Returns: DEX/AMM, pool address, token name, symbol, price USD, market cap, liquidity, 24h volume. Use this to build screeners or find which DEX a token trades on.
Token Metadata & Price (batch):
Returns name, symbol, image, and USD price for multiple tokens at once. Ideal for portfolio dashboards.
Burn Account Enrichment:
Takes an array of token accounts and returns enriched metadata with USD values — useful for building custom burn/close UIs.
SOL Price:
Returns current SOL/USD price. Simple and fast.
Why Use RefundYourSOL's API?
Most Solana trading APIs make you handle pool detection, route calculation, and transaction building yourself. RefundYourSOL's API does all of that in one call:
- One endpoint for all DEXes — no need to integrate each DEX separately
- Automatic pool detection — send a mint, get a trade
- Built-in Jito support — MEV protection without extra infrastructure
- Percentage sells — sell "50%" without calculating token amounts
- Account cleanup — recover rent in the same transaction
- Sub-400ms execution — competitive with dedicated trading infrastructure
Pricing
The Trading API charges a small fee per trade (included in the swap). There are no monthly subscriptions or API key fees. You pay only when you trade.
Get Started
The full API documentation with all parameters, response formats, and more examples is available at refundyoursol.com/docs.
Related: How to Recover SOL from Unused Token Accounts | Best Solana Token Account Closure Tools Compared
Start building at refundyoursol.com/docs — no API key required.
Ready to Recover Your SOL?
Connect your wallet and see how much SOL is locked in your empty token accounts.
Get Your SOL Back