REST API
TextPress 提供 RESTful API 接口,方便前后端分离开发。
基础信息
API 基础路径
https://your-domain.com/api/
文章接口
GET
/api/posts
获取文章列表
请求参数
| 参数 | 类型 | 说明 |
|---|---|---|
page | int | 页码,默认 1 |
per_page | int | 每页数量,默认 10 |
category | int | 分类 ID |
响应示例
JSON
{
"success": true,
"data": {
"posts": [...],
"total": 100,
"page": 1,
"per_page": 10
}
}
POST
/api/posts
创建新文章(需要认证)