---
title: "REST API 端点 | Tajo"
description: "REST API 端点的文档"
url: https://tajo.io/zh-cn/docs/endpoints/rest-api/
markdown: https://tajo.io/zh-cn/docs/endpoints/rest-api.md
lang: zh-CN
author: "Set Noa"
author_url: https://tajo.io/zh-cn/set-noa/
robots: noindex
---

申请抢先体验

请输入您的名字和公司电子邮箱地址。我们会发送确认 Tajo 访问申请的链接。

# REST API 端点

[Set Noa](https://tajo.io/zh-cn/set-noa/)

Caution

**演示页面** - 这是一个用于展示多标签文档功能的演示页面。此处内容仅供示意。

Tajo 的 REST API 提供用于访问和操作数据的端点。所有端点都以 JSON 格式返回数据。

## 基础 URL

所有 API 请求都应发送到以下基础 URL：

```
https://api.example.com/v1
```

## 用户端点

### 获取全部用户

```http
GET /users
```

返回全部用户的列表。支持分页参数。

**查询参数：**

| 参数 | 类型 | 说明 |
| --- | --- | --- |
| page | integer | 页码（默认值：1） |
| limit | integer | 每页记录数（默认值：50，最大值：100） |
| sort | string | 排序字段（例如 “name”、“created\_at”） |

**响应：**

```json
{
  "data": [
    {
      "id": "user_123",
      "name": "John Doe",
      "email": "john@example.com",
      "created_at": "2023-01-15T08:30:00Z"
    },
    // More users...
  ],
  "meta": {
    "total": 250,
    "page": 1,
    "limit": 50
  }
}
```

### 按 ID 获取用户

```http
GET /users/{id}
```

按 ID 返回单个用户。

**响应：**

```json
{
  "data": {
    "id": "user_123",
    "name": "John Doe",
    "email": "john@example.com",
    "created_at": "2023-01-15T08:30:00Z",
    "profile": {
      "bio": "Software developer",
      "location": "New York",
      "avatar_url": "https://example.com/avatars/john.jpg"
    }
  }
}
```

## 商品端点

### 获取全部商品

```http
GET /products
```

返回全部商品的列表。支持筛选和分页。

**查询参数：**

| 参数 | 类型 | 说明 |
| --- | --- | --- |
| category | string | 按类目筛选 |
| min\_price | number | 按最低价格筛选 |
| max\_price | number | 按最高价格筛选 |
| page | integer | 页码（默认值：1） |
| limit | integer | 每页记录数（默认值：50，最大值：100） |

**响应：**

```json
{
  "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 - 服务器发生错误 |

错误响应包含一条说明问题原因的消息：

```json
{
  "error": {
    "code": "invalid_parameter",
    "message": "The parameter 'email' is not a valid email address",
    "request_id": "req_abc123"
  }
}
```
