get Price
Retrieves a price quote without transaction data.
This method fetches a price quote for a swap without generating transaction data. This is useful for:
Checking swap prices before committing to a transaction
Displaying price information to users
Comparing prices across different swap sources
Unlike getQuote(), this method does not return transaction data. The response includes price information, fees breakdown, and liquidity availability.
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 ZeroXPriceResponse with the price data, including buy/sell amounts, price, gas estimates, fees breakdown, and liquidity availability.
Parameters
The price request parameters containing chain ID, tokens, amounts, and optional swap configuration.
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.