{
  "openapi": "3.0.3",
  "info": {
    "title": "LinuxWord 文章开放接口",
    "version": "1.0.5",
    "description": "免登录获取公开文章。目录和详情均直接返回完整 content_html 和封面信息，不需要跳转原文或再次加载正文。支持 CORS。"
  },
  "servers": [
    {
      "url": "https://linuxword.com"
    }
  ],
  "security": [],
  "tags": [
    {
      "name": "文章",
      "description": "完整公开文章读取"
    }
  ],
  "externalDocs": {
    "description": "在线接口文档",
    "url": "https://linuxword.com/articles/api/"
  },
  "paths": {
    "/wp-json/linuxword/v1/articles": {
      "get": {
        "tags": [
          "文章"
        ],
        "summary": "文章目录（每条直接含全文）",
        "operationId": "listArticles",
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "required": false,
            "description": "页码，从 1 开始",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000000,
              "default": 1
            }
          },
          {
            "name": "per_page",
            "in": "query",
            "required": false,
            "description": "每页数量；每条记录直接包含全文",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 20
            }
          },
          {
            "name": "search",
            "in": "query",
            "required": false,
            "description": "搜索标题和正文",
            "schema": {
              "type": "string",
              "maxLength": 120,
              "default": ""
            }
          },
          {
            "name": "orderby",
            "in": "query",
            "required": false,
            "description": "按发表或修改时间排序",
            "schema": {
              "type": "string",
              "enum": [
                "date",
                "modified"
              ],
              "default": "date"
            }
          },
          {
            "name": "order",
            "in": "query",
            "required": false,
            "description": "排序方向",
            "schema": {
              "type": "string",
              "enum": [
                "asc",
                "desc"
              ],
              "default": "desc"
            }
          },
          {
            "name": "modified_after",
            "in": "query",
            "required": false,
            "description": "只返回指定 ISO 8601 时间之后修改的文章",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "成功，返回完整文章数组和分页信息",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ArticleList"
                }
              }
            },
            "headers": {
              "X-WP-Total": {
                "description": "文章总数",
                "schema": {
                  "type": "integer"
                }
              },
              "X-WP-TotalPages": {
                "description": "总页数",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "400": {
            "description": "参数无效或超过实际末页",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "请求过于频繁，请降低并发并退避重试；响应可能为网关 HTML"
          }
        }
      }
    },
    "/wp-json/linuxword/v1/articles/{id}": {
      "get": {
        "tags": [
          "文章"
        ],
        "summary": "文章详情（完整图文和音视频 HTML）",
        "operationId": "getArticle",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "文章 ID",
            "schema": {
              "type": "integer",
              "minimum": 1
            },
            "example": 57054
          }
        ],
        "responses": {
          "200": {
            "description": "成功，直接返回完整文章",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ArticleDetail"
                }
              }
            }
          },
          "400": {
            "description": "参数无效或超过实际末页",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "文章不存在、未公开或设置了访问密码",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "请求过于频繁，请降低并发并退避重试；响应可能为网关 HTML"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Article": {
        "type": "object",
        "required": [
          "id",
          "title",
          "published_at",
          "published_at_gmt",
          "updated_at",
          "views",
          "url",
          "detail_url",
          "api_url",
          "content_html",
          "content_text",
          "cover_url",
          "cover_image",
          "categories",
          "tags"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "minimum": 1,
            "description": "文章唯一 ID"
          },
          "title": {
            "type": "string",
            "description": "文章标题"
          },
          "published_at": {
            "type": "string",
            "format": "date-time",
            "description": "带站点时区的发表时间"
          },
          "published_at_gmt": {
            "type": "string",
            "format": "date-time",
            "description": "UTC 发表时间"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "description": "带时区的最后修改时间"
          },
          "views": {
            "type": "integer",
            "minimum": 0,
            "description": "已有阅读次数；GET 不增加计数"
          },
          "url": {
            "type": "string",
            "format": "uri",
            "description": "直接显示全文的新阅读页"
          },
          "detail_url": {
            "type": "string",
            "format": "uri",
            "description": "与 url 一致"
          },
          "api_url": {
            "type": "string",
            "format": "uri",
            "description": "详情接口地址；目录已经包含全文，无需再次请求"
          },
          "content_html": {
            "type": "string",
            "description": "完整 WordPress 渲染正文，含所有分页、图文、音视频、表格和嵌入内容；不是摘要或跳转链接"
          },
          "content_text": {
            "type": "string",
            "description": "去掉 HTML 标签后的完整正文文本"
          },
          "cover_url": {
            "type": "string",
            "format": "uri",
            "nullable": true,
            "description": "封面地址：特色图优先，其次正文首张有效图片，再其次视频海报；没有时为 null"
          },
          "cover_image": {
            "type": "object",
            "nullable": true,
            "required": [
              "url",
              "source",
              "attachment_id",
              "width",
              "height",
              "alt",
              "updated_at"
            ],
            "properties": {
              "url": {
                "type": "string",
                "format": "uri"
              },
              "source": {
                "type": "string",
                "enum": [
                  "featured_image",
                  "content_image",
                  "video_poster"
                ]
              },
              "attachment_id": {
                "type": "integer",
                "minimum": 1,
                "nullable": true
              },
              "width": {
                "type": "integer",
                "minimum": 1,
                "nullable": true
              },
              "height": {
                "type": "integer",
                "minimum": 1,
                "nullable": true
              },
              "alt": {
                "type": "string"
              },
              "updated_at": {
                "type": "string",
                "format": "date-time",
                "description": "封面更新标记；更换封面会同步更新文章修改时间，以支持增量同步"
              }
            }
          },
          "categories": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Term"
            }
          },
          "tags": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Term"
            }
          }
        }
      },
      "Term": {
        "type": "object",
        "required": [
          "id",
          "name",
          "slug"
        ],
        "properties": {
          "id": {
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "slug": {
            "type": "string"
          }
        }
      },
      "Pagination": {
        "type": "object",
        "required": [
          "page",
          "per_page",
          "total",
          "total_pages",
          "has_more"
        ],
        "properties": {
          "page": {
            "type": "integer",
            "minimum": 1
          },
          "per_page": {
            "type": "integer",
            "minimum": 1,
            "maximum": 100
          },
          "total": {
            "type": "integer",
            "minimum": 0
          },
          "total_pages": {
            "type": "integer",
            "minimum": 0
          },
          "has_more": {
            "type": "boolean"
          }
        }
      },
      "ArticleList": {
        "type": "object",
        "required": [
          "success",
          "pagination",
          "articles"
        ],
        "properties": {
          "success": {
            "type": "boolean",
            "enum": [
              true
            ]
          },
          "pagination": {
            "$ref": "#/components/schemas/Pagination"
          },
          "articles": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Article"
            }
          }
        }
      },
      "ArticleDetail": {
        "type": "object",
        "required": [
          "success",
          "article"
        ],
        "properties": {
          "success": {
            "type": "boolean",
            "enum": [
              true
            ]
          },
          "article": {
            "$ref": "#/components/schemas/Article"
          }
        }
      },
      "Error": {
        "type": "object",
        "required": [
          "code",
          "message",
          "data"
        ],
        "properties": {
          "code": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "data": {
            "type": "object",
            "required": [
              "status"
            ],
            "properties": {
              "status": {
                "type": "integer"
              }
            },
            "additionalProperties": true
          }
        }
      }
    }
  }
}
