API 文档

所有可用端点的详细文档

快速开始

本 API 提供了评论系统、页面浏览统计和网页元数据获取功能。所有端点均使用 JSON 格式进行数据交换。

基础 URL
https://blog.justinl.site

身份验证

当前 API 端点不需要身份验证。所有端点都可以公开访问。

速率限制

为了确保服务质量和公平使用,我们实施了以下速率限制:

评论查询每分钟 60 次
浏览统计查询每分钟 60 次
元数据获取每分钟 30 次

代码示例

GET/api/comments

获取文章评论列表

参数

名称类型位置描述
slug*stringquery文章 slug

代码示例

bash
curl -X GET "https://blog.justinl.site/api/comments?slug=my-post-slug" \
  -H "Content-Type: application/json"

响应示例

json
{
  "comments": [
    {
      "id": 1,
      "post_slug": "my-post-slug",
      "content": "Great article!",
      "author_name": "John Doe",
      "created_at": "2025-10-20T12:00:00Z",
      "replies": []
    }
  ],
  "count": 1
}

状态码

200成功
400缺少必需参数
500服务器错误
GET/api/views

获取文章浏览次数

参数

名称类型位置描述
slug*stringquery文章 slug

代码示例

bash
curl -X GET "https://blog.justinl.site/api/views?slug=my-post-slug" \
  -H "Content-Type: application/json"

响应示例

json
{
  "views": 42
}

状态码

200成功
400缺少必需参数
500服务器错误
GET/api/og-metadata

获取 URL 的 Open Graph 元数据

参数

名称类型位置描述
url*stringquery要获取元数据的 URL

代码示例

bash
curl -X GET "https://blog.justinl.site/api/og-metadata?url=https://example.com" \
  -H "Content-Type: application/json"

响应示例

json
{
  "title": "Example Domain",
  "description": "This domain is for use in illustrative examples",
  "image": "https://example.com/og-image.jpg",
  "siteName": "Example",
  "url": "https://example.com",
  "favicon": "https://example.com/favicon.ico"
}

状态码

200成功
400无效的 URL
500服务器错误

HTTP 状态码

2xx 成功

200请求成功
201资源创建成功

4xx 客户端错误

400错误的请求
401未授权
404未找到

5xx 服务器错误

500内部服务器错误
503服务不可用

版本历史

v1.0.02025-10-20
  • 初始 API 发布
← 返回博客最后更新:2025年10月
API 文档 | Justin's Blog