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

Quick Start

1. Detect the DEX for a token

Before trading, find out which DEX a token trades on:

code
GET https://refundyoursol.com/api/trade/detect/YOUR_TOKEN_MINT

Response:

json
{
  "success": true,
  "amm": "pumpswap",
  "dex": "pumpswap",
  "tokenName": "Example Token",
  "tokenSymbol": "EX",
  "priceUsd": 0.000042,
  "marketCapUsd": 42000,
  "liquidityUsd": 8500
}

2. Buy a token

json
POST https://refundyoursol.com/api/trade

{
  "wallet": "YOUR_WALLET_ADDRESS",
  "mint": "TOKEN_MINT_ADDRESS",
  "action": "buy",
  "amount": "0.1",
  "slippage": 15,
  "privateKey": "YOUR_PRIVATE_KEY"
}

3. Sell a token (100%)

json
POST https://refundyoursol.com/api/trade

{
  "wallet": "YOUR_WALLET_ADDRESS",
  "mint": "TOKEN_MINT_ADDRESS",
  "action": "sell",
  "amount": "100%",
  "slippage": 15,
  "privateKey": "YOUR_PRIVATE_KEY",
  "closeAccount": true
}

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.

json
{
  "privateKey": "YOUR_KEY",
  "mode": "fast"
}

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.

json
{
  "returnTx": true,
  "wallet": "YOUR_WALLET"
}

MEV Protection with Jito

Worried about sandwich attacks? Enable Jito bundles:

json
{
  "useJito": true,
  "priorityFee": 100000
}

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:

json
{
  "returnTx": true,
  "optimizeFees": true
}

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:

code
GET /api/trade/detect/TOKEN_MINT

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):

code
POST /api/token-metadata
{ "mints": ["EPjF...1v", "So11...112"] }

Returns name, symbol, image, and USD price for multiple tokens at once. Ideal for portfolio dashboards.

Burn Account Enrichment:

code
POST /api/get-token-metadata
{ "burnAccounts": [{"mint":"...","pubkey":"...","amount":1000}] }

Takes an array of token accounts and returns enriched metadata with USD values — useful for building custom burn/close UIs.

SOL Price:

code
GET /api/solana-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:

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