Repository navigation
RESTful API
hsfzxjy edited this page Jul 17, 2017
·
12 revisions
-
*必填 -
!只读 -
?部分对象
示例:'1,2'。
ISO-8601 字符串,零时区。如:2017-07-17T07:12:29.181605Z。
alias of String.
alias of String.
T 的数组。
{
count: Number,
next: URL | null, // 下一页 URL
previous: URL | null, // 上一页 URL
results: List<T>
}{
id!: Number,
last_login!: DateTime | null,
username: String,
is_superuser!: Boolean,
first_name: String,
last_name: String,
email: Email,
date_joined!: DateTime,
description: String,
avatar_url: URL,
education: String,
major: String
}{
id!: Number,
category!: String,
message!: String,
has_read: Boolean,
created!: DateTime
}使用 JSON 交换数据。默认当输入有错误时,返回 Status Code 400 和详细错误信息。
标 API<T> <base> 的为类型 T 的 CRUD API,操作有如下几类:
-
list:GET <base>->Page<T> -
create:POST <base>->T -
retrieve:GET <base>/<id>/->T -
update:PUT <base>/<id>/->T(输入为T,完整更新对象) -
patch:PATCH <base>/<id>/->T(输入为T?,局部更新对象) -
delete:DELETE <base>/<id>/
对于指定了 Filters 的 API,可以传递相应的 URL Parameters 筛选结果集。注意:
- 对获取单个对象的操作使用 filters 时,可能会导致 404。
- 筛选
Boolean域时,传入字符串True或False。
{
username*: String,
email*: Email,
password*: String,
password2*: String
}- 404: 当前已有用户登录
- 200 ->
User: 自动将用户登入
{
username*: String,
password*: String
}- 404: 当前已有用户登录
- 200 ->
User
- 403: 未登录
- 200 ->
String = 'OK'
{
old*: String,
new1*: String,
new2*: String
}- 403: 未登录
- 200 ->
String = 'OK'
usernamefirst_namelast_name
listretrieveupdatepatch
自己只能更新自己。
- 200 ->
List<String>: 分类列表
type Category = {
category: String,
count: Number,
unread: Number
}- 200 ->
List<Category>:分类详情信息
- 200 ->
String = 'OK'
- 200 ->
String = 'OK'
has_readcategory-
ids: CommaSeparatedInt:用 id 列表筛选
listretrieve