{
  "openapi": "3.0.0",
  "info": {
    "title": "n8n 公共 API",
    "version": "1.1.1"
  },
  "tags": [
    {
      "name": "DataTable",
      "description": "数据表及其行相关操作"
    }
  ],
  "servers": [
    {
      "url": "/api/v1",
      "description": "当前 n8n 实例（自托管版本的内置测试台）"
    },
    {
      "url": "{url}/api/v1",
      "description": "自托管 n8n 实例",
      "variables": {
        "url": {
          "default": "https://example.com"
        }
      }
    }
  ],
  "security": [
    {
      "ApiKeyAuth": []
    },
    {
      "BearerAuth": []
    },
    {
      "CookieAuth": []
    }
  ],
  "components": {
    "securitySchemes": {
      "ApiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "X-N8N-API-KEY"
      },
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      },
      "CookieAuth": {
        "type": "apiKey",
        "in": "cookie",
        "name": "n8n-auth"
      }
    },
    "parameters": {
      "limit": {
        "name": "limit",
        "in": "query",
        "description": "最多返回的数据项数量。",
        "required": false,
        "schema": {
          "type": "number",
          "default": 100,
          "maximum": 250
        }
      },
      "cursor": {
        "name": "cursor",
        "in": "query",
        "description": "将 cursor 参数设为上次请求响应中的 nextCursor 属性，以进行分页。使用默认值时，获取集合的第一页。更多信息，请参阅分页说明。",
        "required": false,
        "style": "form",
        "schema": {
          "type": "string"
        }
      }
    },
    "responses": {
      "badRequest": {
        "description": "请求无效，或提供的数据格式错误。"
      },
      "unauthorized": {
        "description": "未授权"
      },
      "forbidden": {
        "description": "禁止访问"
      },
      "notFound": {
        "description": "未找到指定资源。"
      }
    }
  },
  "paths": {
    "/data-tables/{dataTableId}/rows": {
      "get": {
        "operationId": "listDataTableRows",
        "tags": [
          "DataTable"
        ],
        "summary": "列出数据表的行",
        "description": "获取数据表中的行，可选择筛选、排序和分页。",
        "parameters": [
          {
            "$ref": "#/components/parameters/limit"
          },
          {
            "$ref": "#/components/parameters/cursor"
          },
          {
            "schema": {
              "type": "string",
              "format": "nanoid",
              "pattern": "^[A-Za-z0-9]{16}$"
            },
            "required": true,
            "description": "数据表的 ID",
            "name": "dataTableId",
            "in": "path"
          },
          {
            "schema": {
              "type": "string",
              "format": "jsonString"
            },
            "required": false,
            "description": "筛选条件的 JSON 字符串",
            "name": "filter",
            "in": "query"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "description": "排序格式：columnName:asc 或 columnName:desc",
            "name": "sortBy",
            "in": "query"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": false,
            "description": "在所有字符串列中搜索的文本",
            "name": "search",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "操作成功。",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "integer",
                            "description": "行 ID，自动生成"
                          },
                          "createdAt": {
                            "type": "string",
                            "format": "date-time",
                            "description": "行创建的日期和时间"
                          },
                          "updatedAt": {
                            "type": "string",
                            "format": "date-time",
                            "description": "行上次更新的日期和时间"
                          }
                        },
                        "required": [
                          "id",
                          "createdAt",
                          "updatedAt"
                        ],
                        "description": "数据表中的一行，包含系统列（id、createdAt、updatedAt）和用户自定义列"
                      }
                    },
                    "nextCursor": {
                      "type": "string",
                      "nullable": true,
                      "description": "将 cursor 参数设为先前请求返回的 nextCursor 属性，以对行进行分页。使用默认值时，获取集合的第一页。"
                    }
                  },
                  "required": [
                    "data",
                    "nextCursor"
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/badRequest"
          },
          "401": {
            "$ref": "#/components/responses/unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/forbidden"
          },
          "404": {
            "$ref": "#/components/responses/notFound"
          }
        }
      }
    }
  }
}
