Skip to main content
Swap & Bridge
In a nutshell
Blockradar’s Swap API lets you exchange assets on the same chain (swap) or move assets between different chains (bridge) using a single unified endpoint.

Prerequisites

Before using the Swap API, ensure you have:
1

API Key

Get your API key from the Blockradar Dashboard. Navigate to Developers to generate one.
2

Wallet Created

Create a wallet in the dashboard (see Create a Master Wallet). You’ll need the walletId for swap operations.
3

Asset IDs

Get the assetId for your source and destination assets from Assets in the dashboard or via the Get Assets API.
4

Sufficient Balance

Ensure your wallet has enough balance of the source asset to cover the swap amount plus network fees.

How It Works

Blockradar automatically determines whether your transaction is a swap or a bridge based on your asset selection:

Swap

Exchange different assets on the same blockchain.Example: USDC → USDT on Base

Bridge

Move assets between different blockchains.Example: USDC on BSC → USDC on Optimism
You don’t need to specify whether it’s a swap or bridge—the API handles this automatically based on the fromAssetId and toAssetId you provide.

Supported Assets & Chains

The Swap API supports major stablecoins across Blockradar-supported chains:
Asset availability varies by chain. Always use the Get Assets API to fetch the current list of supported assets and their assetId values for your target chains.
See Integrations for the complete list of supported networks and stablecoins.

Master Wallet vs Child Address

The Swap API is available at two levels:

Master Wallet

Execute swaps directly from your master wallet. Ideal for treasury operations.

Child Address

Execute swaps from individual child addresses. Perfect for user-specific operations.

Endpoints

Step 1: Get a Quote

Always fetch a quote before executing a swap to show users the expected outcome.

Request Parameters

Use amountSide: "source" when the user enters how much they want to spend. Use amountSide: "target" when the user enters how much they want to receive and you need Blockradar to resolve the required source amount.

Stellar recipient routing

recipientRouting is supported only when the destination chain is Stellar. It is a generic routing contract shared by every quote and execute endpoint in this guide. Existing EVM, Solana, and Tron requests are non-breaking and unchanged: they must not send recipientRouting; requests that supply it are rejected. The same applies to Bitcoin payouts. recipientAddress remains an optional string; do not send it as an object. Do not send a separate recipient memo field.

Stellar destination rules

  1. Muxed M... recipient: omit recipientRouting. The routing ID is embedded in the muxed address, and supplying routing data is rejected.
  2. Base G... recipient with a routing ID: send { type: "memo_id", value: "123" }. value must be a non-empty numeric string from 0 through 18446744073709551615. Blockradar normalizes the address to M... before requesting quote or execution.
  3. Base G... recipient without a routing ID: send { type: "none" } and do not include value. A G... recipient without recipientRouting is rejected. The destination base account must have a Stellar USDC trustline before quote or execution.
  4. Default Blockradar Stellar wallet: explicitly send { type: "none" } in recipientRouting.

Request examples

All examples use the same body shape on each of these endpoints:
  • POST /v1/wallets/{walletId}/swaps/quote
  • POST /v1/wallets/{walletId}/swaps/execute
  • POST /v1/wallets/{walletId}/addresses/{addressId}/swaps/quote
  • POST /v1/wallets/{walletId}/addresses/{addressId}/swaps/execute
Non-Stellar destination — no routing field
Stellar G... without a routing ID
Stellar G... with a routing ID
Stellar M... recipient — no routing field
Default Blockradar Stellar wallet

Migrating from Stellar-only fields

Stellar as a source

You can swap or bridge from a Stellar asset in your wallet to an asset on another supported chain, for example Stellar USDC to Base USDC. Use the same quote and execute endpoints, with the Stellar wallet asset as fromAssetId.
  • Mainnet only. In Test Mode, a quote returns Swap is not supported on testnet.
  • Not to Solana or Tempo. A swap from Stellar to Solana or Tempo is not supported and returns Stellar swap route is unavailable (400).

Quote Example

Quote Response

For a muxed destination, data.recipientRouting can instead report that the routing ID is embedded in the normalized destination address:
data.recipientRouting is optional and is returned by quote responses only. Do not expect it in execute responses.

Understanding Quote Fields

Always display at minimum: amount to receive, estimated arrival time, and fees before the user confirms the swap.

Step 2: Execute the Swap

Once the user confirms the quote, execute the swap.

Request Parameters

Execute Example

Execute Response

Swap operations are asynchronous. The initial response shows PENDING status. Listen for the swap.success or swap.failed webhook to confirm completion.

Order Types

Choose the right order type based on your use case:

Webhook Events

Monitor swap completion through webhooks:
To pay out an asset as fiat when Withdraw Fiat does not support it, swap it first and start the payout on swap.success. See Swap Before Paying Out.

Webhook Payload

Bitcoin Payouts

Send stablecoins from a mainnet wallet and have native BTC arrive at any Bitcoin address. Blockradar converts the stablecoin and delivers the BTC in one swap, so you don’t need a Bitcoin wallet, node, or private keys. A Bitcoin payout uses the same quote and execute endpoints as any other swap, from a master wallet or a child address. Instead of toAssetId, describe the destination with toBlockchain and toAsset, and send the BTC address as recipientAddress: Do not send toAssetId in the same request. A Bitcoin address has no Blockradar wallet or asset ID, which is why the destination is named by chain and symbol.

Quote a Bitcoin payout

Execute with the same body at /swaps/execute, adding reference and metadata if you use them. Amounts in the quote are in BTC, with up to 8 decimal places.

How a Bitcoin payout completes

  1. The stablecoin leaves your wallet on the source chain.
  2. A routing provider delivers native BTC to recipientAddress on the Bitcoin network.
  3. Blockradar checks the Bitcoin transaction on two independent block explorers and confirms that at least the quoted minAmount reached the recipient.
  4. The swap is marked SUCCESS and you receive the swap.success webhook. The destination hash is the Bitcoin transaction ID, which you can show to your user or look up on any Bitcoin explorer.
Until step 3 passes, the swap stays PROCESSING. Blockradar does not fail a payout whose stablecoin has already left your wallet; if the Bitcoin leg is late or does not match the quote, our team is alerted and follows it up.
Bitcoin transactions confirm in blocks roughly every 10 minutes, so a Bitcoin payout takes longer than a swap between stablecoin chains. Use estimatedArrivalTime from the quote to set your user’s expectations.

Fees and small payouts

A Bitcoin payout quote returns the same fee fields as any other swap, including impact and impactInUSD. Routing has a fixed cost per payout, so on a small amount the fee is a large share of the payout. Show toAmount and impactInUSD to your user before they confirm.

Limitations

  • Mainnet only. Bitcoin payouts are not available on testnet; testnet requests return a 400.
  • Payout only. Blockradar sends BTC but does not hold it: there are no Bitcoin wallets or deposit addresses, and Bitcoin does not appear in the Get Assets or blockchain lists.
  • Gasless swaps and recipientRouting are not supported for Bitcoin destinations.
  • Wallets with address whitelisting turned on cannot send Bitcoin payouts. Whitelisted addresses must match the wallet’s own blockchain, so a Bitcoin address cannot be added to the list.

Bitcoin payout errors

Bitcoin payouts can also run automatically from deposits. See Bitcoin payout rules in Auto Settlements.

Complete Flow Example

Here’s a full implementation showing the quote → confirm → execute flow:

Error Responses

Best Practices

User Experience

  • Always show quotes: Display amount, fees, and estimated time before execution
  • Handle slippage: Inform users about potential price variations
  • Show progress: Use webhooks to update users on swap status

Security

  • Validate amounts: Ensure swap amounts are within acceptable ranges
  • Use references: Track swaps with unique reference IDs
  • Monitor webhooks: Always verify swap completion via webhooks

Performance

  • Cache asset IDs: Store asset IDs locally to avoid repeated lookups
  • Use appropriate order types: Choose FASTEST for time-sensitive, CHEAPEST for cost-sensitive
  • Implement retries: Handle transient failures with exponential backoff

API Reference

Support

The Swap API provides a unified interface for both same-chain swaps and cross-chain bridges. Start with small test amounts on testnets before moving to production.