KaleidoSwap SDK Python Bindings
Python bindings for the KaleidoSwap SDK: atomic swaps (Boltz protocol) between Bitcoin, Lightning, and Liquid.
Installation
python -m pip install kaleidorg_swap_sdk
Python 3.10+ is supported. Prebuilt wheels cover Linux x86_64/aarch64, macOS x86_64/arm64, and Windows x86_64; other platforms build the published source distribution and need a Rust 1.88+ toolchain.
Quick Start
⚠️ WARNING: All examples are only to be used in REGTEST.
import kaleidorg_swap_sdk
import asyncio
async def main():
# Initialize for regtest (do NOT use this example in production)
network = kaleidorg_swap_sdk.Network.REGTEST
boltz_api = kaleidorg_swap_sdk.BoltzApiClientV2.default(network)
# Example: Create a submarine swap (Lightning → Bitcoin)
key_pair = kaleidorg_swap_sdk.KeyPair()
btc_chain = kaleidorg_swap_sdk.btc_chain_from_network(network)
invoice = "lightning-invoice-to-pay"
request = kaleidorg_swap_sdk.CreateSubmarineRequest(
_from=btc_chain,
to=btc_chain,
invoice=invoice,
refund_public_key=key_pair.public(),
)
swap = await boltz_api.create_swap(request)
print(f"Send {swap.expected_amount} sats to {swap.address}")
asyncio.run(main())
Partner attribution (organization API keys)
A partner organization can have the swaps it originates attributed to it. That
needs an organization API key from the KaleidoSwap partner panel — a
kld_test_… key for signet and staging, kld_live_… for mainnet and
production. Without one, BoltzApiClientV2 behaves exactly as before and
creates unattributed swaps.
import os
import kaleidorg_swap_sdk
client = kaleidorg_swap_sdk.BoltzApiClientV2.kaleido_maker(
"https://maker.signet.kaleidoswap.com/v2",
os.environ["KALEIDOSWAP_API_KEY"],
None, # timeout in seconds
)
client.api_key_environment() # "test"
client.api_key_id() # the key id the partner panel shows
Scrub the key in error reporters that capture locals. It crosses the binding as a plain
str, so it is a function argument on a stack frame for the length of the call. The SDK keeps it out of its own errors, logs andrepr, but anything that renders frame locals —pytest --showlocals, Sentry'swith_locals, some logging formatters — reads it off the frame regardless. Scrub it in your reporter's before-send hook.
The result is an ordinary client — every swap route works the same way — that
sends the key as Authorization: Bearer … to that maker URL, and only to that
maker URL. The key answers which partner organization created this swap? and
nothing else: it authorizes no claim, no refund, no fund movement and no panel
access. The per-swap swap_auth credential the maker returns on create stays
separate and unchanged.
The URL must be https unless it is a loopback address, since a bearer
credential over plain HTTP is readable by anything on the path. A value that
cannot be a key is rejected here rather than reaching the maker as a 401 —
which is the same answer a revoked key gets. There is no accessor for the secret
half: api_key_id() and api_key_environment() are all the client will tell
you, and UniFFI renders no string form of the object at all.
Keep the key in server-side configuration. It is permanent until revoked, so never ship it inside a mobile or desktop application, where every user holds it.
Swap Types
- Submarine swaps - Lightning → On-chain Bitcoin/Liquid
- Reverse swaps - On-chain Bitcoin/Liquid → Lightning
- Chain swaps - Bitcoin ↔ Liquid atomic swaps
Examples
Complete working examples are available in the examples/ directory:
reverse.py- Lightning to Bitcoinsubmarine.py- Bitcoin to Lightningchain.py- Bitcoin to Liquid (and vice versa)
Release files for kaleidorg-swap-sdk 0.7.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| kaleidorg_swap_sdk-0.7.2.tar.gz | 261.2 kB | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| kaleidorg_swap_sdk-0.7.2-py3-none-win_amd64.whl | Python 3 | none | Windows x86-64 | Details |
| kaleidorg_swap_sdk-0.7.2-py3-none-manylinux_2_28_x86_64.whl | Python 3 | none | Linux glibc 2.28+ x86-64 | Details |
| kaleidorg_swap_sdk-0.7.2-py3-none-manylinux_2_28_aarch64.whl | Python 3 | none | Linux glibc 2.28+ ARM64 | Details |
| kaleidorg_swap_sdk-0.7.2-py3-none-macosx_11_0_arm64.whl | Python 3 | none | macOS 11.0+ ARM64 | Details |
| kaleidorg_swap_sdk-0.7.2-py3-none-macosx_10_12_x86_64.whl | Python 3 | none | macOS 10.12+ x86-64 | Details |
Total release size: 26.4 MB
Release files / kaleidorg_swap_sdk-0.7.2.tar.gz
| Download URL | kaleidorg_swap_sdk-0.7.2.tar.gz |
|---|---|
| Size | 261.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c036f61dbc48b91bd19a3ab2f48240496e4a2f8273f85123e8add074c5b3e881
|
|
BLAKE2b-256 checksum How to use checksums |
2244616537ed2a37e58f4a1960ff246b799a2e439c5ee1ce7fb94a5ae6436d2c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Release files / kaleidorg_swap_sdk-0.7.2-py3-none-win_amd64.whl
| Download URL | kaleidorg_swap_sdk-0.7.2-py3-none-win_amd64.whl |
|---|---|
| Size | 5.1 MB |
| Tags | Python 3 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
a4f3ac50d583da940229ef664e4c87edab570b8ae28b74bf6b916c2523209a8d
|
|
BLAKE2b-256 checksum How to use checksums |
84bc97d1e4edf6c1b1c9b24b2427fd2e1018cbbfca2ce73928e9f2258a3939f5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Release files / kaleidorg_swap_sdk-0.7.2-py3-none-manylinux_2_28_x86_64.whl
| Download URL | kaleidorg_swap_sdk-0.7.2-py3-none-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 5.3 MB |
| Tags | Linux glibc 2.28+ x86-64 Python 3 |
|
SHA-256 checksum How to use checksums |
663d2b62002f0205dbbbb6f29a7ff6db4d7f0c86f8077ec5f70f7c96eb9aed62
|
|
BLAKE2b-256 checksum How to use checksums |
4739c8429f5b46c31cbd618fd893d79b549255074bfbc7ad3cc3595767502ed4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Release files / kaleidorg_swap_sdk-0.7.2-py3-none-manylinux_2_28_aarch64.whl
| Download URL | kaleidorg_swap_sdk-0.7.2-py3-none-manylinux_2_28_aarch64.whl |
|---|---|
| Size | 5.3 MB |
| Tags | Linux glibc 2.28+ ARM64 Python 3 |
|
SHA-256 checksum How to use checksums |
a3f95d29c6581c45cfbf0269ddc46cedd855c3208e226df6244f22a8f9766f56
|
|
BLAKE2b-256 checksum How to use checksums |
530c2ff1d44a104ee251851790b353ab9e3c15df8239bf9c48f97ba8fe84e7d7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Release files / kaleidorg_swap_sdk-0.7.2-py3-none-macosx_11_0_arm64.whl
| Download URL | kaleidorg_swap_sdk-0.7.2-py3-none-macosx_11_0_arm64.whl |
|---|---|
| Size | 5.2 MB |
| Tags | Python 3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
7f104e121bc6d7362d3da0b0d7e4c3eb41186b28ef15eed50f9e1dba3ee8a351
|
|
BLAKE2b-256 checksum How to use checksums |
e166045aaa46823b6d052a983be6f219cb0583fa05d9f555f137cf85e3553fc4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Release files / kaleidorg_swap_sdk-0.7.2-py3-none-macosx_10_12_x86_64.whl
| Download URL | kaleidorg_swap_sdk-0.7.2-py3-none-macosx_10_12_x86_64.whl |
|---|---|
| Size | 5.2 MB |
| Tags | Python 3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
40295b5c4f203c5eee25361cc7643236fd76bebf810ee6b9c2fed8fbcce84bb1
|
|
BLAKE2b-256 checksum How to use checksums |
1c4979344de313071604e7c307677f1aa87c02833cab64af1c21112cc8dc68db
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|