2022-05-19 00:40:55 +08:00
|
|
|
# REST API
|
|
|
|
|
2022-12-23 17:35:06 +08:00
|
|
|
HTTP API of NocoBase is a superset of REST API, and the standard CRUD API also supports the RESTful style.
|
2022-05-19 00:40:55 +08:00
|
|
|
|
2022-12-23 17:35:06 +08:00
|
|
|
## Collection Resources
|
2022-05-19 00:40:55 +08:00
|
|
|
|
2022-12-23 17:35:06 +08:00
|
|
|
### Create Collection
|
2022-05-19 00:40:55 +08:00
|
|
|
|
|
|
|
HTTP API
|
|
|
|
|
|
|
|
```bash
|
|
|
|
POST /api/<collection>:create
|
|
|
|
|
|
|
|
{} # JSON body
|
|
|
|
```
|
|
|
|
|
|
|
|
REST API
|
|
|
|
|
|
|
|
```bash
|
|
|
|
POST /api/<collection>
|
|
|
|
|
|
|
|
{} # JSON body
|
|
|
|
```
|
|
|
|
|
2022-12-23 17:35:06 +08:00
|
|
|
### View Collection List
|
2022-05-19 00:40:55 +08:00
|
|
|
|
|
|
|
HTTP API
|
|
|
|
|
|
|
|
```bash
|
|
|
|
GET /api/<collection>:list
|
|
|
|
```
|
|
|
|
|
|
|
|
REST API
|
|
|
|
|
|
|
|
```bash
|
|
|
|
GET /api/<collection>
|
|
|
|
```
|
|
|
|
|
2022-12-23 17:35:06 +08:00
|
|
|
### View Collection Details
|
2022-05-19 00:40:55 +08:00
|
|
|
|
|
|
|
HTTP API
|
|
|
|
|
|
|
|
```bash
|
|
|
|
GET /api/<collection>:get?filterByTk=<collectionIndex>
|
|
|
|
GET /api/<collection>:get/<collectionIndex>
|
|
|
|
```
|
|
|
|
|
|
|
|
REST API
|
|
|
|
|
|
|
|
```bash
|
|
|
|
GET /api/<collection>/<collectionIndex>
|
|
|
|
```
|
|
|
|
|
2022-12-23 17:35:06 +08:00
|
|
|
### Update Collection
|
2022-05-19 00:40:55 +08:00
|
|
|
|
|
|
|
HTTP API
|
|
|
|
|
|
|
|
```bash
|
|
|
|
POST /api/<collection>:update?filterByTk=<collectionIndex>
|
|
|
|
|
|
|
|
{} # JSON body
|
|
|
|
|
2022-10-31 23:20:27 +08:00
|
|
|
# Or
|
2022-05-19 00:40:55 +08:00
|
|
|
POST /api/<collection>:update/<collectionIndex>
|
|
|
|
|
|
|
|
{} # JSON body
|
|
|
|
```
|
|
|
|
|
|
|
|
REST API
|
|
|
|
|
|
|
|
```bash
|
|
|
|
PUT /api/<collection>/<collectionIndex>
|
|
|
|
|
|
|
|
{} # JSON body
|
|
|
|
```
|
|
|
|
|
2022-12-23 17:35:06 +08:00
|
|
|
### Delete Collection
|
2022-05-19 00:40:55 +08:00
|
|
|
|
|
|
|
HTTP API
|
|
|
|
|
|
|
|
```bash
|
|
|
|
POST /api/<collection>:destroy?filterByTk=<collectionIndex>
|
2022-10-31 23:20:27 +08:00
|
|
|
# Or
|
2022-05-19 00:40:55 +08:00
|
|
|
POST /api/<collection>:destroy/<collectionIndex>
|
|
|
|
```
|
|
|
|
|
|
|
|
REST API
|
|
|
|
|
|
|
|
```bash
|
|
|
|
DELETE /api/<collection>/<collectionIndex>
|
|
|
|
```
|
|
|
|
|
2022-12-23 17:35:06 +08:00
|
|
|
## Association Resources
|
2022-05-19 00:40:55 +08:00
|
|
|
|
2022-10-31 23:20:27 +08:00
|
|
|
### Create Association
|
2022-05-19 00:40:55 +08:00
|
|
|
|
|
|
|
HTTP API
|
|
|
|
|
|
|
|
```bash
|
|
|
|
POST /api/<collection>/<collectionIndex>/<association>:create
|
|
|
|
|
|
|
|
{} # JSON body
|
|
|
|
```
|
|
|
|
|
|
|
|
REST API
|
|
|
|
|
|
|
|
```bash
|
|
|
|
POST /api/<collection>/<collectionIndex>/<association>
|
|
|
|
|
|
|
|
{} # JSON body
|
|
|
|
```
|
|
|
|
|
2022-12-23 17:35:06 +08:00
|
|
|
### View Association List
|
2022-05-19 00:40:55 +08:00
|
|
|
|
|
|
|
HTTP API
|
|
|
|
|
|
|
|
```bash
|
|
|
|
GET /api/<collection>/<collectionIndex>/<association>:list
|
|
|
|
```
|
|
|
|
|
|
|
|
REST API
|
|
|
|
|
|
|
|
```bash
|
|
|
|
GET /api/<collection>/<collectionIndex>/<association>
|
|
|
|
```
|
|
|
|
|
2022-12-23 17:35:06 +08:00
|
|
|
### View Association Details
|
2022-05-19 00:40:55 +08:00
|
|
|
|
|
|
|
HTTP API
|
|
|
|
|
|
|
|
```bash
|
|
|
|
GET /api/<collection>/<collectionIndex>/<association>:get?filterByTk=<associationIndex>
|
2022-10-31 23:20:27 +08:00
|
|
|
# Or
|
2022-05-19 00:40:55 +08:00
|
|
|
GET /api/<collection>/<collectionIndex>/<association>:get/<associationIndex>
|
|
|
|
```
|
|
|
|
|
|
|
|
REST API
|
|
|
|
|
|
|
|
```bash
|
|
|
|
GET /api/<collection>/<collectionIndex>/<association>:get/<associationIndex>
|
|
|
|
```
|
|
|
|
|
2022-10-31 23:20:27 +08:00
|
|
|
### Update Association
|
2022-05-19 00:40:55 +08:00
|
|
|
|
|
|
|
HTTP API
|
|
|
|
|
|
|
|
```bash
|
|
|
|
POST /api/<collection>/<collectionIndex>/<association>:update?filterByTk=<associationIndex>
|
|
|
|
|
|
|
|
{} # JSON body
|
|
|
|
|
2022-10-31 23:20:27 +08:00
|
|
|
# Or
|
2022-05-19 00:40:55 +08:00
|
|
|
POST /api/<collection>/<collectionIndex>/<association>:update/<associationIndex>
|
|
|
|
|
|
|
|
{} # JSON body
|
|
|
|
```
|
|
|
|
|
|
|
|
REST API
|
|
|
|
|
|
|
|
```bash
|
|
|
|
PUT /api/<collection>/<collectionIndex>/<association>:update/<associationIndex>
|
|
|
|
|
2022-10-31 23:20:27 +08:00
|
|
|
{} # JSON
|
2022-05-19 00:40:55 +08:00
|
|
|
```
|
|
|
|
|
2022-10-31 23:20:27 +08:00
|
|
|
### Delete Association
|
2022-05-19 00:40:55 +08:00
|
|
|
|
|
|
|
HTTP API
|
|
|
|
|
|
|
|
```bash
|
|
|
|
POST /api/<collection>/<collectionIndex>/<association>:destroy?filterByTk=<associationIndex>
|
2022-10-31 23:20:27 +08:00
|
|
|
# Or
|
2022-05-19 00:40:55 +08:00
|
|
|
POST /api/<collection>/<collectionIndex>/<association>:destroy/<associationIndex>
|
|
|
|
```
|
|
|
|
|
|
|
|
REST API
|
|
|
|
|
|
|
|
```bash
|
|
|
|
DELETE /api/<collection>/<collectionIndex>/<association>/<associationIndex>
|
|
|
|
```
|