Exchange FAQ API Support Blog Swap Now ⚡

Build a Crypto Swap App Using SwiftSwap API (2026 Tutorial)

The SwiftSwap API gives developers access to 1,500+ crypto pairs, real-time rates, and instant swap execution. This tutorial walks through building a functional Node.js swap application — from rate fetching to swap creation to status monitoring.

SwiftSwap Developer Team
Written by · SwiftSwap Technical Team · April 2026

API Overview

The SwiftSwap API is a RESTful JSON API. It is public — no authentication required for rate queries. An API key is required for creating swaps programmatically. Get your API key at swiftswap.net/api.html.

Base URLhttps://api.swiftswap.net/v2
FormatJSON
AuthAPI Key in header: X-API-Key: your_key
Rate Limit100 req/min (public), 1000 req/min (authenticated)

Core Endpoints

GET/currencies — List all supported currencies
GET/rate?from={symbol}&to={symbol}&amount={amount} — Get exchange rate
POST/swap — Create a new swap
GET/swap/{id} — Get swap status
GET/swap/{id}/track — Track swap in real time

Prerequisites

Before starting, you need:

Install the required package:

npm init -y
npm install node-fetch dotenv

Create a .env file:

SWIFTSWAP_API_KEY=your_api_key_here

Step 1: Fetch Supported Currencies

// currencies.js
import fetch from 'node-fetch';

const BASE_URL = 'https://api.swiftswap.net/v2';

async function getCurrencies() {
  const response = await fetch(`${BASE_URL}/currencies`);
  const data = await response.json();

  console.log(`Total currencies: ${data.currencies.length}`);

  // Show first 10
  data.currencies.slice(0, 10).forEach(coin => {
    console.log(`${coin.symbol} - ${coin.name} (${coin.network})`);
  });

  return data.currencies;
}

getCurrencies();

Sample output:

Total currencies: 1547
BTC - Bitcoin (bitcoin)
ETH - Ethereum (ethereum)
USDT - Tether (tron)
USDT - Tether (ethereum)
BNB - BNB Chain (bsc)
XRP - XRP (ripple)
SOL - Solana (solana)
ADA - Cardano (cardano)
DOGE - Dogecoin (dogecoin)
AVAX - Avalanche C-Chain (avalanche)

Step 2: Fetch Exchange Rates

// rates.js
import fetch from 'node-fetch';
import 'dotenv/config';

const BASE_URL = 'https://api.swiftswap.net/v2';
const API_KEY = process.env.SWIFTSWAP_API_KEY;

async function getRate(fromSymbol, toSymbol, amount) {
  const params = new URLSearchParams({
    from: fromSymbol,
    to: toSymbol,
    amount: amount.toString()
  });

  const response = await fetch(`${BASE_URL}/rate?${params}`, {
    headers: { 'X-API-Key': API_KEY }
  });

  if (!response.ok) {
    throw new Error(`API error: ${response.status}`);
  }

  const rate = await response.json();

  return {
    fromAmount: rate.fromAmount,
    toAmount: rate.toAmount,
    rate: rate.exchangeRate,
    fee: rate.networkFee,
    estimatedTime: rate.estimatedTime,
    validFor: rate.validForSeconds
  };
}

// Example: How much USDT do I get for 0.1 BTC?
const quote = await getRate('BTC', 'USDTTRC20', 0.1);
console.log(`0.1 BTC = ${quote.toAmount} USDT TRC20`);
console.log(`Rate: 1 BTC = ${quote.rate} USDT`);
console.log(`Network fee: ${quote.fee} USDT`);
console.log(`Estimated time: ${quote.estimatedTime} minutes`);
console.log(`Rate valid for: ${quote.validFor} seconds`);

Step 3: Create a Swap

// create-swap.js
import fetch from 'node-fetch';
import 'dotenv/config';

const BASE_URL = 'https://api.swiftswap.net/v2';
const API_KEY = process.env.SWIFTSWAP_API_KEY;

async function createSwap({
  fromCurrency,   // e.g., 'BTC'
  toCurrency,     // e.g., 'USDTTRC20'
  fromAmount,     // e.g., 0.1
  toAddress,      // recipient wallet address
  refundAddress,  // where to return funds if swap fails (optional)
  affiliateId     // your affiliate ID for commission (optional)
}) {
  const payload = {
    from: fromCurrency,
    to: toCurrency,
    amount: fromAmount,
    address: toAddress,
    refundAddress: refundAddress || null,
    affiliate: affiliateId || null
  };

  const response = await fetch(`${BASE_URL}/swap`, {
    method: 'POST',
    headers: {
      'X-API-Key': API_KEY,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify(payload)
  });

  if (!response.ok) {
    const err = await response.json();
    throw new Error(`Swap creation failed: ${err.message}`);
  }

  return await response.json();
}

// Create a swap: 0.1 BTC -> USDT TRC20
const swap = await createSwap({
  fromCurrency: 'BTC',
  toCurrency: 'USDTTRC20',
  fromAmount: 0.1,
  toAddress: 'TYour_TRC20_USDT_Wallet_Address_Here',
  refundAddress: 'bc1your_btc_refund_address_here'
});

console.log('Swap created!');
console.log(`Swap ID: ${swap.id}`);
console.log(`Send ${swap.fromAmount} BTC to: ${swap.depositAddress}`);
console.log(`You will receive: ${swap.toAmount} USDT`);
console.log(`Expires: ${new Date(swap.expiresAt).toLocaleString()}`);
Important: The depositAddress in the response is where the user must send their crypto. It's unique to this swap and expires after ~30 minutes. Always display this clearly to your user.

Step 4: Monitor Swap Status

// monitor-swap.js
import fetch from 'node-fetch';
import 'dotenv/config';

const BASE_URL = 'https://api.swiftswap.net/v2';
const API_KEY = process.env.SWIFTSWAP_API_KEY;

const STATUSES = {
  waiting:    'Waiting for deposit...',
  confirming: 'Deposit received, confirming...',
  processing: 'Processing swap...',
  sending:    'Sending to destination...',
  completed:  'Swap completed!',
  failed:     'Swap failed',
  refunded:   'Swap refunded'
};

async function getSwapStatus(swapId) {
  const response = await fetch(`${BASE_URL}/swap/${swapId}`, {
    headers: { 'X-API-Key': API_KEY }
  });
  return await response.json();
}

async function monitorSwap(swapId, intervalMs = 15000) {
  console.log(`Monitoring swap ${swapId}...`);

  return new Promise((resolve, reject) => {
    const poll = setInterval(async () => {
      try {
        const swap = await getSwapStatus(swapId);
        const statusMsg = STATUSES[swap.status] || swap.status;

        console.log(`[${new Date().toLocaleTimeString()}] ${statusMsg}`);

        if (swap.txHash) {
          console.log(`  Tx Hash: ${swap.txHash}`);
        }

        if (swap.status === 'completed') {
          clearInterval(poll);
          console.log(`\nSwap complete!`);
          console.log(`Received: ${swap.toAmount} ${swap.to}`);
          console.log(`TX: ${swap.txHash}`);
          resolve(swap);
        }

        if (['failed', 'refunded'].includes(swap.status)) {
          clearInterval(poll);
          reject(new Error(`Swap ${swap.status}: ${swap.failReason || ''}`));
        }

      } catch (err) {
        clearInterval(poll);
        reject(err);
      }
    }, intervalMs);
  });
}

// Usage:
const swapId = 'ss_abc123def456'; // from createSwap()
await monitorSwap(swapId);

Complete Swap Application

Here's a complete, production-ready swap function combining all the above:

// swiftswap-client.js
import fetch from 'node-fetch';

export class SwiftSwapClient {
  constructor(apiKey) {
    this.apiKey = apiKey;
    this.baseUrl = 'https://api.swiftswap.net/v2';
  }

  async request(method, path, body = null) {
    const options = {
      method,
      headers: {
        'X-API-Key': this.apiKey,
        'Content-Type': 'application/json'
      }
    };
    if (body) options.body = JSON.stringify(body);

    const res = await fetch(`${this.baseUrl}${path}`, options);
    const data = await res.json();

    if (!res.ok) throw new Error(data.message || `HTTP ${res.status}`);
    return data;
  }

  getRate(from, to, amount) {
    return this.request('GET', `/rate?from=${from}&to=${to}&amount=${amount}`);
  }

  createSwap(params) {
    return this.request('POST', '/swap', params);
  }

  getSwap(id) {
    return this.request('GET', `/swap/${id}`);
  }

  async waitForCompletion(swapId, opts = {}) {
    const { interval = 10000, timeout = 1800000 } = opts;
    const start = Date.now();

    while (Date.now() - start < timeout) {
      const swap = await this.getSwap(swapId);

      if (swap.status === 'completed') return swap;
      if (['failed', 'refunded'].includes(swap.status)) {
        throw new Error(`Swap ${swap.status}`);
      }

      await new Promise(r => setTimeout(r, interval));
    }
    throw new Error('Swap timeout');
  }
}

// Usage example:
import 'dotenv/config';

const client = new SwiftSwapClient(process.env.SWIFTSWAP_API_KEY);

// Get rate
const rate = await client.getRate('ETH', 'USDTTRC20', 1.0);
console.log(`1 ETH = ${rate.toAmount} USDT`);

// Create swap
const swap = await client.createSwap({
  from: 'ETH',
  to: 'USDTTRC20',
  amount: 1.0,
  address: 'TYourUSDTAddress'
});

console.log(`Send ${swap.fromAmount} ETH to: ${swap.depositAddress}`);

// Wait for completion
const result = await client.waitForCompletion(swap.id);
console.log(`Done! Received: ${result.toAmount} USDT`);

Error Handling Best Practices

Get Your API Key

Start building with the SwiftSwap API. Free tier available, generous rate limits, full documentation.

Get API Access →