wepublic-monitor
使用 API Key 查询微信公众号关注列表和缓存文章,支持按公众号名称、时间范围过滤
WePublic Monitor
使用用户的 API Key 查询关注的公众号和获取缓存文章。
⚠️ API Key 检查
在执行任何操作之前,必须先检查 API Key:
- 查看下方
<!-- API_KEY: xxx -->的值 - 如果值为空或为
YOUR_API_KEY:- 停止执行,向用户索取 API Key
- 问用户:"请提供你的 API Key(可向管理员索取)"
- 用户提供后,更新下方注释为
<!-- API_KEY: 用户提供的key -->
- 如果值已配置,使用该 Key 执行后续命令
当前配置
<!-- API_KEY: {{API_KEY}} -->服务器地址: https://value20.top/wechat
1. 查询用户关注的公众号
获取当前用户关注的所有公众号列表及缓存状态。
请求
curl -s "https://value20.top/wechat/api/accounts/subscriptions" \
-H "X-API-Key: {{API_KEY}}"
参数说明
| 参数 | 位置 | 必填 | 说明 |
|---|---|---|---|
X-API-Key | Header | ✅ | 用户 API Key(向管理员索取) |
响应示例
{
"success": true,
"data": [
{
"nickname": "人民日报",
"added_at": "2026-03-15 10:30:00",
"cache_status": "completed",
"cached_count": 120,
"total_count": 120,
"last_cached_at": "2026-04-03 10:30:00"
},
{
"nickname": "央视新闻",
"added_at": "2026-03-20 14:20:00",
"cache_status": "caching",
"cached_count": 45,
"total_count": 200,
"last_cached_at": "2026-04-03 09:15:00"
},
{
"nickname": "科技日报",
"added_at": "2026-04-01 08:00:00",
"cache_status": "pending",
"cached_count": 0,
"total_count": 10,
"last_cached_at": null
}
]
}
响应字段说明
| 字段 | 类型 | 说明 |
|---|---|---|
nickname | string | 公众号名称 |
added_at | string | 用户关注该公众号的时间 |
cache_status | string | 缓存状态:completed(完成)/ caching(缓存中)/ pending(等待中)/ failed(失败) |
cached_count | int | 已缓存文章数量 |
total_count | int | 文章总数量 |
last_cached_at | string | 最后一次缓存更新时间(用于判断数据新鲜度) |
使用场景
场景 1:查看所有关注的公众号
curl -s "https://value20.top/wechat/api/accounts/subscriptions" \
-H "X-API-Key: {{API_KEY}}" | jq '.data[] | {nickname, cache_status, last_cached_at}'
输出示例:
{
"nickname": "人民日报",
"cache_status": "completed",
"last_cached_at": "2026-04-03 10:30:00"
}
{
"nickname": "央视新闻",
"cache_status": "caching",
"last_cached_at": "2026-04-03 09:15:00"
}
场景 2:检查哪些公众号缓存已完成
curl -s "https://value20.top/wechat/api/accounts/subscriptions" \
-H "X-API-Key: {{API_KEY}}" | jq '.data[] | select(.cache_status == "completed") | .nickname'
输出:
人民日报
场景 3:检查最近更新时间(判断数据新鲜度)
curl -s "https://value20.top/wechat/api/accounts/subscriptions" \
-H "X-API-Key: {{API_KEY}}" | jq '.data[] | "\(.nickname): 最后更新 \(.last_cached_at // "尚未缓存")"'
输出:
"人民日报: 最后更新 2026-04-03 10:30:00"
"央视新闻: 最后更新 2026-04-03 09:15:00"
"科技日报: 最后更新 尚未缓存"
场景 4:查看缓存进度
curl -s "https://value20.top/wechat/api/accounts/subscriptions" \
-H "X-API-Key: {{API_KEY}}" | jq '.data[] | "\(.nickname): \(.cached_count)/\(.total_count) 篇"'
输出:
"人民日报: 120/120 篇"
"央视新闻: 45/200 篇"
"科技日报: 0/10 篇"
场景 5:统计关注数量和文章数
curl -s "https://value20.top/wechat/api/accounts/subscriptions" \
-H "X-API-Key: {{API_KEY}}" | jq '{
关注数量: (.data | length),
已缓存文章: [.data[].cached_count] | add,
文章总数: [.data[].total_count] | add
}'
输出:
{
"关注数量": 3,
"已缓存文章": 165,
"文章总数": 330
}
缓存状态说明
| 状态 | 说明 | 建议 |
|---|---|---|
completed | 所有可获取文章已缓存完成 | 可以正常查询文章 |
caching | 正在后台缓存中 | 等待几分钟后重试 |
pending | 等待缓存任务开始 | 首次关注后会有短暂等待 |
failed | 缓存失败(可能是登录过期) | 联系管理员处理 |
2. 获取用户缓存的文章
获取用户订阅公众号的所有缓存文章,支持多种过滤条件。
基础请求(无过滤)
curl -s "https://value20.top/wechat/api/public/cached?limit=20" \
-H "X-API-Key: {{API_KEY}}"
参数说明
| 参数 | 位置 | 必填 | 类型 | 默认值 | 说明 |
|---|---|---|---|---|---|
X-API-Key | Header | ✅ | string | - | 用户 API Key |
limit | Query | ❌ | int | 20 | 返回文章数量,范围 1-100 |
nickname | Query | ❌ | string | - | 按公众号名称模糊过滤(支持部分匹配) |
start_time | Query | ❌ | int | - | 文章发布时间起始(Unix 时间戳,秒) |
end_time | Query | ❌ | int | - | 文章发布时间结束(Unix 时间戳,秒) |
示例 1:按公众号名称过滤
# 只获取"人民日报"的文章(模糊匹配,输入"人民"也能匹配)
curl -s "https://value20.top/wechat/api/public/cached?limit=50&nickname=人民日报" \
-H "X-API-Key: {{API_KEY}}"
示例 2:按时间范围过滤(最近 7 天)
# start_time = 7天前的Unix时间戳
# end_time = 当前Unix时间戳
curl -s "https://value20.top/wechat/api/public/cached?limit=30&start_time=$(date -d '7 days ago' +%s)&end_time=$(date +%s)" \
-H "X-API-Key: {{API_KEY}}"
示例 3:组合过滤(指定公众号 + 时间范围)
# 获取"央视新闻"最近 30 天的文章,最多 100 篇
curl -s "https://value20.top/wechat/api/public/cached?limit=100&nickname=央视新闻&start_time=$(date -d '30 days ago' +%s)" \
-H "X-API-Key: {{API_KEY}}"
示例 4:获取指定日期范围(固定日期)
# 获取 2026 年 3 月的文章
# 2026-03-01 00:00:00 UTC = 1740787200
# 2026-04-01 00:00:00 UTC = 1743465600
curl -s "https://value20.top/wechat/api/public/cached?limit=100&start_time=1740787200&end_time=1743465600" \
-H "X-API-Key: {{API_KEY}}"
示例 5:获取最近 10 篇文章(最快)
curl -s "https://value20.top/wechat/api/public/cached?limit=10" \
-H "X-API-Key: {{API_KEY}}"
响应示例
{
"success": true,
"data": {
"articles": [
{
"title": "今日新闻摘要",
"content": "<p>文章HTML内容...</p>",
"link": "https://mp.weixin.qq.com/s/abc123",
"author": "编辑部",
"cover": "https://mmbiz.qpic.cn/...",
"digest": "文章摘要内容...",
"publish_time": 1743462000,
"publish_time_str": "2026-04-03 08:30:00",
"nickname": "人民日报"
}
],
"total": 50
}
}
响应字段说明
| 字段 | 说明 |
|---|---|
title | 文章标题 |
content | 文章 HTML 正文(保留原始排版) |
link | 原文链接 |
author | 作者 |
cover | 封面图片 URL |
digest | 文章摘要 |
publish_time | 发布时间戳(秒) |
publish_time_str | 发布时间字符串 |
nickname | 所属公众号名称 |
时间戳计算示例
# 当前时间戳
date +%s
# 输出: 1743679200
# 7 天前
date -d '7 days ago' +%s
# 30 天前
date -d '30 days ago' +%s
# 指定日期(2026-03-01 00:00:00)
date -d '2026-03-01' +%s
# 输出: 1740787200
# 时间戳转日期
date -d '@1740787200'
# 输出: Sat Mar 1 00:00:00 UTC 2026
快速测试
# 1. 查看关注列表和最后更新时间
curl -s "https://value20.top/wechat/api/accounts/subscriptions" \
-H "X-API-Key: {{API_KEY}}" | jq .
# 2. 获取最近 10 篇文章
curl -s "https://value20.top/wechat/api/public/cached?limit=10" \
-H "X-API-Key: {{API_KEY}}" | jq .
# 3. 按公众号名称过滤文章
curl -s "https://value20.top/wechat/api/public/cached?limit=50&nickname=人民日报" \
-H "X-API-Key: {{API_KEY}}" | jq .
# 4. 按时间范围过滤(最近 7 天)
curl -s "https://value20.top/wechat/api/public/cached?limit=30&start_time=$(date -d '7 days ago' +%s)&end_time=$(date +%s)" \
-H "X-API-Key: {{API_KEY}}" | jq .
# 5. 只看文章标题和发布时间
curl -s "https://value20.top/wechat/api/public/cached?limit=20" \
-H "X-API-Key: {{API_KEY}}" | jq '.data.articles[] | {title, publish_time_str, nickname}'
错误响应
| HTTP 状态 | 说明 |
|---|---|
| 401 | API Key 无效或未提供 |
| 500 | 服务器内部错误 |
{
"success": false,
"error": "Invalid API Key"
}