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

# Calculate Best Path Quote

> Calculates the best swap path and quote for given token pair and amount



## OpenAPI

````yaml /kuru-flow/openapi.json post /api/quote
openapi: 3.0.3
info:
  title: Kuru WebSocket API
  description: >-
    API for Kuru WebSocket services including JWT token generation and swap
    quote calculations
  version: 1.0.0
servers:
  - url: https://ws.kuru.io
    description: Main server
security: []
paths:
  /api/quote:
    post:
      summary: Calculate Best Path Quote
      description: Calculates the best swap path and quote for given token pair and amount
      operationId: calculateBestPath
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CalculateBestPathRequest'
            example:
              userAddress: '0x1234567890abcdef1234567890abcdef12345678'
              tokenIn: '0x0000000000000000000000000000000000000000'
              tokenOut: '0x754704bc059f8c67012fed69bc8a327a5aafb603'
              amount: '1000000000000000000'
              slippageTolerance: 50
              autoSlippage: true
              referrerAddress: '0x5678567856785678567856785678567856785678'
              referrerFeeBps: 25
      responses:
        '200':
          description: Successfully calculated best path
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CalculateBestPathResponse'
              example:
                type: swap_calculation
                status: success
                output: '950000000000000000'
                path: {}
                buildResponse: {}
                gasPrices: {}
        '400':
          description: Bad Request - Invalid input
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                invalid_json:
                  value:
                    error: invalid_json
                missing_fields:
                  value:
                    error: missing_required_fields
        '401':
          description: Unauthorized - Invalid or missing authentication
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error: unauthorized
        '405':
          description: Method Not Allowed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error: method_not_allowed
        '429':
          description: Too Many Requests - Rate limit exceeded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error: too_many_requests
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error: calculation_failed
                message: Failed to calculate swap path
        '503':
          description: Service Unavailable
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error: service_unavailable
      security:
        - BearerAuth: []
        - ApiKeyAuth: []
components:
  schemas:
    CalculateBestPathRequest:
      type: object
      required:
        - userAddress
        - tokenIn
        - tokenOut
        - amount
      oneOf:
        - required:
            - autoSlippage
          properties:
            autoSlippage:
              type: boolean
              enum:
                - true
          not:
            required:
              - slippageTolerance
        - required:
            - slippageTolerance
          properties:
            autoSlippage:
              type: boolean
              enum:
                - false
      properties:
        userAddress:
          type: string
          description: Ethereum address of the user
          pattern: ^0x[a-fA-F0-9]{40}$
          example: '0x1234567890abcdef1234567890abcdef12345678'
        tokenIn:
          type: string
          description: Address of the input token
          pattern: ^0x[a-fA-F0-9]{40}$
          example: '0xA0b86a33E6441051686442d3a1BA4Fab4F85d2b2'
        tokenOut:
          type: string
          description: Address of the output token
          pattern: ^0x[a-fA-F0-9]{40}$
          example: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'
        amount:
          type: string
          description: Amount to swap (in wei for tokens with 18 decimals)
          example: '1000000000000000000'
        slippageTolerance:
          type: integer
          format: uint16
          description: Slippage tolerance in basis points (e.g., 50 = 0.5%)
          minimum: 1
          maximum: 10000
          example: 50
        autoSlippage:
          type: boolean
          description: Whether to use automatic slippage calculation
          example: true
        referrerAddress:
          type: string
          description: Optional referrer address for fee sharing
          pattern: ^0x[a-fA-F0-9]{40}$
          example: '0x5678567856785678567856785678567856785678'
        referrerFeeBps:
          type: integer
          format: uint16
          description: Optional referrer fee in basis points
          minimum: 0
          maximum: 10000
          example: 25
    CalculateBestPathResponse:
      type: object
      properties:
        type:
          type: string
          description: Response type identifier
          example: swap_calculation
        status:
          type: string
          description: Status of the calculation
          enum:
            - success
            - error
          example: success
        output:
          type: string
          description: Expected output amount
          example: '950000000000000000'
        message:
          type: string
          description: Status or error message
        path:
          type: object
          description: Swap route information (tx_builder.SwapRoute)
        buildResponse:
          type: object
          description: Transaction build response (tx_builder.BuildResponse)
        gasPrices:
          type: object
          description: Gas price information (swapcalc.GasPriceInfo)
    ErrorResponse:
      type: object
      required:
        - error
      properties:
        error:
          type: string
          description: Error code or type
          example: invalid_json
        message:
          type: string
          description: Human-readable error message
          example: Invalid JSON format in request body
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: JWT token obtained from /api/generate-token endpoint
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
      description: API key for authentication

````