Skip to main content

swapzone

PyPI version License: ISC Python Version

Modern, fully typed Python client library for the Swapzone instant cryptocurrency exchange & DEX cross-chain aggregator REST API.

Official API documentation: https://documenter.getpostman.com/view/16362858/UVXokDS6


Features

  • 🔄 15+ Exchange Providers Aggregated — Compares rates in real time across top instant swap platforms (SimpleSwap, StealthEX, ChangeNOW, Changelly, etc.).
  • 🪙 1000+ Cryptocurrencies — Full support for fixed and floating cross-chain swaps.
  • 🐍 Modern Pythonic Design — Type annotations, dataclass models (RateOffer, TransactionResult, SupportedCurrency, TransactionStatus), context manager support (with Swapzone(...) as client:), and custom exceptions.
  • ⚡ DEX Aggregation — DEX blockchain routes, token catalogs, and quote comparisons.
  • 🛡️ Address Validation — Built-in validate_address() helper to verify destination wallet addresses.

Installation

pip install swapzone

Requires Python 3.10 or higher.


Quick Start (Safe Check)

The quick check only inspects supported currencies and compares live provider exchange rates. It does not create orders:

import os
from swapzone import Swapzone

with Swapzone(api_key=os.environ["SWAPZONE_API_KEY"]) as client:
    # 1. Fetch supported currencies
    currencies = client.get_currencies()
    print(f"Available currencies: {len(currencies)}")

    # 2. Query best rate offer for 0.1 BTC to ETH
    rate = client.get_rate(
        from_currency="btc",
        to_currency="eth",
        amount=0.1,
        rate_type="all",
    )
    print(f"Best Provider: {rate.best_offer.adapter}")
    print(f"Estimated Receive: {rate.best_offer.amount_to} ETH")

Usage Guide

1. Finding the Best Rate and Creating a Swap

Full lifecycle: query provider rates, validate destination address, create transaction, and monitor status:

from swapzone import Swapzone, SwapzoneError

with Swapzone(api_key="your_api_key") as client:
    # 1. Get rate offers across all providers
    rate = client.get_rate(
        from_currency="btc",
        to_currency="eth",
        amount=0.1,
        rate_type="all",
    )
    best_offer = rate.best_offer
    print(f"Selected Provider: {best_offer.adapter} (Quota: {best_offer.amount_to} ETH)")

    # 2. Validate destination wallet address
    check = client.validate_address(
        currency="eth",
        address="0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
    )
    if not check.result:
        raise ValueError("Invalid destination wallet address!")

    # 3. Create transaction with the selected provider
    tx = client.create_transaction(
        from_currency="btc",
        to_currency="eth",
        amount_deposit=0.1,
        address_receive="0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
        quota_id=best_offer.quota_id,
        refund_address="bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh",  # optional
    )

    print(f"Transaction Created! ID: {tx.transaction.id}")
    print(f"Send BTC to Deposit Address: {tx.transaction.address_deposit}")
    print(f"Status: {tx.transaction.status}")

2. Tracking Transaction Progress

Monitor swap progress from deposit to settlement:

current = client.get_transaction(tx.transaction.id)
print(f"Status: {current.status}")

if current.status == "finished":
    print(f"Received: {current.amount_receive} ETH")

3. Querying DEX Aggregation

Inspect supported DEX blockchains and token pairs:

# List supported DEX blockchains
blockchains = client.get_dex_blockchains()
print("DEX Blockchains:", blockchains)

# Check DEX tokens
dex_tokens = client.get_dex_tokens()
print(f"DEX Tokens count: {len(dex_tokens)}")

API Reference

Swapzone Class

Constructor

Swapzone(
    api_key: str,
    base_url: str = "https://api.swapzone.io/v1",
    timeout: float = 30.0,
)
Parameter Type Default Description
api_key str Required Your Swapzone API key.
base_url str "https://api.swapzone.io/v1" Swapzone API base URL.
timeout float 30.0 HTTP request timeout in seconds.

Methods

  • get_currencies() -> list[SupportedCurrency] — Returns all supported cryptocurrencies.
  • get_rate(from_currency, to_currency, amount, rate_type="all") -> RateOffer — Returns aggregated quotes.
  • create_transaction(from_currency, to_currency, amount_deposit, address_receive, quota_id, ...) -> TransactionResult — Creates transaction.
  • get_transaction(transaction_id: str) -> TransactionStatus — Checks swap status and execution details.
  • validate_address(currency, address) -> ValidateAddressResult — Validates destination wallet address.
  • get_markets(rate_type=None) -> list[Any] — Retrieves active market pairs.
  • get_dex_blockchains() -> list[DEXBlockchain] — Lists supported DEX blockchains.
  • get_dex_tokens() -> list[Any] — Lists tokens supported on DEX routers.

Error Handling

When the API returns an error, SwapzoneError is raised:

from swapzone import Swapzone, SwapzoneError

try:
    with Swapzone(api_key="invalid_key") as client:
        client.get_currencies()
except SwapzoneError as exc:
    print(f"Swapzone Error: {exc.message} (Status: {exc.status})")

Common HTTP status codes:

  • 400 Bad Request — Invalid address or amount out of limits.
  • 401 Unauthorized — Invalid API key.
  • 404 Not Found — Transaction ID not found.

License

ISC

Metadata

Release files for swapzone 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for swapzone 0.1.0
File Size Uploaded Provenance
swapzone-0.1.0.tar.gz 21.1 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for swapzone 0.1.0
File Interpreter ABI Platform
swapzone-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 29.4 kB

Release files / swapzone-0.1.0.tar.gz

Download URL swapzone-0.1.0.tar.gz
Size 21.1 kB
Tags Source
SHA-256 checksum
How to use checksums
94c1c1a5b87e3d78b107440becd567aec06c9aaa92c6eee80b95cbbfa7663c7a
BLAKE2b-256 checksum
How to use checksums
b08c8523911d45ac3517e62e41aec498a6795561d18047990eda456e701f42d1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / swapzone-0.1.0-py3-none-any.whl

Download URL swapzone-0.1.0-py3-none-any.whl
Size 8.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
63ef9e8fb33faa65c2d478cb878ba96f5e2393ae2b76abb1edf1918e4069438a
BLAKE2b-256 checksum
How to use checksums
f12e619309f3f7e123f78e82d4ed42e1a3787b4d22a7afcc939e23377b4a4672
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for swapzone 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page