Skip to content

across-protocol-py

CI PyPI Docs Python versions License: MIT

A typed Python client for the Across Protocol bridge API. It wraps the public, keyless quoting endpoints with pydantic v2 models and ships both synchronous and asynchronous httpx-based clients.

  • Sync (AcrossClient) and async (AsyncAcrossClient) clients with identical surfaces.
  • Fully typed (py.typed), validated request/response models.
  • Headline quoting via /suggested-fees, plus /available-routes, /limits, and deposit status tracking with a poll-to-terminal helper.

Installation

pip install across-protocol-py

Quickstart

Get a cross-chain bridge quote (USDC from Ethereum to Polygon) in a few lines:

from across_protocol import AcrossClient

with AcrossClient() as client:
    quote = client.get_suggested_fees(
        input_token="0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",   # USDC on Ethereum
        output_token="0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",  # USDC.e on Polygon
        origin_chain_id=1,
        destination_chain_id=137,
        amount=10_000_000,  # 10 USDC (6 decimals)
    )
    print(f"Output amount: {quote.output_amount}")
    print(f"Total relay fee: {quote.total_relay_fee.total}")
    print(f"Estimated fill time: {quote.estimated_fill_time_sec}s")

The async client mirrors the sync API:

import asyncio
from across_protocol import AsyncAcrossClient


async def main() -> None:
    async with AsyncAcrossClient() as client:
        quote = await client.get_suggested_fees(
            input_token="0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
            output_token="0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",
            origin_chain_id=1,
            destination_chain_id=137,
            amount=10_000_000,
        )
        print(quote.output_amount)


asyncio.run(main())

Other endpoints

with AcrossClient() as client:
    routes = client.get_available_routes()             # GET /available-routes
    limits = client.get_limits(...)                    # GET /limits
    status = client.get_deposit_status(                # GET /deposit/status
        origin_chain_id=1, deposit_id=2000000,
    )
    # Block until the deposit reaches a terminal state (filled / refunded / expired):
    final = client.wait_for_deposit(origin_chain_id=1, deposit_id=2000000)

Configuration

The base URL defaults to https://app.across.to/api and can be overridden:

client = AcrossClient(base_url="https://testnet.across.to/api", timeout=30.0)

Development

pip install -e ".[dev]"
ruff check .
mypy src
pytest -q                      # unit tests (respx-mocked)
pytest -m integration -q       # live integration test (hits the real API)

License

MIT