relay-link-py
A typed Python client for the Relay Protocol API — a fast
crosschain bridge and swap protocol. Sync and async, pydantic v2 models,
py.typed, no network needed to import.
- Base URL:
https://api.relay.link(configurable) - API reference: https://docs.relay.link/references/api/overview
- OpenAPI spec: https://api.relay.link/documentation/json
Install
pip install relay-link-py
Python 3.9+ is supported. The data layer needs only httpx and pydantic.
Signing the transaction steps a quote returns is out of scope for the core
client; install the optional extra if you want web3 / solders available:
pip install "relay-link-py[exec]"
Quickstart
from relay_link import RelayClient, TradeType
NATIVE = "0x0000000000000000000000000000000000000000"
with RelayClient() as client:
# List supported chains (no API key required)
chains = client.get_chains()
print(f"{len(chains)} chains supported")
# Get an executable quote: bridge 1 ETH from Base (8453) to Optimism (10)
quote = client.get_quote(
user="0x03508bb71268bba25ecacc8f620e01866650532c",
origin_chain_id=8453,
destination_chain_id=10,
origin_currency=NATIVE,
destination_currency=NATIVE,
amount="1000000000000000000", # 1 ETH in wei
trade_type=TradeType.EXACT_INPUT,
)
for step in quote.steps:
print(step.kind, step.id, step.action)
Async
import asyncio
from relay_link import AsyncRelayClient, TradeType
async def main():
async with AsyncRelayClient() as client:
chains = await client.get_chains()
print(len(chains))
asyncio.run(main())
Polling execution status
After you submit a step's transaction on-chain, poll its requestId until it
reaches a terminal state (success, failure, or refund):
status = client.poll_status(request_id="0x...", interval=2, timeout=120)
print(status.status, status.tx_hashes)
Configuration
client = RelayClient(
base_url="https://api.relay.link", # configurable
api_key="your-key", # optional; sent on every request
api_key_header="x-api-key", # configurable header name
timeout=30.0,
max_retries=3, # retries for 429 / 5xx responses
backoff_base=0.5, # exponential backoff base (seconds)
)
Quotes are public and need no API key.
Retries and errors
429 and transient 5xx responses are retried up to max_retries times with
exponential backoff, honoring a Retry-After header when present. The
exception hierarchy:
RelayError— base class for everything this library raises.RelayAPIError— non-2xx response; carriesstatus_code,message,body.RelayRateLimitError—429after retries are exhausted; addsretry_after.
RelayConnectionError— could not reach the API.RelayTimeoutError— the request timed out.
API surface
| Method | Endpoint | Description |
|---|---|---|
get_chains() |
GET /chains |
List supported chains |
get_quote(...) |
POST /quote/v2 |
Executable bridge/swap/call quote |
get_price(...) |
POST /price |
Non-executable price estimate |
get_status(request_id=...) |
GET /intents/status/v3 |
Execution status |
poll_status(request_id=...) |
GET /intents/status/v3 |
Poll to a terminal state |
get_requests(...) |
GET /requests |
List relay requests |
get_token_price(address=..., chain_id=...) |
GET /currencies/token/price |
Token USD price |
AsyncRelayClient exposes the same methods as awaitables.
Development
uv pip install -e ".[dev]"
ruff check .
mypy --strict src tests
pytest # unit tests (network mocked)
pytest -m integration # one live test against GET /chains
License
MIT
Metadata
Release files for relay-link-py 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| relay_link_py-0.1.0.tar.gz | 25.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| relay_link_py-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 43.9 kB
Release files / relay_link_py-0.1.0.tar.gz
| Download URL | relay_link_py-0.1.0.tar.gz |
|---|---|
| Size | 25.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
33f33f3e0cf51e4a31f1f65375515556b86ca356b0567fdef74ea71f4175c22b
|
|
BLAKE2b-256 checksum How to use checksums |
b554a5d11fdd9283566caf93efc4c0496363f5ee76e34c461c89449e1e754dbb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.9
|
Release files / relay_link_py-0.1.0-py3-none-any.whl
| Download URL | relay_link_py-0.1.0-py3-none-any.whl |
|---|---|
| Size | 18.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c191f0a0cd3aaaac8d88744f60ba393af6a03772d219949f7dfacd68ccdcf631
|
|
BLAKE2b-256 checksum How to use checksums |
e142eb94ae00342886e1b9a1626b9116f24c89da4614722b5028c39f691830d0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.9
|