how to integrate parasoldex with your ai agent
your agent needs to move tokens. maybe it's rebalancing a portfolio. maybe it's paying for an API call with USDC but only holds SOL. maybe it's executing a strategy that requires swapping into a specific memecoin at exactly the right moment.
whatever the reason, the agent needs a DEX. and it needs one that doesn't require a human clicking buttons in a browser.
parasoldex is built for this. it wraps Jupiter's routing engine in an API that agents can call programmatically — TypeScript, Python, or raw HTTP. no browser. no wallet popup. no human in the loop.
this guide walks through everything: SDK setup, authentication, making your first swap, handling errors, and the patterns that make autonomous trading reliable.
---
what parasoldex actually does
parasoldex is a DEX aggregation layer on Solana. it routes swaps through Jupiter to find the best price across all Solana liquidity sources — Raydium, Orca, Meteora, Phoenix, and dozens more.
the value for agents is the interface. Jupiter's API is designed for frontends. parasoldex's API is designed for machines.
the differences that matter:
---
option 1: typescript sdk
the fastest path. install the sdk and you're three lines from a swap.
installation
``bash
npm install moltydex
`
basic setup
`typescript
import { MoltyDEXClient } from 'moltydex';
const client = new MoltyDEXClient('https://api.parasol.so');
`
no api key needed. parasoldex uses the moltydex sdk pointed at api.parasol.so. for x402 payments, use HTTPInterceptor or X402AutoPayAgent — see parasol.so/sdk.
getting a quote
before swapping, get a quote. this tells your agent exactly what it will receive.
`typescript
const quote = await client.getQuote(
'So11111111111111111111111111111111111111112', // SOL
'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v', // USDC
'1000000000', // 1 SOL in lamports
50 // 0.5% slippage
);
console.log(output: ${quote.output_after_fee} USDC);
`
amounts are always in the token's smallest unit. SOL uses lamports (1 SOL = 1,000,000,000 lamports). USDC uses 6 decimals (1 USDC = 1,000,000). for full swap flow see parasol.so/sdk.
executing a swap
use buildSwapTransaction to get an unsigned tx, sign it with your wallet, then sendTransaction. or use X402AutoPayAgent for the full flow including x402. full reference at parasol.so/sdk.
configuration options
the moltydex sdk accepts apiUrl, walletPath, walletSecretKey, autoSwap, rpcUrl, and more. see parasol.so/sdk for the complete config reference.
---
option 2: rest api
if you're not in the JavaScript ecosystem, or if your agent framework has its own HTTP client, use the REST API directly. no API key required for quotes or swap builds — you sign transactions client-side.
base url
`
https://api.parasol.so
`
get a quote
`bash
curl "https://api.parasol.so/api/quote?input_mint=So11111111111111111111111111111111111111112&output_mint=EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v&amount=1000000000&slippage_bps=50"
`
query params: input_mint, output_mint, amount (string), slippage_bps (optional, default 50).
response structure
`json
{
"input_mint": "So11111111111111111111111111111111111111112",
"output_mint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
"input_amount": "1000000000",
"output_amount": "142350000",
"output_after_fee": "142350000",
"minimum_output": "141638250",
"price_impact": "0.01",
"route_plan": [],
"fee_amount": "0",
"fee_bps": 0
}
`
minimum_output is the minimum you'll receive after slippage. output_after_fee is what you get before slippage (fees are zero).
build swap transaction
`bash
curl -X POST "https://api.parasol.so/api/swap/build" \
-H "Content-Type: application/json" \
-d '{
"wallet_address": "YOUR_WALLET_PUBLIC_KEY",
"input_mint": "So11111111111111111111111111111111111111112",
"output_mint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
"amount": "1000000000",
"slippage_bps": 50
}'
`
the response includes a base64 transaction field. your agent signs it locally and submits via Solana RPC. the SDK handles this flow — see parasol.so/sdk for the full reference.
error responses
errors return { "error": "message", "details": "..." } with appropriate HTTP status. common cases: 400 (missing params, invalid token), 503 (Jupiter unavailable). retry with backoff on 5xx.
---
option 3: python sdk
for python agents, data science workflows, or Jupyter notebook prototyping.
installation
`bash
pip install moltydex
`
basic usage
`python
from moltydex import MoltyDEX
dex = MoltyDEX(
api_url="https://api.parasol.so",
wallet_path="~/.config/solana/id.json",
)
get a quote
quote = dex.quote(
"So11111111111111111111111111111111111111112",
"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
1_000_000_000,
50
)
print(f"output: {quote['output_after_fee']} USDC")
`
executing a swap
`python
result = dex.swap(
"So11111111111111111111111111111111111111112",
"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
1_000_000_000,
wait_for_confirmation=True
)
print(f"tx: {result['signature']}")
`
see parasol.so/sdk for the full Python API.
---
x402 payment integration
x402 lets your agent pay for API access per-request instead of managing API keys and subscriptions. the payment is embedded in the HTTP request itself.
how it works
and a payment invoicewith the SDK, use HTTPInterceptor or X402AutoPayAgent — they handle the 402 → pay → retry flow automatically. see parasol.so/sdk for the full x402 setup.
manual x402 flow
if you're using raw HTTP:
`typescript
// step 1: make request
const response = await fetch('https://api.parasol.so/api/quote', {
method: 'GET',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ / quote params / }),
});
// step 2: handle 402
if (response.status === 402) {
const invoice = await response.json();
// step 3: sign payment
const payment = await signPayment(invoice, agentWallet);
// step 4: retry with payment proof
const retryResponse = await fetch('https://api.parasol.so/api/quote', {
method: 'GET',
headers: {
'Content-Type': 'application/json',
'X-402-Payment': payment.proof,
},
body: JSON.stringify({ / same quote params / }),
});
}
`
---
error recovery patterns
agents need to handle failures gracefully. Solana transactions fail for many reasons: congestion, expired blockhashes, insufficient priority fees, slippage tolerance exceeded. a robust agent doesn't crash on failure — it retries with adjusted parameters.
exponential backoff with jitter
wrap swap calls in a retry loop. the moltydex client has built-in retry for transient failures. for custom logic, catch errors and retry with increased slippage or delay. see parasol.so/sdk for error types.
pre-swap validation
check balances before attempting a swap. failed transactions still cost priority fees.
`typescript
async function validateAndSwap(
dex: MoltyDEX,
params: SwapParams
): Promise
// check balance first
const balance = await dex.getBalance(params.inputMint, params.wallet);
if (balance < params.amount) {
throw new Error(
insufficient balance: have ${balance}, need ${params.amount}
);
}
// get fresh quote to check conditions
const quote = await dex.getQuote({
inputMint: params.inputMint,
outputMint: params.outputMint,
amount: params.amount,
slippageBps: params.slippageBps,
});
// reject if price impact is too high
if (parseFloat(quote.priceImpactPct) > 1.0) {
throw new Error(
price impact too high: ${quote.priceImpactPct}%
);
}
return await dex.swap(params);
}
`
circuit breaker pattern
if swaps keep failing, stop trying. something is wrong with the network, the token, or the route.
`typescript
class SwapCircuitBreaker {
private failures = 0;
private lastFailure = 0;
private readonly threshold = 3;
private readonly cooldownMs = 300_000; // 5 minutes
async execute(fn: () => Promise
if (this.isOpen()) {
throw new Error('circuit open — too many recent failures');
}
try {
const result = await fn();
this.failures = 0;
return result;
} catch (error) {
this.failures++;
this.lastFailure = Date.now();
throw error;
}
}
private isOpen(): boolean {
if (this.failures < this.threshold) return false;
if (Date.now() - this.lastFailure > this.cooldownMs) {
this.failures = 0;
return false;
}
return true;
}
}
`
---
putting it together
a minimal agent swap flow: getQuote → buildSwapTransaction → sign → sendTransaction`. add validation, retries, and circuit breakers for production. the full reference is at parasol.so/sdk.
---
next steps
building something with parasoldex? we want to see it. get access at parasol.so/access and tell us what you're building.