> ## Documentation Index
> Fetch the complete documentation index at: https://docs.inkyswap.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Get Swap Quote

> Get a price quote for swapping tokens with optional transaction building

## Query Parameters

<ParamField query="tokenIn" type="string" required>
  Input token address (use `0x0000000000000000000000000000000000000000` for native ETH)
</ParamField>

<ParamField query="tokenOut" type="string" required>
  Output token address (use `0x0000000000000000000000000000000000000000` for native ETH)
</ParamField>

<ParamField query="amount" type="string">
  Amount of input token (in smallest unit). Either `amount` or `amountOut` must be provided
</ParamField>

<ParamField query="amountOut" type="string">
  Desired amount of output token (in smallest unit). Either `amount` or `amountOut` must be provided
</ParamField>

<ParamField query="slippage" type="string">
  Slippage tolerance in basis points (e.g., 100 = 1%). Range: 0-10000
</ParamField>

<ParamField query="buildTx" type="boolean" default="false">
  Whether to build the transaction data
</ParamField>

<ParamField query="userAddress" type="string">
  User's wallet address (required if `buildTx` is true)
</ParamField>

## Response

<ResponseField name="amountIn" type="string">
  Actual input amount in smallest unit
</ResponseField>

<ResponseField name="amountOut" type="string">
  Expected output amount in smallest unit
</ResponseField>

<ResponseField name="minimumAmountOut" type="string">
  Minimum output amount after slippage (if slippage provided)
</ResponseField>

<ResponseField name="maximumAmountIn" type="string">
  Maximum input amount after slippage (if using exact output)
</ResponseField>

<ResponseField name="executionRate" type="string">
  Exchange rate for this specific trade (accounts for price impact)
</ResponseField>

<ResponseField name="spotRate" type="string">
  Current spot price without price impact
</ResponseField>

<ResponseField name="path" type="array">
  Token addresses in the swap route
</ResponseField>

<ResponseField name="priceImpact" type="number">
  Estimated price impact percentage (0-1)
</ResponseField>

<ResponseField name="lpFee" type="string">
  Total LP fees in input token amount
</ResponseField>

<ResponseField name="metadata" type="object">
  Additional quote information

  <Expandable title="Metadata">
    <ResponseField name="lpFeePercent" type="number">
      LP fee percentage
    </ResponseField>

    <ResponseField name="routerAddress" type="string">
      Router contract address
    </ResponseField>

    <ResponseField name="slippageBps" type="number">
      Applied slippage in basis points
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="transaction" type="object">
  Transaction data (if `buildTx` is true)

  <Expandable title="Transaction">
    <ResponseField name="from" type="string">
      Sender address
    </ResponseField>

    <ResponseField name="to" type="string">
      Router contract address
    </ResponseField>

    <ResponseField name="data" type="string">
      Encoded transaction data
    </ResponseField>

    <ResponseField name="value" type="string">
      ETH value to send (for ETH swaps)
    </ResponseField>

    <ResponseField name="gasPrice" type="string">
      Estimated gas price
    </ResponseField>

    <ResponseField name="gas" type="string">
      Estimated gas limit
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseExample>
  ```json theme={null}
  {
    "amountIn": "1000000000000000000",
    "amountOut": "2500000000",
    "minimumAmountOut": "2475000000",
    "executionRate": "2500000000000000000000",
    "spotRate": "2505000000000000000000",
    "path": [
      "0x0000000000000000000000000000000000000000",
      "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
    ],
    "priceImpact": 0.002,
    "lpFee": "3000000000000000",
    "metadata": {
      "lpFeePercent": 0.003,
      "routerAddress": "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D",
      "slippageBps": 100
    },
    "transaction": {
      "from": "0x1234567890abcdef1234567890abcdef12345678",
      "to": "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D",
      "data": "0x7ff36ab500000...",
      "value": "1000000000000000000",
      "gasPrice": "50000000000",
      "gas": "250000"
    }
  }
  ```
</ResponseExample>

<RequestExample>
  ```bash cURL theme={null}
  curl -X GET "https://inkyswap.com/api/quote?tokenIn=0x0000000000000000000000000000000000000000&tokenOut=0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48&amount=1000000000000000000"

  curl -X GET "https://inkyswap.com/api/quote?tokenIn=0x0000000000000000000000000000000000000000&tokenOut=0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48&amount=1000000000000000000&slippage=100&buildTx=true&userAddress=0x1234567890abcdef1234567890abcdef12345678"
  ```

  ```typescript TypeScript theme={null}
  const response = await fetch(
    'https://inkyswap.com/api/quote?' + 
    new URLSearchParams({
      tokenIn: '0x0000000000000000000000000000000000000000',
      tokenOut: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
      amount: '1000000000000000000'
    })
  );
  const quote = await response.json();

  const txResponse = await fetch(
    'https://inkyswap.com/api/quote?' + 
    new URLSearchParams({
      tokenIn: '0x0000000000000000000000000000000000000000',
      tokenOut: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
      amount: '1000000000000000000',
      slippage: '100',
      buildTx: 'true',
      userAddress: '0x1234567890abcdef1234567890abcdef12345678'
    })
  );
  const txQuote = await txResponse.json();
  ```

  ```python Python theme={null}
  import requests

  response = requests.get(
      "https://inkyswap.com/api/quote",
      params={
          "tokenIn": "0x0000000000000000000000000000000000000000",
          "tokenOut": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
          "amount": "1000000000000000000"
      }
  )
  quote = response.json()

  tx_response = requests.get(
      "https://inkyswap.com/api/quote",
      params={
          "tokenIn": "0x0000000000000000000000000000000000000000",
          "tokenOut": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
          "amount": "1000000000000000000",
          "slippage": "100",
          "buildTx": "true",
          "userAddress": "0x1234567890abcdef1234567890abcdef12345678"
      }
  )
  tx_quote = tx_response.json()
  ```
</RequestExample>
