0x

0x Gasless API

Gasless API endpoints

Documentation

Specifications

Code Examples

Other Resources

OpenAPI Specification

0x-gasless-api-openapi.yml Raw ↑
openapi: 3.0.3
info:
  title: 0x Cross-Chain Gasless API
  description: This is the official API reference for the latest 0x API (v2).
  version: v2
  x-source-url: https://github.com/0xProject/0x-docs/blob/main/fern/openapi.json
  x-last-validated: '2026-05-28'
servers:
- url: https://api.0x.org
tags:
- name: Gasless
  description: Gasless API endpoints
paths:
  /gasless/price:
    get:
      operationId: gasless::getPrice
      summary: Get Gasless Price
      description: Get the indicative price for a gasless swap
      tags:
      - Gasless
      parameters:
      - description: Visit dashboard.0x.org to get your API Key
        in: header
        name: 0x-api-key
        required: true
        schema:
          type: string
      - description: API version
        in: header
        name: 0x-version
        required: true
        schema:
          type: string
          example: v2
      - name: chainId
        in: query
        required: true
        schema:
          type: integer
          exclusiveMinimum: true
          minimum: 0
        description: Chain ID. See [here](https://docs.0x.org/docs/introduction/supported-chains) for the list of supported chains
        example: 1
      - name: buyToken
        in: query
        required: true
        schema:
          type: string
          pattern: ^0x(?!0{40})[a-fA-F0-9]{40}$
        description: The contract address of the token to buy
        example: '0xdac17f958d2ee523a2206206994597c13d831ec7'
      - name: sellToken
        in: query
        required: true
        schema:
          type: string
          pattern: ^0x(?!0{40})[a-fA-F0-9]{40}$
        description: The contract address of the token to sell. Native token is not supported
        example: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48'
      - name: sellAmount
        in: query
        required: true
        schema:
          type: string
        description: The amount of `sellToken` in `sellToken` base units to sell
        example: '300000000'
      - name: taker
        in: query
        required: false
        schema:
          type: string
          pattern: ^0x[a-fA-F0-9]{40}$
        description: The address which holds the `sellToken` balance and has the allowance set for the swap
        example: '0x70a9f34f9b34c64957b9c401a97bfed35b95049e'
      - name: recipient
        in: query
        required: false
        schema:
          type: string
          pattern: ^0x[a-fA-F0-9]{40}$
        description: The address to receive the `buyToken`. If not provided, defaults to the taker address. Not supported for wrap/unwrap operations.
      - name: swapFeeRecipient
        in: query
        required: false
        schema:
          type: string
          pattern: ^\s*0x[a-fA-F0-9]{40}(\s*,\s*0x[a-fA-F0-9]{40})*\s*$
        description: The wallet address to receive the specified trading fees (supports single or multiple comma-separated values). You must also specify the `swapFeeBps` in the request to use this feature. When multiple values are provided, must match length of `swapFeeBps`.
      - name: swapFeeBps
        in: query
        required: false
        schema:
          type: string
          pattern: ^\s*\d+(\s*,\s*\d+)*\s*$
        description: The amount in Bps of the `swapFeeToken` to charge and deliver to the `swapFeeRecipient` (supports single or multiple comma-separated values). You must also specify the `swapFeeRecipient` in the request to use this feature. For security, this field has a default limit of 1000 Bps. If your application requires a higher value, please reach out to us.
      - name: swapFeeToken
        in: query
        required: false
        schema:
          type: string
          pattern: ^\s*0x(?!0{40})[a-fA-F0-9]{40}(\s*,\s*0x(?!0{40})[a-fA-F0-9]{40})*\s*$
        description: The contract address of the token to receive trading fees in (supports single or multiple comma-separated values). Each token must be set to the value of either the `buyToken` or the `sellToken`. If omitted, the fee token will be determined by 0x with preference to stablecoins and highly liquid assets. You must also specify the `swapFeeRecipient` and `swapFeeBps` to charge integrator fees. When multiple values are provided, must match length of `swapFeeBps`.
      - name: tradeSurplusRecipient
        in: query
        required: false
        schema:
          type: string
          pattern: ^0x[a-fA-F0-9]{40}$
        description: The address to receive any trade surplus. If specified, this address will receive trade surplus when applicable. Otherwise, the taker will receive the surplus. This feature is only available to selected integrators on a custom pricing plan. In other cases, the surplus will be collected by 0x. For assistance with a custom plan, please contact support.
      - name: tradeSurplusMaxBps
        in: query
        required: false
        schema:
          type: integer
          minimum: 1
          maximum: 10000
        description: The maximum trade surplus (positive slippage) that can be collected in Bps of the buy amount. If not provided, defaults to 10000 (100%). Must be used together with `tradeSurplusRecipient`.
      - name: slippageBps
        in: query
        required: false
        schema:
          type: integer
          minimum: 30
          maximum: 10000
        description: The maximum acceptable slippage of the `buyToken` in Bps. 0x sets the optimal slippage tolerance per trade by default. To mitigate the risk of MEV attacks, we recommend adjusting this value only when trading low-liquidity tokens.
      - name: slippagePpm
        in: query
        required: false
        schema:
          type: integer
          minimum: 0
          maximum: 1000000
        description: The maximum acceptable slippage of the `buyToken` in parts-per-million (PPM). Mutually exclusive with `slippageBps`. e.g. 3000 PPM = 30 BPS = 0.30%.
      - name: excludedSources
        in: query
        required: false
        schema:
          type: string
        description: Liquidity sources e.g. Uniswap_V3, SushiSwap, 0x_RFQ to exclude from the provided quote. `See https://api.0x.org/sources?chainId=<chain_id>` with the desired chain's ID for a full list of sources. Separate multiple sources with a comma
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                anyOf:
                - type: object
                  properties:
                    allowanceTarget:
                      type: string
                      pattern: ^0x[a-fA-F0-9]{40}$
                      nullable: true
                      description: The target contract address for which the `taker` needs to have an allowance in order to be able to complete the swap. For swaps with the native asset (ie "ETH" or "BNB") as the `sellToken`, wrapping the native asset (i.e. "ETH" to "WETH") or unwrapping, no allowance is needed
                    blockNumber:
                      allOf:
                      - {}
                      - type: string
                        pattern: ^[-+]?(0|[1-9]\d*)(\.\d+)?$
                      description: The block number at which the liquidity sources were sampled to generate the quote. This indicates the freshness of the quote
                    buyAmount:
                      allOf:
                      - {}
                      - type: string
                        pattern: ^[-+]?(0|[1-9]\d*)(\.\d+)?$
                      description: The amount of `buyToken` (in `buyToken` units) that will be bought in the swap
                    buyToken:
                      type: string
                      pattern: ^0x[a-fA-F0-9]{40}$
                      description: The contract address of the token to buy in the swap
                    fees:
                      type: object
                      properties:
                        integratorFee:
                          type: object
                          properties:
                            amount:
                              allOf:
                              - {}
                              - type: string
                                pattern: ^[-+]?(0|[1-9]\d*)(\.\d+)?$
                              description: The amount of token charged as the integrator fee
                            token:
                              type: string
                              pattern: ^0x[a-fA-F0-9]{40}$
                              description: The address of the token charged as the integrator fee
                            type:
                              type: string
                              enum:
                              - volume
                          required:
                          - amount
                          - token
                          - type
                          additionalProperties: false
                          nullable: true
                          description: The specified fee to charge and deliver to the `swapFeeRecipient`.
                        integratorFees:
                          type: array
                          items:
                            type: object
                            properties:
                              amount:
                                allOf:
                                - {}
                                - type: string
                                  pattern: ^[-+]?(0|[1-9]\d*)(\.\d+)?$
                                description: The amount of token charged as the integrator fee
                              token:
                                type: string
                                pattern: ^0x[a-fA-F0-9]{40}$
                                description: The address of the token charged as the integrator fee
                              type:
                                type: string
                                enum:
                                - volume
                            required:
                            - amount
                            - token
                            - type
                            additionalProperties: false
                          nullable: true
                          description: The specified fees to charge and deliver to the `swapFeesRecipient`.
                        zeroExFee:
                          type: object
                          properties:
                            amount:
                              allOf:
                              - {}
                              - type: string
                                pattern: ^[-+]?(0|[1-9]\d*)(\.\d+)?$
                              description: The amount of token charged as the 0x fee
                            token:
                              type: string
                              pattern: ^0x[a-fA-F0-9]{40}$
                              description: The address of the token charged as the 0x fee
                            type:
                              type: string
                              enum:
                              - volume
                          required:
                          - amount
                          - token
                          - type
                          additionalProperties: false
                          nullable: true
                          description: The fee charged by 0x for the trade.
                        gasFee:
                          type: object
                          properties:
                            amount:
                              allOf:
                              - {}
                              - type: string
                                pattern: ^[-+]?(0|[1-9]\d*)(\.\d+)?$
                              description: The amount of token charged as the gas fee
                            token:
                              type: string
                              pattern: ^0x[a-fA-F0-9]{40}$
                              description: The address of the token charged as the gas fee
                            type:
                              type: string
                              enum:
                              - gas
                          required:
                          - amount
                          - token
                          - type
                          additionalProperties: false
                          nullable: true
                          description: The gas fee to be used in submitting the transaction.
                      required:
                      - integratorFee
                      - integratorFees
                      - zeroExFee
                      - gasFee
                      additionalProperties: false
                      description: Fees to be deducted in this transaction. It contains the `integratorFee`, `zeroExFee` and `gasFee`
                    issues:
                      type: object
                      properties:
                        allowance:
                          type: object
                          properties:
                            actual:
                              allOf:
                              - {}
                              - type: string
                                pattern: ^[-+]?(0|[1-9]\d*)(\.\d+)?$
                              description: The `taker`'s current allowance of the `spender`
                            spender:
                              type: string
                              pattern: ^0x[a-fA-F0-9]{40}$
                              description: The address to set the allowance on
                          required:
                          - actual
                          - spender
                          additionalProperties: false
                          description: Details of allowances that the `taker` must set for in order to execute the swap successfully. Null if no allowance is required
                          nullable: true
                        balance:
                          type: object
                          properties:
                            token:
                              type: string
                              pattern: ^0x[a-fA-F0-9]{40}$
                              description: The contract address of the `sellToken`
                            actual:
                              allOf:
                              - {}
                              - type: string
                                pattern: ^[-+]?(0|[1-9]\d*)(\.\d+)?$
                              description: The current balance of the `sellToken` in the `taker` address
                            expected:
                              allOf:
                              - {}
                              - type: string
                                pattern: ^[-+]?(0|[1-9]\d*)(\.\d+)?$
                              description: The balance of the `sellToken` required for the swap to execute successfully
                          required:
                          - token
                          - actual
                          - expected
                          additionalProperties: false
                          description: Details of balance of the `sellToken` that the `taker` must hold. Null if the `taker` has sufficient balance
                          nullable: true
                        simulationIncomplete:
                          type: boolean
                          description: This is set to `true` when 0x cannot validate the transaction. This happens when the `taker` has an insufficient balance of the `sellToken` and 0x is unable to peform ehanced quote validation with the low balance. Note that this does not necessarily mean that the trade will revert
                        invalidSourcesPassed:
                          type: array
                          items:
                            type: string
                          description: A list of invalid sources present in `excludedSources` request. See `https://api.0x.org/sources?chainId=` with the desired chain's ID for the list of valid sources
                      required:
                      - allowance
                      - balance
                      - simulationIncomplete
                      - invalidSourcesPassed
                      additionalProperties: false
                      description: An object containing potential issues discovered during 0x validation that can prevent the swap from being executed successfully by the `taker`
                    liquidityAvailable:
                      type: boolean
                      enum:
                      - true
                      description: This validates the availability of liquidity for the quote requested. The rest of the fields will only be returned if `true`
                    minBuyAmount:
                      allOf:
                      - {}
                      - type: string
                        pattern: ^[-+]?(0|[1-9]\d*)(\.\d+)?$
                      description: The price which must be met or else the entire transaction will revert. This price is influenced by the `slippageBps` parameter. On-chain sources may encounter price movements from quote to settlement
                    route:
                      type: object
                      properties:
                        fills:
                          type: array
                          items:
                            type: object
                            properties:
                              from:
                                type: string
                                pattern: ^0x[a-fA-F0-9]{40}$
                                description: The contract address of the input token
                              to:
                                type: string
                                pattern: ^0x[a-fA-F0-9]{40}$
                                description: The contract address of the output token
                              source:
                                type: string
                                description: The liquidity source used in the route
                              proportionBps:
                                allOf:
                                - {}
                                - type: string
                                  pattern: ^[-+]?(0|[1-9]\d*)(\.\d+)?$
                                description: The proportion of the trade to be filled by the `source`
                            required:
                            - from
                            - to
                            - source
                            - proportionBps
                            additionalProperties: false
                          description: Details of each segment that 0x routes the swap through
                        tokens:
                          type: array
                          items:
                            type: object
                            properties:
                              address:
                                type: string
                                pattern: ^0x[a-fA-F0-9]{40}$
                                description: The token address. This is the unique identifier of the token
                              symbol:
                                type: string
                                description: The token symbol. This is not guaranteed to be unique, as multiple tokens can have the same symbol
                            required:
                            - address
                            - symbol
                            additionalProperties: false
                            description: Properties of the tokens involved in the swap
                          description: Properties of the tokens involved in the swap
                      required:
                      - fills
                      - tokens
                      additionalProperties: false
                      description: The path of liquidity sources to be used in executing this swap
                    sellAmount:
                      allOf:
                      - {}
                      - type: string
                        pattern: ^[-+]?(0|[1-9]\d*)(\.\d+)?$
                      description: The amount of `sellToken` (in `sellToken` units) that will be sold in this swap
                    sellToken:
                      type: string
                      pattern: ^0x[a-fA-F0-9]{40}$
                      description: The contract address of the token to sell in the swap
                    target:
                      type: string
                      pattern: ^0x[a-fA-F0-9]{40}$
                      description: The address of the target contract that the transaction will be submitted to
                    tokenMetadata:
                      type: object
                      properties:
                        buyToken:
                          type: object
                          properties:
                            buyTaxBps:
                              allOf:
                              - {}
                              - type: string
                                pattern: ^[-+]?(0|[1-9]\d*)(\.\d+)?$
                              nullable: true
                              description: The buy tax in bps of the token. Since each token could have arbitrary implementation, this field is best effort, meaning it would be set to `null` if the system is not able to determine the tax
                            sellTaxBps:
                              allOf:
                              - {}
                              - type: string
                                pattern: ^[-+]?(0|[1-9]\d*)(\.\d+)?$
                              nullable: true
                              description: The sell tax in bps of the token. Since each token could have arbitrary implementation, this field is best effort, meaning it would be set to `null` if the system is not able to determine the tax
                            transferTaxBps:
                              allOf:
                              - {}
                              - type: string
                                pattern: ^[-+]?(0|[1-9]\d*)(\.\d+)?$
                              nullable: true
                              description: The transfer tax in bps of the token. Since each token could have arbitrary implementation, this field is best effort, meaning it would be set to `null` if the system is not able to determine the tax
                          required:
                          - buyTaxBps
                          - sellTaxBps
                          - transferTaxBps
                          additionalProperties: false
                          description: Swap-related metadata for the buy token
                        sellToken:
                          type: object
                          properties:
                            buyTaxBps:
                              allOf:
                              - {}
                              - type: string
                                pattern: ^[-+]?(0|[1-9]\d*)(\.\d+)?$
                              nullable: true
                              description: The buy tax in bps of the token. Since each token could have arbitrary implementation, this field is best effort, meaning it would be set to `null` if the system is not able to determine the tax
                            sellTaxBps:
                              allOf:
                              - {}
                              - type: string
                                pattern: ^[-+]?(0|[1-9]\d*)(\.\d+)?$
                              nullable: true
                              description: The sell tax in bps of the token. Since each token could have arbitrary implementation, this field is best effort, meaning it would be set to `null` if the system is not able to determine the tax
                            transferTaxBps:
                              allOf:
                              - {}
                              - type: string
                                pattern: ^[-+]?(0|[1-9]\d*)(\.\d+)?$
                              nullable: true
                              description: The transfer tax in bps of the token. Since each token could have arbitrary implementation, this field is best effort, meaning it would be set to `null` if the system is not able to determine the tax
                          required:
                          - buyTaxBps
                          - sellTaxBps
                          - transferTaxBps
                          additionalProperties: false
                          description: Swap-related metadata for the sell token
                      required:
                      - buyToken
                      - sellToken
                      additionalProperties: false
                      description: Swap-related metadata for the buy and sell token in the swap
                    zid:
                      type: string
                      description: The unique ZeroEx identifier of the request
                  required:
                  - allowanceTarget
                  - blockNumber
                  - buyAmount
                  - buyToken
                  - fees
                  - issues
                  - liquidityAvailable
                  - minBuyAmount
                  - route
                  - sellAmount
                  - sellToken
                  - target
                  - tokenMetadata
                  - zid
                  additionalProperties: false
                - type: object
                  properties:
                    liquidityAvailable:
                      type: boolean
                      enum:
                      - false
                      description: This validates the availability of liquidity for the quote requested. No other fields will be returned if it is `false`
                    zid:
                      type: string
                      description: The unique ZeroEx identifier of the request
                  required:
                  - liquidityAvailable
                  - zid
                  additionalProperties: false
              example:
                allowanceTarget: '0x000000000022d473030f116ddee9f6b43ac78ba3'
                blockNumber: '20114764'
                buyAmount: '291527064'
                buyToken: '0xdac17f958d2ee523a2206206994597c13d831ec7'
                fees:
                  integratorFee: null
                  zeroExFee:
                    amount: '150053'
                    token: '0xdac17f958d2ee523a2206206994597c13d831ec7'
                    type: volume
                  gasFee:
                    amount: '8430138'
                    token: '0xdac17f958d2ee523a2206206994597c13d831ec7'
                    type: gas
                issues:
                  allowance:
                    actual: '0'
                    spender: '0x000000000022d473030f116ddee9f6b43ac78ba3'
                  balance:
                    token: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48'
                    actual: '0'
                    expected: '300000000'
                  simulationIncomplete: false
                  invalidSourcesPassed: []
                liquidityAvailable: true
                minBuyAmount: '290652483'
                route:
                  fills:
                  - from: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48'
                    to: '0xdac17f958d2ee523a2206206994597c13d831ec7'
                    source: SolidlyV3
                    proportionBps: '10000'
                  tokens:
                  - address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48'
                    symbol: USDC
                  - address: '0xdac17f958d2ee523a2206206994597c13d831ec7'
                    symbol: USDT
                sellAmount: '300000000'
                sellToken: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48'
                target: '0x7c39a136ea20b3483e402ea031c1f3c019bab24b'
                tokenMetadata:
                  buyToken:
                    buyTaxBps: '0'
                    sellTaxBps: '0'
                  sellToken:
                    buyTaxBps: '0'
                    sellTaxBps: '0'
                zid: '0x111111111111111111111111'
        '400':
          description: 400 error response
          content:
            application/json:
              schema:
                anyOf:
                - $ref: '#/components/schemas/INPUT_INVALID'
                - $ref: '#/components/schemas/RECIPIENT_NOT_SUPPORTED'
                - $ref: '#/components/schemas/SMART_WALLET_NOT_SUPPORTED'
                - $ref: '#/components/schemas/UNABLE_TO_CALCULATE_GAS_FEE'
                - $ref: '#/components/schemas/SELL_AMOUNT_TOO_SMALL'
                - $ref: '#/components/schemas/SWAP_VALIDATION_FAILED'
                - $ref: '#/components/schemas/TOKEN_NOT_SUPPORTED'
                - $ref: '#/components/schemas/USER_NOT_AUTHORIZED'
                - $ref: '#/components/schemas/TOKEN_PAIR_NOT_SUPPORTED'
        '403':
          description: 403 error response
          content:
            application/json:
              schema:
                anyOf:
                - $ref: '#/components/schemas/TAKER_NOT_AUTHORIZED_FOR_TRADE'
                - $ref: '#/components/schemas/RECIPIENT_NOT_AUTHORIZED_FOR_TRADE'
                - $ref: '#/components/schemas/XSTOCKS_NOT_AUTHORIZED'
        '422':
          description: 422 error response
          content:
            application/json:
              schema:
                anyOf:
                - $ref: '#/components/schemas/BUY_TOKEN_NOT_AUTHORIZED_FOR_TRADE'
                - $ref: '#/components/schemas/SELL_TOKEN_NOT_AUTHORIZED_FOR_TRADE'
        '500':
          description: 500 error response
          content:
            application/json:
              schema:
                anyOf:
                - $ref: '#/components/schemas/INTERNAL_SERVER_ERROR'
                - $ref: '#/components/schemas/UNCATEGORIZED'
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
  /gasless/quote:
    get:
      operationId: gasless::getQuote
      summary: Get Gasless Quote
      description: Get the firm quote for a gasless swap
      tags:
      - Gasless
      parameters:
      - description: Visit dashboard.0x.org to get your API Key
        in: header
        name: 0x-api-key
        required: true
        schema:
          type: string
      - description: API version
        in: header
        name: 0x-version
        required: true
        schema:
          type: string
          example: v2
      - name: chainId
        in: query
        required: true
        schema:
          type: integer
          exclusiveMinimum: true
          minimum: 0
        description: Chain ID. See [here](https://docs.0x.org/docs/introduction/supported-chains) for the list of supported chains
        example: 1
      - name: buyToken
        in: query
        required: true
        schema:
          type: string
          pattern: ^0x(?!0{40})[a-fA-F0-9]{40}$
        description: The contract address of the token to buy
        example: '0xdac17f958d2ee523a2206206994597c13d831ec7'
      - name: sellToken
        in: query
        required: true
        schema:
          type: string
          pattern: ^0x(?!0{40})[a-fA-F0-9]{40}$
        description: The contract address of the token to sell. Native token is not supported
        example: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48'
      - name: sellAmount
        in: query
        required: true
        schema:
          type: string
        description: The amount of `sellToken` in `sellToken` base units to sell
        example: '300000000'
      - name: taker
        in: query
        required: true
        schema:
          type: string
          pattern: ^0x[a-fA-F0-9]{40}$
        description: The address which holds the `sellToken` balance and has the allowance set for the swap
        example: '0x70a9f34f9b34c64957b9c401a97bfed35b95049e'
      - name: recipient
        in: query
        required: false
        schema:
          type: string
          pattern: ^0x[a-fA-F0-9]{40}$
        description: The address to receive the `buyToken`. If not provided, defaults to the taker address. Not supported for wrap/unwrap operations.
      - name: swapFeeRecipient
        in: query
        required: false
        schema:
          type: string
          pattern: ^\s*0x[a-fA-F0-9]{40}(\s*,\s*0x[a-fA-F0-9]{40})*\s*$
        descrip

# --- truncated at 32 KB (133 KB total) ---
# Full source: https://raw.githubusercontent.com/api-evangelist/0x/refs/heads/main/openapi/0x-gasless-api-openapi.yml