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

# Get Swap Quote

> Returns the best swap quote for a pair of tokens and an input amount from the nexroute routing engine.



## OpenAPI

````yaml /router/api-reference/openapi.json post /quote
openapi: 3.1.0
info:
  title: nexroute Router API
  version: 1.0.0
  description: >-
    nexroute is a high-performance routing engine designed to provide fast and
    accurate swap quotes for various applications.
servers:
  - url: https://api.nexroute.io/v1
    description: API v1
security:
  - ApiKeyAuth: []
paths:
  /quote:
    post:
      tags:
        - Quote
      summary: Get Swap Quote
      description: >-
        Returns the best swap quote for a pair of tokens and an input amount
        from the nexroute routing engine.
      operationId: getSwapQuote
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/QuoteParams'
      responses:
        '200':
          description: Successful quote response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/QuoteResult'
        '400':
          description: Invalid request data
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationError'
        '401':
          description: Missing or invalid API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnauthorizedError'
        '422':
          description: Quote could not be produced (no route, insufficient liquidity, etc.)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/QuoteError'
        '429':
          description: Rate limit exceeded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RateLimitError'
        '502':
          description: Upstream node unreachable or returned an HTTP error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UpstreamError'
      security:
        - ApiKeyAuth: []
components:
  schemas:
    QuoteParams:
      type: object
      required:
        - tokenIn
        - tokenOut
        - amountIn
      properties:
        tokenIn:
          type: string
          pattern: ^0x[a-fA-F0-9]{40}$
          description: Input token contract address (0x-prefixed, 40 hex characters)
          example: '0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c'
        tokenOut:
          type: string
          pattern: ^0x[a-fA-F0-9]{40}$
          description: Output token contract address (0x-prefixed, 40 hex characters)
          example: '0x55d398326f99059fF775485246999027B3197955'
        amountIn:
          type: string
          pattern: ^[1-9]\d*$
          description: Input amount in wei (uint256 as decimal string, must be > 0)
          example: '1000000000000000000'
    QuoteResult:
      type: object
      properties:
        amountOut:
          type: string
          description: Output amount in wei (uint256 as decimal string)
          example: '8643194859422640072'
        gas:
          type: integer
          description: Estimated gas cost
          example: 237995
        calldata:
          type: string
          description: Calldata for the swap transaction
          example: 0x8f01f039...
        router:
          type: string
          description: Router contract address to call
          example: '0x365193e7e200CC2Ce82eb67DB0Fed117F8C7c660'
        spender:
          type: string
          description: Spender address for token approval
          example: '0x365193e7e200CC2Ce82eb67DB0Fed117F8C7c660'
    ValidationError:
      type: object
      properties:
        code:
          type: string
          example: VALIDATION_ERROR
        message:
          type: string
          example: Invalid request data
        details:
          type: array
          description: Validation error details
    UnauthorizedError:
      type: object
      properties:
        code:
          type: string
          example: UNAUTHORIZED
        message:
          type: string
          example: Invalid API key.
    QuoteError:
      type: object
      properties:
        code:
          type: string
          example: QUOTE_ERROR
        message:
          type: string
          example: No quote available
        details:
          description: Additional error details
    RateLimitError:
      type: object
      properties:
        code:
          type: string
          example: RATE_LIMIT_EXCEEDED
        message:
          type: string
          example: Too many requests, please try again later.
    UpstreamError:
      type: object
      properties:
        code:
          type: string
          example: UPSTREAM_ERROR
        message:
          type: string
          example: 'Upstream error: HTTP 500 Internal Server Error'
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
      description: API key for authentication

````