{
  "openapi": "3.0.0",
  "servers": [
    {
      "description": "UniswapX APIs",
      "url": "https://api.uniswap.org/v2"
    }
  ],
  "info": {
    "version": "1.0.0",
    "title": "UniswapX",
    "description": "Rest API for orders."
  },
  "paths": {
    "/orders": {
      "get": {
        "tags": [
          "Dutch Order"
        ],
        "summary": "Retrieve orders",
        "description": "Retrieve orders filtered by query param(s). Some fields on the order can be used as query param.",
        "parameters": [
          {
            "$ref": "#/components/parameters/limitParam"
          },
          {
            "$ref": "#/components/parameters/orderStatusParam"
          },
          {
            "$ref": "#/components/parameters/orderHashParam"
          },
          {
            "$ref": "#/components/parameters/orderHashesParam"
          },
          {
            "$ref": "#/components/parameters/swapperParam"
          },
          {
            "$ref": "#/components/parameters/sortKeyParam"
          },
          {
            "$ref": "#/components/parameters/sortParam"
          },
          {
            "$ref": "#/components/parameters/descParam"
          },
          {
            "$ref": "#/components/parameters/fillerParam"
          },
          {
            "$ref": "#/components/parameters/cursorParam"
          },
          {
            "$ref": "#/components/parameters/chainId"
          }
        ],
        "responses": {
          "200": {
            "description": "Request Successful",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GetOrdersResponse"
                }
              }
            }
          }
        }
      }
    },
    "/limit-orders": {
      "get": {
        "tags": [
          "Limit Order"
        ],
        "summary": "Retrieve orders",
        "description": "Retrieve orders filtered by query param(s). Some fields on the order can be used as query param.",
        "parameters": [
          {
            "$ref": "#/components/parameters/limitParam"
          },
          {
            "$ref": "#/components/parameters/orderStatusParam"
          },
          {
            "$ref": "#/components/parameters/orderHashParam"
          },
          {
            "$ref": "#/components/parameters/orderHashesParam"
          },
          {
            "$ref": "#/components/parameters/swapperParam"
          },
          {
            "$ref": "#/components/parameters/sortKeyParam"
          },
          {
            "$ref": "#/components/parameters/sortParam"
          },
          {
            "$ref": "#/components/parameters/descParam"
          },
          {
            "$ref": "#/components/parameters/fillerParam"
          },
          {
            "$ref": "#/components/parameters/cursorParam"
          },
          {
            "$ref": "#/components/parameters/chainId"
          }
        ],
        "responses": {
          "200": {
            "description": "Request Successful",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GetOrdersResponse"
                }
              }
            }
          }
        }
      }
    },
    "/nonce": {
      "get": {
        "tags": [
          "Dutch Order"
        ],
        "summary": "Get nonce",
        "description": "Get current nonce for dutch auction orders. Given an address this endpoint will return the next valid nonce to be used in order creation.",
        "parameters": [
          {
            "$ref": "#/components/parameters/addressParam"
          },
          {
            "$ref": "#/components/parameters/chainId"
          }
        ],
        "responses": {
          "200": {
            "description": "Request Successful",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Nonce"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "responses": {
      "400InvalidOrder": {
        "description": "Invalid Order."
      }
    },
    "parameters": {
      "addressParam": {
        "name": "address",
        "in": "query",
        "schema": {
          "type": "string",
          "pattern": "^(0x)?[0-9a-fA-F]{40}$",
          "example": "0x50EC05ADe8280758E2077fcBC08D878D4aef79C3"
        },
        "required": false
      },
      "chainId": {
        "name": "chainId",
        "in": "query",
        "schema": {
          "type": "number",
          "enum": [
            1,
            137
          ],
          "example": 1
        },
        "required": false
      },
      "limitParam": {
        "name": "limit",
        "in": "query",
        "schema": {
          "type": "number",
          "default": 1
        },
        "required": false
      },
      "orderStatusParam": {
        "name": "orderStatus",
        "in": "query",
        "description": "Filter by order status.",
        "required": false,
        "schema": {
          "$ref": "#/components/schemas/OrderStatus"
        }
      },
      "orderHashParam": {
        "name": "orderHash",
        "in": "query",
        "description": "Filter by order hash.",
        "required": false,
        "schema": {
          "$ref": "#/components/schemas/OrderHash"
        }
      },
      "orderHashesParam": {
        "name": "orderHashes",
        "in": "query",
        "description": "Filter by comma separated order hashes.",
        "required": false,
        "schema": {
          "type": "string",
          "pattern": "^(?=([^,]*,){0,49}[^,]*$)0x[0-9a-zA-Z]{64}(,0x[0-9a-zA-Z]{64})*$",
          "example": "orderHash,orderHash,orderHash"
        }
      },
      "swapperParam": {
        "name": "swapper",
        "in": "query",
        "description": "Filter by swapper address.",
        "required": false,
        "schema": {
          "type": "string",
          "pattern": "^(0x)?[0-9a-fA-F]{40}$",
          "example": "0x50EC05ADe8280758E2077fcBC08D878D4aef79C3"
        }
      },
      "fillerParam": {
        "name": "filler",
        "in": "query",
        "description": "Filter by filler address.",
        "required": false,
        "schema": {
          "type": "string",
          "pattern": "^(0x)?[0-9a-fA-F]{40}$",
          "example": "0x50EC05ADe8280758E2077fcBC08D878D4aef79C3"
        }
      },
      "sortKeyParam": {
        "name": "sortKey",
        "in": "query",
        "description": "Order the query results by the sort key.",
        "required": false,
        "schema": {
          "$ref": "#/components/schemas/SortKey"
        }
      },
      "sortParam": {
        "name": "sort",
        "in": "query",
        "description": "Sort query. For example: `sort=gt(UNIX_TIMESTAMP)`, `sort=between(1675872827, 1675872930)`, or `lt(1675872930)`.",
        "required": false,
        "schema": {
          "type": "string"
        }
      },
      "descParam": {
        "name": "desc",
        "in": "query",
        "description": "Boolean to sort query results by descending sort key.",
        "required": false,
        "schema": {
          "type": "boolean"
        }
      },
      "cursorParam": {
        "name": "cursor",
        "in": "query",
        "description": "Cursor param to page through results. This will be returned in the previous query if the results have been paginated.",
        "required": false,
        "schema": {
          "type": "string"
        }
      }
    },
    "schemas": {
      "Nonce": {
        "type": "object",
        "properties": {
          "nonce": {
            "type": "string"
          }
        }
      },
      "OrderInput": {
        "type": "object",
        "properties": {
          "token": {
            "type": "string"
          },
          "startAmount": {
            "type": "string"
          },
          "endAmount": {
            "type": "string"
          }
        },
        "required": [
          "token"
        ]
      },
      "OrderOutput": {
        "type": "object",
        "properties": {
          "token": {
            "type": "string"
          },
          "startAmount": {
            "type": "string"
          },
          "endAmount": {
            "type": "string"
          },
          "recipient": {
            "type": "string"
          }
        },
        "required": [
          "startAmount",
          "endAmount",
          "recipient"
        ]
      },
      "SettledAmount": {
        "type": "object",
        "properties": {
          "tokenOut": {
            "type": "string",
            "pattern": "^(0x)?[0-9a-fA-F]{40}$"
          },
          "amountOut": {
            "type": "string"
          },
          "tokenIn": {
            "type": "string",
            "pattern": "^(0x)?[0-9a-fA-F]{40}$"
          },
          "amountIn": {
            "type": "string"
          }
        }
      },
      "OrderType": {
        "type": "string",
        "enum": [
          "Dutch"
        ]
      },
      "OrderEntity": {
        "type": "object",
        "properties": {
          "type": {
            "$ref": "#/components/schemas/OrderType"
          },
          "encodedOrder": {
            "type": "string"
          },
          "signature": {
            "type": "string"
          },
          "nonce": {
            "type": "string"
          },
          "orderHash": {
            "type": "string"
          },
          "orderStatus": {
            "$ref": "#/components/schemas/OrderStatus"
          },
          "chainId": {
            "$ref": "#/components/schemas/ChainId"
          },
          "swapper": {
            "type": "string"
          },
          "reactor": {
            "type": "string"
          },
          "decayStartTime": {
            "type": "number"
          },
          "decayEndTime": {
            "type": "number"
          },
          "deadline": {
            "type": "number"
          },
          "input": {
            "$ref": "#/components/schemas/OrderInput"
          },
          "outputs": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/OrderOutput"
            }
          },
          "filler": {
            "description": "Filler field is defined when the order has been filled and the status tracking function has recorded the filler address.",
            "type": "string"
          },
          "quoteId": {
            "description": "QuoteId field is defined when the order has a quote associated with it.",
            "type": "string"
          },
          "txHash": {
            "description": "TxHash field is defined when the order has been filled and there is a txHash associated with the fill.",
            "type": "string"
          },
          "fillBlock": {
            "description": "Fill block field is defined when the order has been filled and the fill block has been recorded.",
            "type": "number"
          },
          "settledAmounts": {
            "description": "SettledAmount field is defined when the order has been filled and the fill amounts have been recorded.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SettledAmount"
            }
          }
        },
        "required": [
          "ecodedOrder",
          "signature",
          "nonce",
          "orderHash",
          "orderStatus",
          "chainId",
          "swapper",
          "reactor",
          "decayStartTime",
          "decayEndTime",
          "deadline",
          "input",
          "outputs",
          "type",
          "encodedOrder"
        ]
      },
      "GetOrdersResponse": {
        "type": "object",
        "properties": {
          "orders": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/OrderEntity"
            }
          },
          "cursor": {
            "type": "string"
          }
        },
        "required": [
          "orders"
        ]
      },
      "SortKey": {
        "type": "string",
        "enum": [
          "createdAt"
        ]
      },
      "OrderHash": {
        "type": "string"
      },
      "OrderHashes": {
        "type": "string"
      },
      "OrderStatus": {
        "type": "string",
        "enum": [
          "open",
          "expired",
          "error",
          "cancelled",
          "filled",
          "insufficient-funds"
        ]
      },
      "ChainId": {
        "type": "number",
        "enum": [
          1,
          137
        ]
      }
    }
  }
}