2022-05-18 16:40:55 +00:00
|
|
|
# REST API
|
|
|
|
|
2022-10-31 03:52:17 +00:00
|
|
|
NocoBase 的 HTTP API 是 REST API 的超集,标准的 CRUD API 也支持 RESTful 风格。
|
2022-05-18 16:40:55 +00:00
|
|
|
|
2022-10-31 03:52:17 +00:00
|
|
|
## Collection 资源
|
2022-05-18 16:40:55 +00:00
|
|
|
|
|
|
|
---
|
|
|
|
|
2022-10-31 03:52:17 +00:00
|
|
|
### 创建 collection
|
2022-05-18 16:40:55 +00:00
|
|
|
|
|
|
|
HTTP API
|
|
|
|
|
|
|
|
```bash
|
|
|
|
POST /api/<collection>:create
|
|
|
|
|
|
|
|
{} # JSON body
|
|
|
|
```
|
|
|
|
|
|
|
|
REST API
|
|
|
|
|
|
|
|
```bash
|
|
|
|
POST /api/<collection>
|
|
|
|
|
|
|
|
{} # JSON body
|
|
|
|
```
|
|
|
|
|
2022-10-31 03:52:17 +00:00
|
|
|
### 查看 collection 列表
|
2022-05-18 16:40:55 +00:00
|
|
|
|
|
|
|
HTTP API
|
|
|
|
|
|
|
|
```bash
|
|
|
|
GET /api/<collection>:list
|
|
|
|
```
|
|
|
|
|
|
|
|
REST API
|
|
|
|
|
|
|
|
```bash
|
|
|
|
GET /api/<collection>
|
|
|
|
```
|
|
|
|
|
2022-10-31 03:52:17 +00:00
|
|
|
### 查看 collection 详情
|
2022-05-18 16:40:55 +00:00
|
|
|
|
|
|
|
HTTP API
|
|
|
|
|
|
|
|
```bash
|
|
|
|
GET /api/<collection>:get?filterByTk=<collectionIndex>
|
|
|
|
GET /api/<collection>:get/<collectionIndex>
|
|
|
|
```
|
|
|
|
|
|
|
|
REST API
|
|
|
|
|
|
|
|
```bash
|
|
|
|
GET /api/<collection>/<collectionIndex>
|
|
|
|
```
|
|
|
|
|
2022-10-31 03:52:17 +00:00
|
|
|
### 更新 collection
|
2022-05-18 16:40:55 +00:00
|
|
|
|
|
|
|
HTTP API
|
|
|
|
|
|
|
|
```bash
|
|
|
|
POST /api/<collection>:update?filterByTk=<collectionIndex>
|
|
|
|
|
|
|
|
{} # JSON body
|
|
|
|
|
2022-10-31 03:52:17 +00:00
|
|
|
# 或者
|
2022-05-18 16:40:55 +00:00
|
|
|
POST /api/<collection>:update/<collectionIndex>
|
|
|
|
|
|
|
|
{} # JSON body
|
|
|
|
```
|
|
|
|
|
|
|
|
REST API
|
|
|
|
|
|
|
|
```bash
|
|
|
|
PUT /api/<collection>/<collectionIndex>
|
|
|
|
|
|
|
|
{} # JSON body
|
|
|
|
```
|
|
|
|
|
2022-10-31 03:52:17 +00:00
|
|
|
### 删除 collection
|
2022-05-18 16:40:55 +00:00
|
|
|
|
|
|
|
HTTP API
|
|
|
|
|
|
|
|
```bash
|
|
|
|
POST /api/<collection>:destroy?filterByTk=<collectionIndex>
|
2022-10-31 03:52:17 +00:00
|
|
|
# 或者
|
2022-05-18 16:40:55 +00:00
|
|
|
POST /api/<collection>:destroy/<collectionIndex>
|
|
|
|
```
|
|
|
|
|
|
|
|
REST API
|
|
|
|
|
|
|
|
```bash
|
|
|
|
DELETE /api/<collection>/<collectionIndex>
|
|
|
|
```
|
|
|
|
|
2022-10-31 03:52:17 +00:00
|
|
|
## Association 资源
|
2022-05-18 16:40:55 +00:00
|
|
|
|
|
|
|
---
|
|
|
|
|
2022-10-31 03:52:17 +00:00
|
|
|
### 创建 Association
|
2022-05-18 16:40:55 +00:00
|
|
|
|
|
|
|
HTTP API
|
|
|
|
|
|
|
|
```bash
|
|
|
|
POST /api/<collection>/<collectionIndex>/<association>:create
|
|
|
|
|
|
|
|
{} # JSON body
|
|
|
|
```
|
|
|
|
|
|
|
|
REST API
|
|
|
|
|
|
|
|
```bash
|
|
|
|
POST /api/<collection>/<collectionIndex>/<association>
|
|
|
|
|
|
|
|
{} # JSON body
|
|
|
|
```
|
|
|
|
|
2022-10-31 03:52:17 +00:00
|
|
|
### 查看 Association 列表
|
2022-05-18 16:40:55 +00:00
|
|
|
|
|
|
|
HTTP API
|
|
|
|
|
|
|
|
```bash
|
|
|
|
GET /api/<collection>/<collectionIndex>/<association>:list
|
|
|
|
```
|
|
|
|
|
|
|
|
REST API
|
|
|
|
|
|
|
|
```bash
|
|
|
|
GET /api/<collection>/<collectionIndex>/<association>
|
|
|
|
```
|
|
|
|
|
2022-10-31 03:52:17 +00:00
|
|
|
### 查看 Association 详情
|
2022-05-18 16:40:55 +00:00
|
|
|
|
|
|
|
HTTP API
|
|
|
|
|
|
|
|
```bash
|
|
|
|
GET /api/<collection>/<collectionIndex>/<association>:get?filterByTk=<associationIndex>
|
2022-10-31 03:52:17 +00:00
|
|
|
# 或者
|
2022-05-18 16:40:55 +00:00
|
|
|
GET /api/<collection>/<collectionIndex>/<association>:get/<associationIndex>
|
|
|
|
```
|
|
|
|
|
|
|
|
REST API
|
|
|
|
|
|
|
|
```bash
|
|
|
|
GET /api/<collection>/<collectionIndex>/<association>:get/<associationIndex>
|
|
|
|
```
|
|
|
|
|
2022-10-31 03:52:17 +00:00
|
|
|
### 更新 Association
|
2022-05-18 16:40:55 +00:00
|
|
|
|
|
|
|
HTTP API
|
|
|
|
|
|
|
|
```bash
|
|
|
|
POST /api/<collection>/<collectionIndex>/<association>:update?filterByTk=<associationIndex>
|
|
|
|
|
|
|
|
{} # JSON body
|
|
|
|
|
2022-10-31 03:52:17 +00:00
|
|
|
# 或者
|
2022-05-18 16:40:55 +00:00
|
|
|
POST /api/<collection>/<collectionIndex>/<association>:update/<associationIndex>
|
|
|
|
|
|
|
|
{} # JSON body
|
|
|
|
```
|
|
|
|
|
|
|
|
REST API
|
|
|
|
|
|
|
|
```bash
|
|
|
|
PUT /api/<collection>/<collectionIndex>/<association>:update/<associationIndex>
|
|
|
|
|
2022-10-31 03:52:17 +00:00
|
|
|
{} # JSON 数据
|
2022-05-18 16:40:55 +00:00
|
|
|
```
|
|
|
|
|
2022-10-31 03:52:17 +00:00
|
|
|
### 删除 Association
|
2022-05-18 16:40:55 +00:00
|
|
|
|
|
|
|
HTTP API
|
|
|
|
|
|
|
|
```bash
|
|
|
|
POST /api/<collection>/<collectionIndex>/<association>:destroy?filterByTk=<associationIndex>
|
2022-10-31 03:52:17 +00:00
|
|
|
# 或者
|
2022-05-18 16:40:55 +00:00
|
|
|
POST /api/<collection>/<collectionIndex>/<association>:destroy/<associationIndex>
|
|
|
|
```
|
|
|
|
|
|
|
|
REST API
|
|
|
|
|
|
|
|
```bash
|
|
|
|
DELETE /api/<collection>/<collectionIndex>/<association>/<associationIndex>
|
|
|
|
```
|