Build your first integration
1. Create an API key
Sign in to the API Hub, open Dashboard and create a key. Copy it immediately: only its hash is stored. Put the key in your server environment; never ship it in public frontend code or commit it to Git.
2. Request a quote
curl 'https://amm-api.pikapika-app.com/v1/v2/quote' \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'Content-Type: application/json' \
--data '{"reserve_in":"1000000","reserve_out":"2000000","amount_in":"1000","fee_bps":30,"token_in_decimals":18,"token_out_decimals":18}'
The output is 1992 raw units. With 18 output decimals this means 0.000000000000001992 tokens. The example uses deliberately small reserves; it is not a live market price.
Node.js / TypeScript
const response = await fetch('https://amm-api.pikapika-app.com/v1/v2/quote', {
method: 'POST',
headers: {Authorization: 'Bearer ' + process.env.PIKAPIKA_API_KEY,
'Content-Type': 'application/json'},
body: JSON.stringify({reserve_in: '1000000', reserve_out: '2000000',
amount_in: '1000', fee_bps: 30, token_in_decimals: 18, token_out_decimals: 18})
});
const result = await response.json();
if (!response.ok) throw new Error(result.error?.code);
const rawOutput = BigInt(result.data.amount_out);
Python
import os, requests
r = requests.post('https://amm-api.pikapika-app.com/v1/v2/quote',
headers={'Authorization': 'Bearer ' + os.environ['PIKAPIKA_API_KEY']},
json={'reserve_in':'1000000', 'reserve_out':'2000000',
'amount_in':'1000', 'fee_bps':30,
'token_in_decimals':18, 'token_out_decimals':18}, timeout=10)
r.raise_for_status()
raw_output = int(r.json()['data']['amount_out'])
V3 exact-input interval quote
POST /v1/v3/quote
{"sqrt_price_x96":"79228162514264337593543950336",
"sqrt_boundary_x96":"70000000000000000000000000000",
"liquidity":"1000000000000000000", "amount_in":"1000000000000",
"fee_pips":3000, "zero_for_one":true}
Price is Q64.96; liquidity is uint128; amount is uint256. zero_for_one=true sends token0 and receives token1. Fee 3000 pips is 0.30%; V2 fee 30 bps is also 0.30%. Supply the nearest initialized tick boundary in that direction. This endpoint does not traverse ticks or verify the pool snapshot. If the amount reaches the boundary, it returns V3_TICK_CROSSING_REQUIRED; obtain tick state or reduce input. Do not present this as a full multi-tick quote.
Endpoints & computation units
| Endpoint | Scope | Units |
|---|
| /v1/v2/quote | Constant product, supplied reserves | 1 |
| /v1/v3/quote | One liquidity interval | 1 |
| /v1/route/evaluate | 1–5 connected V2 pools | 1 |
| /v1/v2/arbitrage | Bounded two-pool optimization | 82 |
| /v1/break-even | Separate raw-unit cost budget | 1 |
| /v1/batch/evaluate | 1–8 items, total at most 82 units | Sum |
Rounding and profit
Amounts must be decimal strings, not JSON numbers. Convert human amounts with exact integer arithmetic using token decimals. V2 reserves fit uint112. Outputs round down; fee reporting rounds up. DEX fees are already included in swap output. For cyclic routes, net profit subtracts the starting principal, gas cost and flash fee once. Gas cost must already be converted into starting-token raw units; the API does not fetch gas prices or USD rates. Noncyclic profit is null. Repeated pools and disconnected tokens are rejected.
Errors and retries
400: invalid input or unsupported tick crossing; fix the request. 401: missing/revoked key. 413: body exceeds 32 KiB. 415: use application/json. 429: rate or quota exceeded; respect Retry-After and your plan. 503: temporarily unavailable; bounded exponential backoff is appropriate. Failed requests after quota reservation consume their computation units. Keep request_id when contacting support; do not send your key.
Pool state freshness, asset identity and decimals are the caller's responsibility. The API performs calculations; it neither submits transactions nor guarantees execution or profit.
Download OpenAPI 3.1