Skip to main content
Below are the two methods to get a quote for a swap from a given route using JSON-RPC or REST-API:
When providing HBAR in the path array, use the wrapped HBAR token ID (WHBAR).

Get output quote from input amount

No gas cost — read-only call. Get the output amounts from a given input amount and a swap route. Function name: getAmountsOut

Code overview

Resources:

Get input quote from output amount

No gas cost — read-only call. Get the input amounts from a given output amount and a swap route. Function name: getAmountsIn

Code overview

Resources:

Next steps

Swap HBAR for tokens (V1)

Execute the swap you just quoted with the V1 router.

Swap quote (V2)

Quote against V2 concentrated liquidity with QuoterV2.

Contract deployments

Router, factory, and token IDs for mainnet and testnet.