# LFJ Router API

## Get routes for a token swap

> One of amountIn or amountOut is required. Exact out calculation is not supported by some aggregators.

```json
{"openapi":"3.0.0","info":{"title":"LFJ Router API","version":"1.0.0"},"servers":[{"url":"https://router-api.lfj.dev"}],"paths":{"/v2/aggregator/routes/{chain}/{agg}/quote":{"get":{"summary":"Get routes for a token swap","description":"One of amountIn or amountOut is required. Exact out calculation is not supported by some aggregators.","parameters":[{"$ref":"#/components/parameters/chainParam"},{"$ref":"#/components/parameters/aggregatorParam"},{"$ref":"#/components/parameters/tokenInParam"},{"$ref":"#/components/parameters/tokenOutParam"},{"$ref":"#/components/parameters/amountInParam"},{"$ref":"#/components/parameters/amountOutParam"}],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/QuoteResponse"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}},"components":{"parameters":{"chainParam":{"name":"chain","in":"path","required":true,"schema":{"type":"string","enum":["avalanche"]},"description":"Chain identifier"},"aggregatorParam":{"name":"agg","in":"path","required":true,"schema":{"type":"string","enum":["flytrade","jar","kyber","odos","okx"]},"description":"Aggregator identifier"},"tokenInParam":{"name":"tokenIn","in":"query","required":true,"schema":{"type":"string"},"description":"Input token address"},"tokenOutParam":{"name":"tokenOut","in":"query","required":true,"schema":{"type":"string"},"description":"Output token address"},"amountInParam":{"name":"amountIn","in":"query","schema":{"type":"string"},"description":"Input token amount"},"amountOutParam":{"name":"amountOut","in":"query","schema":{"type":"string"},"description":"Output token amount"}},"schemas":{"QuoteResponse":{"type":"object","properties":{"tokenIn":{"$ref":"#/components/schemas/TokenWithSwaps"},"tokenOut":{"$ref":"#/components/schemas/Token"},"amountIn":{"type":"string","description":"Input token amount"},"amountOut":{"type":"string","description":"Output token amount"},"aggregator":{"type":"string","description":"Aggregator identifier"}}},"TokenWithSwaps":{"allOf":[{"$ref":"#/components/schemas/Token"},{"type":"object","properties":{"swaps":{"type":"array","items":{"$ref":"#/components/schemas/Swap"}}}}]},"Token":{"type":"object","properties":{"address":{"type":"string","description":"Token address"},"symbol":{"type":"string","description":"Token symbol"}}},"Swap":{"type":"object","properties":{"pair":{"type":"string","description":"Pair address"},"tokenIn":{"$ref":"#/components/schemas/Token","type":"object","description":"Input token"},"tokenOut":{"$ref":"#/components/schemas/TokenOut","type":"object","description":"Output token with swaps"},"amountBp":{"type":"integer","description":"Percentage of input token used for this swap in basis points"}}},"TokenOut":{"type":"object","properties":{"address":{"type":"string","description":"Token address"},"symbol":{"type":"string","description":"Token symbol"},"swaps":{"type":"array","items":{"type":"object"}}}},"Error":{"type":"object","properties":{"error":{"type":"string","description":"Error message"}}}}}}
```

## GET /v2/aggregator/routes/{chain}/{agg}/swap

> Get transaction data for a token swap

```json
{"openapi":"3.0.0","info":{"title":"LFJ Router API","version":"1.0.0"},"servers":[{"url":"https://router-api.lfj.dev"}],"paths":{"/v2/aggregator/routes/{chain}/{agg}/swap":{"get":{"summary":"Get transaction data for a token swap","parameters":[{"$ref":"#/components/parameters/chainParam"},{"$ref":"#/components/parameters/aggregatorParam"},{"$ref":"#/components/parameters/tokenInParam"},{"$ref":"#/components/parameters/tokenOutParam"},{"name":"amountIn","in":"query","required":true,"schema":{"type":"string"},"description":"Input token amount"},{"$ref":"#/components/parameters/userAddressParam"},{"$ref":"#/components/parameters/slippageBpsParam"},{"$ref":"#/components/parameters/feeBpsParam"},{"$ref":"#/components/parameters/feeRecipientAddressParam"}],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SwapResponse"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}},"components":{"parameters":{"chainParam":{"name":"chain","in":"path","required":true,"schema":{"type":"string","enum":["avalanche"]},"description":"Chain identifier"},"aggregatorParam":{"name":"agg","in":"path","required":true,"schema":{"type":"string","enum":["flytrade","jar","kyber","odos","okx"]},"description":"Aggregator identifier"},"tokenInParam":{"name":"tokenIn","in":"query","required":true,"schema":{"type":"string"},"description":"Input token address"},"tokenOutParam":{"name":"tokenOut","in":"query","required":true,"schema":{"type":"string"},"description":"Output token address"},"userAddressParam":{"name":"userAddress","in":"query","required":true,"schema":{"type":"string"},"description":"User's wallet address"},"slippageBpsParam":{"name":"slippageBps","in":"query","required":true,"schema":{"type":"integer","maximum":10000},"description":"Maximum slippage tolerance in basis points (1 bps = 0.01%)"},"feeBpsParam":{"name":"feeBps","in":"query","required":true,"schema":{"type":"integer","maximum":10000},"description":"Fee in basis points (1 bps = 0.01%)"},"feeRecipientAddressParam":{"name":"feeRecipientAddress","in":"query","schema":{"type":"string"},"description":"Fee recipient's wallet address. Required if feeBps is not zero."}},"schemas":{"SwapResponse":{"type":"object","properties":{"from":{"type":"string","description":"Transaction from address"},"to":{"type":"string","description":"Transaction to address"},"data":{"type":"string","description":"Transaction data"},"value":{"type":"string","description":"Transaction value"},"gas":{"type":"string","description":"Gas limit"},"gasPrice":{"type":"string","description":"Gas price"}}},"Error":{"type":"object","properties":{"error":{"type":"string","description":"Error message"}}}}}}
```

## GET /health-check

> Health check

```json
{"openapi":"3.0.0","info":{"title":"LFJ Router API","version":"1.0.0"},"servers":[{"url":"https://router-api.lfj.dev"}],"paths":{"/health-check":{"get":{"summary":"Health check","responses":{"200":{"description":"Service is healthy"},"503":{"description":"Service is unhealthy"}}}}}}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developers.lfj.gg/lfj-router-api/lfj-router-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
