Skip to main content

biatec-router (Python)

Python client for Biatec Router, a DEX aggregator API for the Algorand blockchain.

At the time of writing it is the most efficient DEX aggregator on Algorand as it routes trades across Pact.Fi, Tinyman and Biatec DEX - the first concentrated-liquidity AMM on Algorand, which other aggregators don't support.

This mirrors the biatec-router npm package for Python developers: a thin HTTP client plus an ARC-14 authentication helper. It does not sign or submit transactions for you - you decode, sign and send the transaction group with py-algorand-sdk as shown below.

Install

pip install biatec-router

Authentication

Every endpoint requires an Authorization header carrying a signed ARC-0014 transaction for the realm BiatecRouter#ARC14. The transaction is a zero-amount payment with the realm in the note field - it is never submitted to the network, it only proves control of an Algorand account.

from algosdk.v2client import algod
from biatec_router import build_auth_header, RouterClient

algod_client = algod.AlgodClient("", "https://mainnet-api.4160.nodely.dev")
suggested_params = algod_client.suggested_params()

# private_key from mnemonic.to_private_key(...), ARC-76, or however you manage keys
auth_header = build_auth_header(private_key, suggested_params)

router = RouterClient(
    base_url="https://router.api.biatec.io",  # or https://testnet.router.api.biatec.io
    auth_header=auth_header,
)

Request a quote

output_amount = router.quote(from_asset=0, to_asset=31566704, amount=5_000_000)
print(output_amount)  # estimated USDC (base units) for 5 ALGO

routes = router.route(from_asset=0, to_asset=31566704, amount=5_000_000, max_routes=1)
print(routes)

Fixed-output quotes (receive exactly N)

By default amount / swap_amount is the input. With swap_mode="FixedOutput" it is the wanted output (base units of to_asset): the router finds the smallest input whose quote reaches it (overshoot at most 0.1 %) and returns the ordinary route for that input. Execution is a normal swap of that input - keep receive_minimum.

from biatec_router import SWAP_MODE_FIXED_OUTPUT

# How much ALGO must I sell to receive 1 USDC?
required_input = router.quote(from_asset=0, to_asset=31566704, amount=1_000_000, swap_mode=SWAP_MODE_FIXED_OUTPUT)

response = router.route_txs(
    sender=account_address,
    from_asset=0,
    to_asset=31566704,
    swap_amount=1_000_000,       # wanted output
    receive_minimum=1_000_000,
    swap_mode=SWAP_MODE_FIXED_OUTPUT,
    send_maximum=7_000_000,      # refuse if more than 7 ALGO would be needed
)

The client checks that the router echoed the mode (X-Swap-Mode header for quote/route, input.swapMode for route_txs) and raises biatec_router.SwapModeNotSupportedError otherwise - an older router would treat the wanted output as an input. An unreachable target raises RouterApiError with status 404.

Execute a swap

Always set receive_minimum when executing to protect your funds. Never use 0 outside of a preview.

import algosdk
from algosdk import transaction

response = router.route_txs(
    sender=account_address,
    from_asset=0,
    to_asset=31566704,
    swap_amount=5_000_000,
    receive_minimum=4_900_000,
    routes_count=1,
    max_hops=3,
)

route = response["routes"][0]
if not route.get("txsToSign"):
    raise RuntimeError("No transactions to sign in the route.")

# Decode, group and sign
txns = [algosdk.encoding.msgpack_decode(b64) for b64 in route["txsToSign"]]
group_id = transaction.calculate_group_id(txns)
for txn in txns:
    txn.group = group_id

signed = [txn.sign(private_key) for txn in txns]
txid = algod_client.send_transactions(signed)
algosdk.transaction.wait_for_confirmation(algod_client, txid, 4)

API

  • RouterClient(base_url=..., auth_header=..., timeout=30.0)
    • .quote(from_asset, to_asset, amount, swap_mode="FixedInput") -> int
    • .route(from_asset, to_asset, amount, max_routes=1, swap_mode="FixedInput") -> list[dict]
    • .route_txs(sender, from_asset, to_asset, swap_amount, receive_minimum, routes_count=1, max_hops=3, swap_mode="FixedInput", send_maximum=None) -> dict
    • .stats() -> dict
    • .snapshot() -> dict
    • Raises biatec_router.RouterApiError (with .status_code / .body) on non-2xx responses, and biatec_router.SwapModeNotSupportedError when a FixedOutput request is not echoed as FixedOutput.
  • build_auth_header(private_key, suggested_params, realm="BiatecRouter#ARC14", sender=None) -> str
  • make_arc14_transaction(sender, suggested_params, realm="BiatecRouter#ARC14") / make_arc14_auth_header(signed_txn) - lower-level building blocks if you sign with something other than a raw private key (e.g. a wallet or AccountTransactionSigner).

Development

cd python
pip install -e ".[dev]"
pytest

See docs/PYPI_CICD.md in the repository root for how releases are published to PyPI.

Metadata

Release files for biatec-router 1.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 biatec-router 1.1.0
File Size Uploaded Provenance Actions
biatec_router-1.1.0.tar.gz 7.8 kB With provenance Details for biatec_router-1.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for biatec-router 1.1.0
File Interpreter ABI Platform Actions
biatec_router-1.1.0-py3-none-any.whl Python 3 none any Details for biatec_router-1.1.0-py3-none-any.whl

Total release size: 15.5 kB

Release files / biatec_router-1.1.0.tar.gz

Download URL biatec_router-1.1.0.tar.gz
Size 7.8 kB
Tags Source
SHA-256 checksum
How to use checksums
31fc7817fa555750510a9b50dc4b9f0c4c7dec857ecf8431435b6147dffa6008
BLAKE2b-256 checksum
How to use checksums
a8be2302266b2714f6585ba8be192a35764f6cc2978ed24196ccb2de2f6e8b86
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.

Transparency log

Release files / biatec_router-1.1.0-py3-none-any.whl

Download URL biatec_router-1.1.0-py3-none-any.whl
Size 7.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
016ca040525a106859dea55ef3439b6a759d9124166225bcd9575629eef0753a
BLAKE2b-256 checksum
How to use checksums
c913cf38b8f03ada0dcd621fb4dfb78aad59e4cac32234a50d682ab58374606d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.

Transparency log

Security for biatec-router 1.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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for biatec_router-1.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.

Transparency log

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.

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