{
  "openapi": "3.1.0",
  "info": {
    "title": "TheAI學院 公開 API",
    "version": "1.0.0",
    "description": "台灣最完整的 AI 工具資料庫公開 API。免金鑰、免註冊，授權 CC BY 4.0（引用請標示來源並連回工具頁）。另提供 MCP Server：POST /mcp（Streamable HTTP）。",
    "contact": {
      "name": "TheAI學院",
      "url": "https://www.theai.tw/contact"
    },
    "license": {
      "name": "CC BY 4.0",
      "url": "https://creativecommons.org/licenses/by/4.0/"
    }
  },
  "servers": [
    {
      "url": "https://www.theai.tw"
    }
  ],
  "paths": {
    "/api/tools.json": {
      "get": {
        "summary": "查詢 AI 工具",
        "description": "取得收錄工具的清單，支援關鍵字搜尋、分類篩選與分頁。",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "關鍵字（比對名稱、標語與介紹）"
          },
          {
            "name": "category",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "分類 slug，例如 ai-for-developers"
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "default": 500,
              "maximum": 1000
            },
            "description": "每頁筆數"
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "default": 0
            },
            "description": "分頁位移"
          }
        ],
        "responses": {
          "200": {
            "description": "工具清單",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "site": {
                      "type": "string"
                    },
                    "license": {
                      "type": "string"
                    },
                    "total": {
                      "type": "integer",
                      "description": "符合條件的總筆數"
                    },
                    "count": {
                      "type": "integer"
                    },
                    "limit": {
                      "type": "integer"
                    },
                    "offset": {
                      "type": "integer"
                    },
                    "tools": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "name": {
                            "type": "string",
                            "description": "英文名稱"
                          },
                          "name_zh": {
                            "type": "string",
                            "description": "中文名稱"
                          },
                          "slug": {
                            "type": "string"
                          },
                          "tagline": {
                            "type": "string",
                            "description": "繁中一句話介紹"
                          },
                          "pricing": {
                            "type": "string",
                            "enum": [
                              "free",
                              "freemium",
                              "paid",
                              "trial",
                              ""
                            ]
                          },
                          "rating": {
                            "type": "number",
                            "nullable": true
                          },
                          "country": {
                            "type": "string",
                            "nullable": true
                          },
                          "official_url": {
                            "type": "string",
                            "format": "uri"
                          },
                          "page": {
                            "type": "string",
                            "format": "uri",
                            "description": "本站工具頁（引用時請連回此頁）"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}