Uniswap Approval API

The Approval API from Uniswap — 1 operation(s) for approval.

Documentation

Specifications

Schemas & Data

Other Resources

OpenAPI Specification

uniswap-approval-api-openapi.yml Raw ↑
openapi: 3.0.0
info:
  version: 1.0.0
  title: Token Trading Approval API
  description: 'Uniswap Labs trading APIs.


    Each operation may include the vendor extension `x-public-endpoint` (boolean): `true` when the operation is available on the public gateway for standard API keys, `false` when it is not publicly exposed. See the [OpenAPI specification extensions](https://swagger.io/docs/specification/v3_0/openapi-extensions/) definition of `x-` fields.'
servers:
- description: Uniswap Trading API
  url: https://trade-api.gateway.uniswap.org/v1
security:
- apiKey: []
tags:
- name: Approval
paths:
  /check_approval:
    post:
      tags:
      - Approval
      summary: Check if token approval is required
      description: 'Allows the requestor to check if the `walletAddress` has the required approval to transact the `token` up to the `amount` specified. If the `walletAddress` does not have the required approval, the response will include a transaction to approve the token spend. If the `walletAddress` has the required approval, the response will return the approval with a `null` value. If the parameter `includeGasInfo` is set to `true` and an approval is needed, then the response will include both the transaction and the gas fee for the approval transaction.


        Certain tokens may require that approval be reset before approving a new spend amount. If this condition is detected for the `walletAddress` and `token`, the response will include the necessary approval cancellation in the `cancel` paragraph. When `cancel` is not applicable, the paragraph will have a `null` value.'
      operationId: check_approval
      security:
      - apiKey: []
      parameters:
      - $ref: '#/components/parameters/permit2DisabledHeader'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ApprovalRequest'
            example:
              chainId: 1
              urgency: urgent
              includeGasInfo: true
              walletAddress: '0xC9bebBA9f481b12cE6f3EA54c4B182c9636ec421'
              token: '0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599'
              amount: '2516'
      responses:
        '200':
          $ref: '#/components/responses/ApprovalSuccess200'
        '400':
          $ref: '#/components/responses/BadRequest400'
        '401':
          $ref: '#/components/responses/ApprovalUnauthorized401'
        '404':
          $ref: '#/components/responses/ApprovalNotFound404'
        '429':
          $ref: '#/components/responses/RateLimitedErr429'
        '500':
          $ref: '#/components/responses/InternalErr500'
        '504':
          $ref: '#/components/responses/Timeout504'
      x-public-endpoint: true
components:
  responses:
    ApprovalNotFound404:
      description: ResourceNotFound eg. Token allowance not found or Gas info not found.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Err404'
    RateLimitedErr429:
      description: Ratelimited
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Err429'
    ApprovalUnauthorized401:
      description: UnauthorizedError eg. Account is blocked.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Err401'
    BadRequest400:
      description: RequestValidationError, Bad Input
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Err400'
    Timeout504:
      description: Request duration limit reached.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Err504'
    ApprovalSuccess200:
      description: Check approval successful.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApprovalResponse'
          example:
            requestId: e63f1e1e-b9e9-411a-bcc8-ff18ce4e77cf
            approval:
              to: '0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599'
              value: '0x00'
              from: '0xC9bebBA9f481b12cE6f3EA54c4B182c9636ec421'
              data: 0x095ea7b300...
              maxFeePerGas: '4656513686'
              maxPriorityFeePerGas: '2000000000'
              gasLimit: '56344'
              chainId: 1
            cancel: null
            gasFee: '262366607123984'
    InternalErr500:
      description: Unexpected error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Err500'
  schemas:
    tokenAmount:
      type: string
      description: The quantity of tokens denominated in the token's base units. (For example, for an ERC20 token one token is 1x10^18 base units. For one USDC token one token is 1x10^6 base units.) This value must be greater than 0.
      pattern: ^[0-9]+$
    ApprovalResponse:
      type: object
      properties:
        requestId:
          $ref: '#/components/schemas/RequestId'
        approval:
          $ref: '#/components/schemas/TransactionRequest'
        cancel:
          $ref: '#/components/schemas/TransactionRequest'
        gasFee:
          $ref: '#/components/schemas/gasFee'
        cancelGasFee:
          $ref: '#/components/schemas/gasFee'
      required:
      - requestId
      - approval
      - cancel
    ChainId:
      description: The unique ID of the blockchain. For a list of supported chains see the [FAQ](https://api-docs.uniswap.org/guides/faqs).
      type: number
      enum:
      - 1
      - 10
      - 56
      - 130
      - 137
      - 143
      - 196
      - 324
      - 480
      - 1868
      - 4217
      - 8453
      - 10143
      - 42161
      - 42220
      - 43114
      - 59144
      - 81457
      - 7777777
      - 1301
      - 84532
      - 11155111
      default: 1
    ApprovalRequest:
      type: object
      properties:
        walletAddress:
          $ref: '#/components/schemas/senderWalletAddress'
        token:
          $ref: '#/components/schemas/inputToken'
        amount:
          $ref: '#/components/schemas/tokenAmount'
        chainId:
          $ref: '#/components/schemas/ChainId'
        urgency:
          $ref: '#/components/schemas/Urgency'
        includeGasInfo:
          $ref: '#/components/schemas/includeGasInfo'
        tokenOut:
          $ref: '#/components/schemas/outputToken'
        tokenOutChainId:
          $ref: '#/components/schemas/ChainId'
      required:
      - walletAddress
      - token
      - amount
      - chainId
    Err500:
      type: object
      properties:
        errorCode:
          default: InternalServerError
          type: string
        detail:
          type: string
    senderWalletAddress:
      type: string
      description: The wallet address which will be used to send the token.
      pattern: ^(0x)?[0-9a-fA-F]{40}$
    inputToken:
      type: string
      description: The token which will be sent, specified by its token address. For a list of supported tokens, see the [FAQ](https://api-docs.uniswap.org/guides/faqs).
      pattern: ^(0x)?[0-9a-fA-F]{40}$
    RequestId:
      type: string
      description: A unique ID for the request.
    Err404:
      type: object
      properties:
        errorCode:
          enum:
          - ResourceNotFound
          - QuoteAmountTooLowError
          - TokenBalanceNotAvailable
          - InsufficientBalance
          type: string
        detail:
          type: string
    Err504:
      type: object
      properties:
        errorCode:
          default: Timeout
          type: string
        detail:
          type: string
    gasFee:
      type: string
      description: The total estimated gas cost of this transaction (eg. `gasLimit` multiplied by `maxFeePerGas`) in the base unit of the chain.
    TransactionRequest:
      type: object
      properties:
        to:
          $ref: '#/components/schemas/receiverWalletAddress'
        from:
          $ref: '#/components/schemas/senderWalletAddress'
        data:
          type: string
          description: The calldata for the transaction.
        value:
          type: string
          description: The quantity of ETH tokens approved for spending by the transaction, denominated in wei. Note that by default Uniswap Labs sets this to the maximum approvable spend.
        gasLimit:
          $ref: '#/components/schemas/gasLimit'
        chainId:
          $ref: '#/components/schemas/ChainId'
        maxFeePerGas:
          $ref: '#/components/schemas/maxFeePerGas'
        maxPriorityFeePerGas:
          $ref: '#/components/schemas/maxPriorityFeePerGas'
        gasPrice:
          $ref: '#/components/schemas/gasPrice'
      required:
      - to
      - from
      - data
      - value
      - chainId
    maxFeePerGas:
      type: string
      description: The sum of the base fee and priority fee. Subtracting `maxPriorityFeePerGas` from this value will yield the base fee to be paid for this transaction.
    Err400:
      type: object
      properties:
        errorCode:
          default: RequestValidationError
          type: string
        detail:
          type: string
    gasLimit:
      type: string
      description: The maximum units of gas that will be consumed by this transaction.
    receiverWalletAddress:
      type: string
      description: The wallet address which will receive the token.
      pattern: ^(0x)?[0-9a-fA-F]{40}$
    Err401:
      type: object
      properties:
        errorCode:
          default: UnauthorizedError
          type: string
        detail:
          type: string
    gasPrice:
      type: string
      description: The cost per unit of gas.
    includeGasInfo:
      type: boolean
      description: If set to `true`, the response will include the estimated gas fee for the proposed transaction.
      default: false
    Err429:
      type: object
      properties:
        errorCode:
          default: Ratelimited
          type: string
        detail:
          type: string
    Urgency:
      type: string
      enum:
      - normal
      - fast
      - urgent
      description: The urgency impacts the estimated gas price of the transaction. The higher the urgency, the higher the gas price, and the faster the transaction is likely to be selected from the mempool. The default value is `urgent`.
      default: urgent
    outputToken:
      type: string
      description: The token which will be received, specified by its token address. For a list of supported tokens, see the [FAQ](https://api-docs.uniswap.org/guides/faqs).
      pattern: ^(0x)?[0-9a-fA-F]{40}$
    maxPriorityFeePerGas:
      type: string
      description: The maximum tip to the block builder. Adjusted based upon the urgency specified in the request.
  parameters:
    permit2DisabledHeader:
      name: x-permit2-disabled
      in: header
      description: Disables the Permit2 approval flow. When set to `true`, `permitData` is returned as `null` and the header is forwarded to the routing layer for correct gas simulation against the Proxy Universal Router contract. When `false` or omitted, the standard Permit2 approval flow is used. This header is intended for integrators whose infrastructure uses a direct approval-then-swap pattern without Permit2.
      required: false
      schema:
        type: boolean
        default: false
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: x-api-key