REST API 端点
Caution
演示页面 - 这是一个用于展示多标签文档功能的演示页面。此处内容仅供示意。
Tajo 的 REST API 提供用于访问和操作数据的端点。所有端点都以 JSON 格式返回数据。
基础 URL
所有 API 请求都应发送到以下基础 URL:
https://api.example.com/v1用户端点
获取全部用户
GET /users返回全部用户的列表。支持分页参数。
查询参数:
| 参数 | 类型 | 说明 |
|---|---|---|
| page | integer | 页码(默认值:1) |
| limit | integer | 每页记录数(默认值:50,最大值:100) |
| sort | string | 排序字段(例如 “name”、“created_at”) |
响应:
{ "data": [ { "id": "user_123", "name": "John Doe", "created_at": "2023-01-15T08:30:00Z" }, // More users... ], "meta": { "total": 250, "page": 1, "limit": 50 }}按 ID 获取用户
GET /users/{id}按 ID 返回单个用户。
响应:
{ "data": { "id": "user_123", "name": "John Doe", "created_at": "2023-01-15T08:30:00Z", "profile": { "bio": "Software developer", "location": "New York", "avatar_url": "https://example.com/avatars/john.jpg" } }}商品端点
获取全部商品
GET /products返回全部商品的列表。支持筛选和分页。
查询参数:
| 参数 | 类型 | 说明 |
|---|---|---|
| category | string | 按类目筛选 |
| min_price | number | 按最低价格筛选 |
| max_price | number | 按最高价格筛选 |
| page | integer | 页码(默认值:1) |
| limit | integer | 每页记录数(默认值:50,最大值:100) |
响应:
{ "data": [ { "id": "prod_123", "name": "Example Product", "description": "This is an example product", "price": 49.99, "category": "electronics" }, // More products... ], "meta": { "total": 350, "page": 1, "limit": 50 }}错误处理
所有端点都遵循标准 HTTP 状态码,并在适用时返回详细的错误信息:
| 状态码 | 说明 |
|---|---|
| 200 | OK - 请求成功 |
| 400 | Bad Request - 参数无效 |
| 401 | Unauthorized - 需要身份认证 |
| 403 | Forbidden - 权限不足 |
| 404 | Not Found - 资源不存在 |
| 429 | Too Many Requests - 超出速率限制 |
| 500 | Internal Server Error - 服务器发生错误 |
错误响应包含一条说明问题原因的消息:
{ "error": { "code": "invalid_parameter", "message": "The parameter 'email' is not a valid email address", "request_id": "req_abc123" }}