API reference
squidrouter
squidrouter-py: a typed Python client for the Squid Router API.
Squid Router is an Axelar-powered aggregator for cross-chain swaps and bridging.
This package provides synchronous (:class:SquidClient) and asynchronous
(:class:AsyncSquidClient) clients built on httpx and pydantic.
Every request requires an integrator ID (free from the Squid integrator portal),
sent by default in the x-integrator-id header.
AsyncSquidClient
Asynchronous client for the Squid Router v2 API.
The async counterpart to :class:~squidrouter.SquidClient, built on
:class:httpx.AsyncClient. Every request requires an integrator ID, sent by
default in the x-integrator-id header. Obtain a free integrator ID from
the Squid integrator portal (https://docs.squidrouter.com).
Use it as an async context manager to ensure the connection pool is closed::
async with AsyncSquidClient(integrator_id="my-id") as client:
chains = await client.get_chains()
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
integrator_id
|
str
|
The integrator ID issued by Squid. Required. |
required |
base_url
|
str
|
Base URL of the Squid API. Defaults to the v2 endpoint at
|
DEFAULT_BASE_URL
|
integrator_header
|
str
|
Header name carrying the integrator ID. Defaults to
|
DEFAULT_INTEGRATOR_HEADER
|
timeout
|
float
|
Request timeout in seconds. |
DEFAULT_TIMEOUT
|
client
|
Optional[AsyncClient]
|
An optional pre-configured :class: |
None
|
aclose()
async
Close the underlying HTTP client if it is owned by this instance.
get_chains()
async
Fetch the chains supported by Squid Router.
Returns:
| Name | Type | Description |
|---|---|---|
A |
ChainsResponse
|
class: |
ChainsResponse
|
chains. |
Raises:
| Type | Description |
|---|---|
SquidAPIError
|
If the API returns an unsuccessful status. |
get_tokens()
async
Fetch the tokens supported by Squid Router.
Returns:
| Name | Type | Description |
|---|---|---|
A |
TokensResponse
|
class: |
TokensResponse
|
tokens. |
Raises:
| Type | Description |
|---|---|
SquidAPIError
|
If the API returns an unsuccessful status. |
get_route(request)
async
Request an optimal cross-chain route (quote) for a swap or bridge.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
Union[RouteRequest, dict[str, Any]]
|
The route parameters, either a
:class: |
required |
Returns:
| Name | Type | Description |
|---|---|---|
A |
RouteResponse
|
class: |
RouteResponse
|
populated from the |
|
RouteResponse
|
|
Raises:
| Type | Description |
|---|---|
SquidAPIError
|
If the API returns an unsuccessful status. |
get_status(*, transaction_id, request_id=None, from_chain_id=None, to_chain_id=None, quote_id=None)
async
Fetch the status of a cross-chain transaction.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
transaction_id
|
str
|
The source-chain transaction hash. |
required |
request_id
|
Optional[str]
|
The |
None
|
from_chain_id
|
Optional[Union[int, str]]
|
The source chain ID. |
None
|
to_chain_id
|
Optional[Union[int, str]]
|
The destination chain ID. |
None
|
quote_id
|
Optional[str]
|
The |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
A |
StatusResponse
|
class: |
Raises:
| Type | Description |
|---|---|
SquidAPIError
|
If the API returns an unsuccessful status. |
poll_status(*, transaction_id, request_id=None, from_chain_id=None, to_chain_id=None, quote_id=None, interval=5.0, timeout=600.0)
async
Poll :meth:get_status until the transaction reaches a terminal state.
Terminal states are success, partial_success, needs_gas and
not_found. A 404 (transaction not yet indexed) is treated as
in-progress and retried.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
transaction_id
|
str
|
The source-chain transaction hash. |
required |
request_id
|
Optional[str]
|
The |
None
|
from_chain_id
|
Optional[Union[int, str]]
|
The source chain ID. |
None
|
to_chain_id
|
Optional[Union[int, str]]
|
The destination chain ID. |
None
|
quote_id
|
Optional[str]
|
The |
None
|
interval
|
float
|
Seconds to wait between polls. |
5.0
|
timeout
|
float
|
Maximum total seconds to poll before giving up. |
600.0
|
Returns:
| Type | Description |
|---|---|
StatusResponse
|
The terminal :class: |
Raises:
| Type | Description |
|---|---|
StatusTimeoutError
|
If no terminal state is reached within
|
SquidAPIError
|
For non-404 API errors. |
SquidClient
Synchronous client for the Squid Router v2 API.
Squid is an Axelar-powered aggregator for cross-chain swaps and bridging.
Every request requires an integrator ID, sent by default in the
x-integrator-id header. Obtain a free integrator ID from the Squid
integrator portal (https://docs.squidrouter.com).
The client may be used as a context manager to ensure the underlying connection pool is closed::
with SquidClient(integrator_id="my-id") as client:
chains = client.get_chains()
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
integrator_id
|
str
|
The integrator ID issued by Squid. Required. |
required |
base_url
|
str
|
Base URL of the Squid API. Defaults to the v2 endpoint at
|
DEFAULT_BASE_URL
|
integrator_header
|
str
|
Header name carrying the integrator ID. Defaults to
|
DEFAULT_INTEGRATOR_HEADER
|
timeout
|
float
|
Request timeout in seconds. |
DEFAULT_TIMEOUT
|
client
|
Optional[Client]
|
An optional pre-configured :class: |
None
|
close()
Close the underlying HTTP client if it is owned by this instance.
get_chains()
Fetch the chains supported by Squid Router.
Returns:
| Name | Type | Description |
|---|---|---|
A |
ChainsResponse
|
class: |
ChainsResponse
|
chains. |
Raises:
| Type | Description |
|---|---|
SquidAPIError
|
If the API returns an unsuccessful status. |
get_tokens()
Fetch the tokens supported by Squid Router.
Returns:
| Name | Type | Description |
|---|---|---|
A |
TokensResponse
|
class: |
TokensResponse
|
tokens. |
Raises:
| Type | Description |
|---|---|
SquidAPIError
|
If the API returns an unsuccessful status. |
get_route(request)
Request an optimal cross-chain route (quote) for a swap or bridge.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
Union[RouteRequest, dict[str, Any]]
|
The route parameters, either a
:class: |
required |
Returns:
| Name | Type | Description |
|---|---|---|
A |
RouteResponse
|
class: |
RouteResponse
|
populated from the |
|
RouteResponse
|
|
Raises:
| Type | Description |
|---|---|
SquidAPIError
|
If the API returns an unsuccessful status. |
get_status(*, transaction_id, request_id=None, from_chain_id=None, to_chain_id=None, quote_id=None)
Fetch the status of a cross-chain transaction.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
transaction_id
|
str
|
The source-chain transaction hash. |
required |
request_id
|
Optional[str]
|
The |
None
|
from_chain_id
|
Optional[Union[int, str]]
|
The source chain ID. |
None
|
to_chain_id
|
Optional[Union[int, str]]
|
The destination chain ID. |
None
|
quote_id
|
Optional[str]
|
The |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
A |
StatusResponse
|
class: |
Raises:
| Type | Description |
|---|---|
SquidAPIError
|
If the API returns an unsuccessful status. |
poll_status(*, transaction_id, request_id=None, from_chain_id=None, to_chain_id=None, quote_id=None, interval=5.0, timeout=600.0)
Poll :meth:get_status until the transaction reaches a terminal state.
Terminal states are success, partial_success, needs_gas and
not_found. A 404 (transaction not yet indexed) is treated as
in-progress and retried.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
transaction_id
|
str
|
The source-chain transaction hash. |
required |
request_id
|
Optional[str]
|
The |
None
|
from_chain_id
|
Optional[Union[int, str]]
|
The source chain ID. |
None
|
to_chain_id
|
Optional[Union[int, str]]
|
The destination chain ID. |
None
|
quote_id
|
Optional[str]
|
The |
None
|
interval
|
float
|
Seconds to wait between polls. |
5.0
|
timeout
|
float
|
Maximum total seconds to poll before giving up. |
600.0
|
Returns:
| Type | Description |
|---|---|
StatusResponse
|
The terminal :class: |
Raises:
| Type | Description |
|---|---|
StatusTimeoutError
|
If no terminal state is reached within
|
SquidAPIError
|
For non-404 API errors. |
SquidAPIError
Bases: SquidError
Raised when the Squid Router API returns an unsuccessful HTTP status.
Attributes:
| Name | Type | Description |
|---|---|---|
status_code |
The HTTP status code returned by the API. |
|
message |
A human-readable error message, extracted from the response body when possible. |
|
response_body |
The decoded JSON body of the error response, or the raw text when the body is not valid JSON. |
|
request_id |
The value of the |
SquidError
Bases: Exception
Base class for all errors raised by :mod:squidrouter.
StatusTimeoutError
Bases: SquidError
Raised when :meth:poll_status does not reach a terminal state in time.
Attributes:
| Name | Type | Description |
|---|---|---|
last_status |
The most recent |
Chain
Bases: SquidModel
A chain supported by Squid Router (GET /v2/chains).
Attributes:
| Name | Type | Description |
|---|---|---|
chain_id |
Optional[Union[int, str]]
|
The chain's identifier, sent as |
chain_name |
Optional[str]
|
Human-readable chain name, sent as |
chain_type |
Optional[str]
|
The chain family (e.g. |
network_name |
Optional[str]
|
The network name, sent as |
rpc |
Optional[str]
|
The default RPC endpoint for the chain. |
ChainsResponse
Bases: SquidModel
Response for GET /v2/chains.
Attributes:
| Name | Type | Description |
|---|---|---|
chains |
list[Chain]
|
The list of supported chains. |
Estimate
Bases: SquidModel
Estimated outcome of a route.
Attributes:
| Name | Type | Description |
|---|---|---|
to_amount |
Optional[str]
|
Estimated amount received at the destination, as a string. |
to_amount_min |
Optional[str]
|
Minimum guaranteed amount after slippage, as a string. |
fee_costs |
Optional[list[dict[str, Any]]]
|
List of fee breakdown objects. |
gas_costs |
Optional[list[dict[str, Any]]]
|
List of gas cost breakdown objects. |
estimated_route_duration |
Optional[Union[int, float]]
|
Estimated route duration in seconds. |
Route
Bases: SquidModel
A single cross-chain route returned by POST /v2/route.
Attributes:
| Name | Type | Description |
|---|---|---|
estimate |
Optional[Estimate]
|
The estimated outcome of executing this route. |
transaction_request |
Optional[TransactionRequest]
|
The signable transaction for this route, sent by
the API as |
quote_id |
Optional[str]
|
Identifier for this quote, sent as |
params |
Optional[dict[str, Any]]
|
Echo of the route parameters used to compute this route. |
RouteRequest
Bases: BaseModel
Parameters for a cross-chain route request (POST /v2/route).
Attributes:
| Name | Type | Description |
|---|---|---|
from_chain |
str
|
Source chain ID (e.g. |
from_token |
str
|
Source token contract address. Sent as |
from_amount |
str
|
Amount to swap, in the token's smallest unit (wei-style
integer string). Sent as |
to_chain |
str
|
Destination chain ID (e.g. |
to_token |
str
|
Destination token contract address. Sent as |
from_address |
str
|
Address initiating the swap. Sent as |
to_address |
str
|
Address receiving the swapped tokens. Sent as |
slippage |
Optional[float]
|
Maximum acceptable slippage as a percentage (e.g. |
slippage_config |
Optional[dict[str, Any]]
|
Advanced slippage configuration object, sent as
|
enable_boost |
Optional[bool]
|
Whether to enable Squid Boost for faster settlement. Sent
as |
quote_only |
Optional[bool]
|
When |
to_payload()
Serialize to the JSON body expected by POST /v2/route.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
A dict using the API's camelCase field names, omitting unset |
dict[str, Any]
|
optional values. |
RouteResponse
Bases: SquidModel
Top-level response for POST /v2/route.
Attributes:
| Name | Type | Description |
|---|---|---|
route |
Optional[Route]
|
The computed route, including estimate and transaction request. |
request_id |
Optional[str]
|
The |
StatusResponse
Bases: SquidModel
Response for GET /v2/status.
Attributes:
| Name | Type | Description |
|---|---|---|
squid_transaction_status |
Optional[str]
|
Overall status of the cross-chain transaction.
Terminal values include |
status |
Optional[str]
|
A finer-grained status string, when provided by the API. |
id |
Optional[str]
|
The transaction identifier echoed by the API. |
from_chain |
Optional[dict[str, Any]]
|
Source-chain status object. |
to_chain |
Optional[dict[str, Any]]
|
Destination-chain status object. |
Token
Bases: SquidModel
A token supported by Squid Router (GET /v2/tokens).
Attributes:
| Name | Type | Description |
|---|---|---|
symbol |
Optional[str]
|
The token's ticker symbol. |
name |
Optional[str]
|
The token's display name. |
address |
Optional[str]
|
The token's contract address. |
decimals |
Optional[int]
|
The token's decimal precision. |
chain_id |
Optional[Union[int, str]]
|
The chain the token lives on, sent as |
coingecko_id |
Optional[str]
|
The CoinGecko identifier, sent as |
logo_uri |
Optional[str]
|
A URI to the token logo, sent as |
TokensResponse
Bases: SquidModel
Response for GET /v2/tokens.
Attributes:
| Name | Type | Description |
|---|---|---|
tokens |
list[Token]
|
The list of supported tokens. |
TransactionRequest
Bases: SquidModel
An on-chain transaction to execute a route.
Attributes:
| Name | Type | Description |
|---|---|---|
target |
Optional[str]
|
Contract address to send the transaction to. Some responses use
|
data |
Optional[str]
|
Calldata for the transaction. |
value |
Optional[str]
|
Native token value to send, as a string. |
gas_limit |
Optional[str]
|
Suggested gas limit, sent by the API as |
gas_price |
Optional[str]
|
Suggested gas price, sent by the API as |