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

# Get Quote - to Specified Amount

> This endpoint calculates the amount of input tokens required to purchase a
specified amount of output tokens from a Uniswap pool.

It also provides the resulting price after the transaction. The calculation takes
into account the current pool state and the specified fee tier.



## OpenAPI

````yaml /v1/combined_spec.json get /v1/uniswap/quote/buy_exactly
openapi: 3.1.0
info:
  title: Compass API
  description: Compass Labs DeFi API
  version: 0.0.1
servers:
  - url: https://api.compasslabs.ai
    description: Production server
security:
  - ApiKeyAuth: []
paths:
  /v1/uniswap/quote/buy_exactly:
    get:
      tags:
        - Uniswap V3
      summary: Get Quote - to Specified Amount
      description: >-
        This endpoint calculates the amount of input tokens required to purchase
        a

        specified amount of output tokens from a Uniswap pool.


        It also provides the resulting price after the transaction. The
        calculation takes

        into account the current pool state and the specified fee tier.
      operationId: v1_uniswap_quote_buy_exactly
      parameters:
        - name: chain
          in: query
          required: true
          schema:
            type: string
            enum:
              - arbitrum
              - base
              - ethereum
            title: Chain
            default: arbitrum
        - name: token_in
          in: query
          required: true
          schema:
            type: string
            title: Token In
            description: >-
              A token identifier - either a supported symbol (e.g., USDC, WETH)
              or a valid Ethereum address (0x...)
            examples:
              - USDC
              - WETH
              - '0xA0b86a33E6441ccF30EE5DdEF1E9b652C91ac1c8'
            default: USDC
          description: The symbol or address of the token to swap from.
        - name: token_out
          in: query
          required: true
          schema:
            type: string
            title: Token Out
            description: >-
              A token identifier - either a supported symbol (e.g., USDC, WETH)
              or a valid Ethereum address (0x...)
            examples:
              - USDC
              - WETH
              - '0xA0b86a33E6441ccF30EE5DdEF1E9b652C91ac1c8'
            default: USDT
          description: The symbol or address of the token to swap to.
        - name: fee
          in: query
          required: true
          schema:
            type: string
            enum:
              - '0.01'
              - '0.05'
              - '0.3'
              - '1.0'
            title: FeeEnum
            description: |-
              The transaction fee of a Uniswap pool in bips.

              Uniswap supports 4 different fee levels.
            default: '0.01'
          description: The fee to pay for the swap
        - name: amount_out
          in: query
          required: true
          schema:
            anyOf:
              - type: number
                exclusiveMinimum: 0
              - type: string
                pattern: ^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$
            title: Amount Out
            default: 1
          description: The amount of the token to swap to
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UniswapBuyQuoteInfoResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      x-codeSamples:
        - lang: python
          label: Python (SDK)
          source: |-
            from compass_api_sdk import CompassAPI, models


            with CompassAPI(
                api_key_auth="<YOUR_API_KEY_HERE>",
            ) as compass_api:

                res = compass_api.uniswap_v3.uniswap_quote_buy_exactly(chain=models.V1UniswapQuoteBuyExactlyChain.ARBITRUM, token_in="USDC", token_out="USDC", fee=models.V1UniswapQuoteBuyExactlyFeeEnum.ZERO_DOT_01, amount_out=1)

                # Handle response
                print(res)
        - lang: typescript
          label: Typescript (SDK)
          source: |-
            import { CompassApiSDK } from "@compass-labs/api-sdk";

            const compassApiSDK = new CompassApiSDK({
              apiKeyAuth: "<YOUR_API_KEY_HERE>",
            });

            async function run() {
              const result = await compassApiSDK.uniswapV3.uniswapQuoteBuyExactly({
                chain: "arbitrum",
                tokenIn: "USDC",
                tokenOut: "USDC",
                fee: "0.01",
                amountOut: 1,
              });

              console.log(result);
            }

            run();
components:
  schemas:
    UniswapBuyQuoteInfoResponse:
      properties:
        amount_in:
          type: string
          pattern: ^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$
          title: Amount In
          description: The amount of token_in you would need to give to the pool.
        price_after:
          type: string
          pattern: ^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$
          title: Price After
          description: >-
            The price of the pool after this trade would happen. (How much
            token0 you need to buy 1 token1.)
      type: object
      required:
        - amount_in
        - price_after
      title: UniswapBuyQuoteInfoResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: >-
        Your Compass API Key. Get your key
        [here](https://www.compasslabs.ai/dashboard).

````