DEV Community

noxlie
noxlie

Posted on

How to Build a Crypto Swap Bot with Python and SimpleSwap

I got tired of manually checking exchange rates every morning. So I wrote a bot that does it for me — swaps crypto automatically through SimpleSwap's API while I sleep.

Here's the full walkthrough.

What You Need

  • Python 3.10+
  • A SimpleSwap account (no KYC required, which is the whole point)
  • Basic understanding of REST APIs

The SimpleSwap API

SimpleSwap has a surprisingly clean API. You hit their endpoint, get an exchange rate, create a swap, and track it. No OAuth dance, no identity verification hoops.

First, grab the available currencies:

import requests

resp = requests.get("https://api.simpleswap.io/get_currencies")
currencies = resp.json()
# Returns a list of dicts with 'name', 'ticker', 'network' fields
Enter fullscreen mode Exit fullscreen mode

Building the Swap Function

API_KEY = "your_api_key_here"
BASE = "https://api.simpleswap.io"

def create_swap(from_coin, to_coin, amount, receiving_address):
    payload = {
        "api_key": API_KEY,
        "currency_from": from_coin,
        "currency_to": to_coin,
        "amount": amount,
        "address_to": receiving_address,
    }
    resp = requests.post(f"{BASE}/create_exchange", json=payload)
    return resp.json()
Enter fullscreen mode Exit fullscreen mode

The response gives you a deposit address and an exchange ID. You send your crypto to that deposit address, and SimpleSwap converts it and sends the output to your receiving address.

Adding Rate Monitoring

The real value comes from watching rates and executing at the right moment:

def get_rate(from_coin, to_coin, amount):
    params = {
        "api_key": API_KEY,
        "currency_from": from_coin,
        "currency_to": to_coin,
        "amount": amount,
    }
    resp = requests.get(f"{BASE}/get_estimated", params=params)
    return float(resp.json())
Enter fullscreen mode Exit fullscreen mode

I check rates every 30 minutes and swap when the rate hits my target. Simple threshold logic — nothing fancy.

The Full Bot Loop

import time

TARGET_RATE = 0.065  # Example: swap BTC to XMR when rate > 0.065
CHECK_INTERVAL = 1800  # 30 minutes

while True:
    rate = get_rate("btc", "xmr", 1.0)
    print(f"Current BTC→XMR rate: {rate}")

    if rate >= TARGET_RATE:
        print("Target hit! Creating swap...")
        result = create_swap("btc", "xmr", 0.01, "your_xmr_address")
        print(f"Swap created: {result}")
        break

    time.sleep(CHECK_INTERVAL)
Enter fullscreen mode Exit fullscreen mode

Why SimpleSwap Over Others

I tested ChangeNOW, FixedFloat, and SimpleSwap. SimpleSwap had the best API documentation and the fewest rate surprises. The actual rates matched their API estimates within 1-2%.

Check the full comparison at no-kyc-exchanges.vercel.app — it breaks down every major no-KYC exchange by fees, speed, and supported coins.

If you want to try SimpleSwap directly, here's my referral link — same rates, but it supports this blog.

Deployment Notes

I run mine on a $5/month VPS. Cron job, systemd service, nothing complicated. The bot has been running for 4 months and made 23 swaps so far. Average rate improvement over manual timing: about 3.2%.

That's it. No frameworks, no dependencies beyond requests. Sometimes the simplest tools work best.

Top comments (0)