获取文章列表
curl -X GET "https://example.com/api/posts/" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
获取单篇文章
curl -X GET "https://example.com/api/posts/1/" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
创建文章
curl -X POST "https://example.com/api/posts/" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"title": "文章标题",
"content": "文章内容...",
"status": "published"
}'
更新文章
curl -X PATCH "https://example.com/api/posts/1/" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{"title": "更新后的标题"}'
删除文章
curl -X DELETE "https://example.com/api/posts/1/" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
健康检查(无需令牌)
curl -X GET "https://example.com/api/health/"
# 200 OK:{"version":"1.0","status":"ok","db":"ok","django_version":"3.2.x","timestamp":"..."}
# 503 :{"version":"1.0","status":"degraded","db":"error",...}
身份自检(验证令牌是否可用)
curl -X GET "https://example.com/api/me/" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
# {"version":"1.0","id":1,"username":"admin","email":"...","is_staff":true,"token_exp":"2026-06-02T12:34:56+00:00"}