API 文档
所有可用端点的详细文档
快速开始
本 API 提供了评论系统、页面浏览统计和网页元数据获取功能。所有端点均使用 JSON 格式进行数据交换。
基础 URL
https://blog.justinl.site身份验证
当前 API 端点不需要身份验证。所有端点都可以公开访问。
速率限制
为了确保服务质量和公平使用,我们实施了以下速率限制:
评论查询每分钟 60 次
浏览统计查询每分钟 60 次
元数据获取每分钟 30 次
代码示例
GET
/api/comments获取文章评论列表
参数
| 名称 | 类型 | 位置 | 描述 |
|---|---|---|---|
slug* | string | query | 文章 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* | string | query | 文章 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* | string | query | 要获取元数据的 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无效的 URL500服务器错误HTTP 状态码
2xx 成功
200请求成功201资源创建成功4xx 客户端错误
400错误的请求401未授权404未找到5xx 服务器错误
500内部服务器错误503服务不可用版本历史
v1.0.02025-10-20- 初始 API 发布
← 返回博客最后更新:2025年10月