Pathfinder API - Requesting a Route
Requesting a Route
A route request JSON object contains the following fields:
chain_id: ID number of the chain to search
amount_in: Hex-string formatted swap amount in
token_in: Hex-string formatted swap input token address
token_out: Hex-string formatted swap output token address
max_hops: The maximum number of hops a trade may use between input and output
min_splits: The minimum number of split paths to accept for a trade route
max_splits: The maximum number of split paths to accept for a trade route
count: The number of best routes to return (currently returns 1 regardless of input)
Sample CURL request
Route Request Parameters In-Depth
In order to preserve pathfinder performance and to prevent unnecessarily deep searches, we have defined several parameter ranges for the route request object.
chain_id
You must submit a chain_id parameter in number format with your query -- this includes single-chain protocols. For multi-chain protocols, you may change your chain_id to route through your protocols' pools on the corresponding chain. You do not have to change your DEX ID.
Requests for routes via a chain on which you have no pools will result in a HTTP error 469: No Route Found.
amount_in
amount_in must be a hex-string formatted integer value of max uint128.
token_in
token_in must be a valid token for the chain_id submitted along with the request.
Requests for routes with invalid tokens will result in a HTTP error 469: No Route Found.
token_out
token_out must be a valid token for the chain_id submitted along with the request.
Requests for routes with invalid tokens will result in a HTTP error 469: No Route Found.
max_hops
For performance reasons, max_hops is capped at 4 for most networks.
Requests for routes with max_hops too high will result in HTTP error 403: Forbidden.
min_splits
min_splits must be smaller than max_splits.
Requests for routes with min_splits larger than max_splits will result in HTTP error 403: Forbidden.
max_splits
For performance reasons, max_splits is capped at 4 for most networks.
Requests for routes with max_splits too high will result in HTTP error 403: Forbidden.
count
While a count value must be passed along with the JSON object, the parameter is currently unused internally and the route request will return a single route regardless of count.
Last updated