get Quote
Retrieves a swap quote with transaction data.
This method fetches a swap quote that includes transaction data ready to be submitted to the blockchain. The quote includes the transaction object with all necessary fields (to, from, data, gas, etc.) that can be directly used with portal.request() to execute the swap.
The ZeroX API key can be configured in two ways:
Portal Dashboard (Recommended): Configure your ZeroX API key in the Portal Dashboard. The SDK will use it automatically when
zeroXApiKeyisnull.Per-Request Override: Provide the API key in the
zeroXApiKeyparameter to override the Dashboard configuration for this specific request.
Return
A Result containing ZeroXQuoteResponse with the quote including transaction data, buy/sell amounts, price, gas estimates, and a ready-to-submit transaction object. The response can be accessed via result.getOrNull()?.data?.rawResponse?.transaction for the transaction object, or result.getOrNull()?.data?.rawResponse?.buyAmount for the buy amount.
Parameters
The quote request parameters containing chain ID, tokens, amounts, and optional swap configuration. Use ZeroXQuoteRequest.create for convenience, which handles Boolean to String conversion for sellEntireBalance.
Note: The
chainIdin the request is included in the request body.
Optional ZeroX API key to override the one configured in Portal Dashboard.
If
null: The SDK will use the API key configured in the Portal Dashboard.If provided: This API key will be used for this request, overriding the Dashboard configuration.
The API key is used to authenticate requests to the ZeroX API service and is included in the request body.
Throws
if the URL cannot be constructed, or network/decoding errors if the request fails.