{
  "openapi": "3.1.0",
  "info": {
    "title": "Douyin Resolver API",
    "version": "1.1.0",
    "description": "抖音链接/aweme_id → 无水印视频直链。直链为时效签名，稳定入口用 /stream 或 /download。"
  },
  "components": {
    "securitySchemes": {
      "ApiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key"
      }
    }
  },
  "paths": {
    "/healthz": {
      "get": {
        "summary": "健康检查",
        "responses": {
          "200": {
            "description": "ok"
          }
        }
      }
    },
    "/api/v1/capabilities": {
      "get": {
        "summary": "服务能力",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "ok"
          }
        }
      }
    },
    "/api/v1/parse": {
      "post": {
        "summary": "解析：链接/文案/口令/id，自动判平台",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "text": {
                    "type": "string",
                    "description": "整段分享文案或口令"
                  },
                  "url": {
                    "type": "string"
                  },
                  "aweme_id": {
                    "type": "string"
                  },
                  "id": {
                    "type": "string"
                  },
                  "code": {
                    "type": "string"
                  },
                  "fresh": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "schema v1 归一化结果"
          },
          "400": {
            "description": "PLATFORM_UNKNOWN / ID_NOT_FOUND / BAD_INPUT"
          },
          "401": {
            "description": "UNAUTHENTICATED"
          },
          "422": {
            "description": "CODE_ONLY（只拿到口令）"
          },
          "429": {
            "description": "RATE_LIMITED"
          },
          "501": {
            "description": "PLATFORM_NOT_IMPLEMENTED"
          },
          "502": {
            "description": "RESOLVE_FAILED"
          }
        }
      }
    },
    "/api/v1/platforms": {
      "get": {
        "summary": "平台清单与支持状态",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "ok"
          }
        }
      }
    },
    "/api/v1/videos/{id}": {
      "get": {
        "summary": "按 id 取归一化结果",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "fresh",
            "in": "query",
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "ok"
          }
        }
      }
    },
    "/api/v1/videos/{id}/stream": {
      "get": {
        "summary": "302 到新签直链（relay=1 走中继）",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "responses": {
          "302": {
            "description": "跳转"
          }
        }
      }
    },
    "/api/v1/videos/{id}/download": {
      "get": {
        "summary": "中继下载（attachment）",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "字节流"
          }
        }
      }
    },
    "/api/v1/library": {
      "get": {
        "summary": "归档清单",
        "security": [
          {
            "ApiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "ok"
          }
        }
      }
    }
  }
}