通过 Halo REST API 管理博客文章、评论等。
PAT Token 存储在环境变量 HALO_PAT_TOKEN 中。使用时去掉 pat_ 前缀,直接使用 JWT 部分。
认证方式:Authorization: Bearer
http://localhost:8090GET /apis/api.content.halo.run/v1alpha1/postsGET /apis/uc.api.content.halo.run/v1alpha1/posts通过 python3 调用 scripts/halo_api.py,支持以下命令:
# 获取文章列表
python3 scripts/halo_api.py list_posts
# 获取分类列表
python3 scripts/halo_api.py list_categories
# 获取标签列表
python3 scripts/halo_api.py list_tags
# 发文章(创建草稿,不自动发布)
python3 scripts/halo_api.py create_post --title "标题" --content "# 内容" --slug "url-slug"
# 发文章并直接发布
python3 scripts/halo_api.py create_post --title "标题" --content "# 内容" --slug "url-slug" --publish
# 发文章带分类和标签(使用分类/标签的 displayName)
python3 scripts/halo_api.py create_post --title "标题" --content "# 内容" --slug "url-slug" --categories "默认分类" --tags "技术"
# 发布草稿
python3 scripts/halo_api.py publish_post --name "文章UUID"
# 回复评论
python3 scripts/halo_api.py reply_comment --comment "评论UUID" --content "回复内容"
--publish 时,文章仅创建为草稿,不自动发布--slug 是文章的 URL 路径,会自动从标题生成(使用拼音/英文),建议手动指定displayName,脚本会自动查找对应的 UUID共 1 个版本