π Aggregator API
PiperX Aggregator exposes a set of APIs that allow developers to easily query optimal rates for a token swap. These APIs return additional swap data such as the precise swap route, routing parameters, and the encoded calldata required to interact with the Aggregator smart contract.
Public API
Story mainnet
https://piperxdb.piperxprotocol.workers.dev
Supported Networks
1514
Story Mainnet
API Documentation
Get swap quote
[GET] https://piperxdb.piperxprotocol.workers.dev/api/swap/swapExactToken
Returns the best swap quote based on the provided parameters.
QUERY PARAMETERS
tokenIn (string, required)
The address of the input token
Example: 0xF1815bd50389c46847f0Bda824eC8da914045D14
tokenOut (string, required)
The address of the output token
Example: 0x855bd6a8c5046d97c4e063e90e40f0f010d5423a
amount (string, required)
Amount of the input token in base units (raw integer)
Example: 1000000 means 1 token if the input token has 6 decimals.
type (string, required)
Routing type
Possible values:
exactInput,exactOutputDefault:
exactInputIf
exactInput,amountmeans input amountIf
exactOutput,amountmeans target output amount
isAggregator (boolean, optional)
Whether to use aggregator route logic
Default:
falseIf
true, will search multiple DEXes to optimize route.
Response Schema
num (string, required)
Final output amount calculated by the router, in raw base units.
universalRoutes (array, required)
Route list. Each route contains:
route(array) of hops Each hop includes:routerAddress(string)poolType(number) β0 = V2,1 = V3tokenIn(string)tokenOut(string)fee(number) β e.g.3000weight(number)
percent(number)amountIn(string)amountOut(string)
Example Request
Example Response
Protocol
Supported DEXes in Aggregator Mode (isAggregator=true)
isAggregator=true)When isAggregator=true, the PiperX Aggregator automatically selects the best route across the following DEXes:
PiperX V2
Classic V2-based AMM on PiperX
StoryHunt V3
V3 liquidity on Story chain
PiperX V3
Optimized V3-style pools on PiperX
These DEXes are automatically included in the route discovery β no need to manually specify protocols.
Last updated