好味道众筹 API 文档
错误处理方式
当请求数据错误或后台处理错误时,会通过HTTP状态码及JSON格式的错误相关信息一起返回给客户端。
HTTP 状态码
400 - 请求格式错误
401 - 凭据无效,拒绝访问
403 - 鉴权成功,但该用户没有权限
404 - 请求的资源不存在
405 - 请求的方法不被允许
JSON 错误信息
当发生错误时,不论是请求什么内容,返回的 JSON 数据将会仅包含和错误相关的信息。
当请求中不包含自定义数据(URL中的 GET 选项参数不算自定义数据)或包含自定义数据但没有验证问题时,如果发生错误,返回
{
"error_code": 10004,
"error_message": "Invalid token",
"errors": []
}
其中, error_code 为全局错误码,可以在下表查看, error_message 为错误描述, errors 为空数组。
当请求中包含自定义数据(比如 POST 时发送的 JSON 数据)且发生校验错误,返回
{
"error_code": 10006,
"error_message": "Validation Failed",
"errors":
[
{
"field": "email",
"error_code": 10000,
"error_message": "Invalid data"
},
{
"field": "password",
"error_code": 10001,
"error_message": "Required data"
}
]
}
其中, error_code , error_message 仍然分别为全局错误码和错误描述, field 为出错字段名。
注:当 errors 中存在数据时,外层的 error_message 一定为 Validation Failed , error_code 一定为 10006 。
全局错误码
-1 - 系统出错(当出现这种情况时请向我反馈)
10000 - Invalid data - 不合法的数据
10001 - Required data - 该字段为必须的
10002 - Inactive user - 该用户尚未激活
10003 - Incorrect email or password - 不正确的电子邮箱地址或密码
10004 - Invalid token - 无效的Token
10005 - Invalid refresh token - 无效的Refresh Token
10006 - Validation Failed - 验证自定义数据失败
10007 - Invalid token header. No credentials provided. - 不合法的token header, 没有任何验证信息被提供
10008 - Invalid token header. Token string should not contain spaces. - 不合法的token header, token不能包含空格
10009 - User inactive or deleted - 用户未激活或已删除
10010 - Token has expired - Token已经过期
10011 - Malformed request. - 错误的请求
10012 - Incorrect authentication credentials. - 不正确的身份验证信息
10013 - Authentication credentials were not provided. - 身份验证信息没有提供
10014 - You do not have permission to perform this action. - 没有权限去执行当前操作
10015 - Not found - 找不到页面
10016 - Method 'GET' not allowed. - GET方法不允许
10017 - Method 'POST' not allowed. - POST方法不允许
10018 - Method 'PUT' not allowed. - PUT方法不允许
10019 - Method 'DELETE' not allowed. DELETE方法不允许
10020 - Method 'HEAD' not allowed. HEAD方法不允许
10021 - Method 'PATCH' not allowed. PATCH方法不允许
10022 - Could not satisfy the request's Accept header 不能满足请求的头信息
10023 - Permission denied 权限不足
10024 - Invalid ID 错误的ID
10025 - Invalid type 错误的类型
10026 - Permission denied when checking project id 提供的项目ID数据越权, 非自己名下
10027 - Invalid image ID 错误的图片ID
10028 - Invalid image type 错误的图片类型
10029 - Invalid image user (no user) 错误的图片用户(无用户)
10030 - Invalid image user (other user) 错误的图片用户(他人用户)
10031 - Already attention 重复关注
10032 - Already inattention 重复取消关注
10033 - Error comment type, you are not authenticated 错误的评论发布类型, 匿名用户仅能发送匿名评论
10034 - Already associated 已经存在关联, 不能删除
对于客户端的请求,网站后台采用 Token 的方式进行验证,当用户第一次在客户端登陆时,客户端需要将 电子邮件地址 和 密码 直接 POST 到网站后台请求 Token 和 Refresh Token。以后每次发送需要身份验证的 API 请求时,需要将 Token 的值存放于 HTTP header 中,示例如下:
Authorization: Token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b
注意 Token 的后面有一个空格。
每个 Token 的有效期为 7200 秒,超时后将会失效,需重新获取 Token,重新获取时请将已失效的 Token 和 Refresh Token 一起 POST 到网站后台,验证通过后会返回新的 Token 及 Refresh Token。
获取Token - 通过 Email 及 Password
获取 Token 及 Refresh Token
/api/token/get/
Show code sample
Response
200 (OK)
Content-Type: application/json
{
"token": "e1bb8b8a4ff5820d155d2a0c853afdd34486c3c9",
"refresh_token": "f95e6625dbab66a49f95670acb194f1e96e7b4ca"
}
Response
400 (Bad Request)
Content-Type: application/json
{
"error_code": 10006,
"error_message": "Validation Failed",
"errors":
[
{
"field": "email",
"error_code": 10000,
"error_message": "Invalid data"
},
{
"field": "password",
"error_code": 10001,
"error_message": "Required data"
}
]
}
获取Token - 通过 Token 及 Refresh Token
获取 Token 及 Refresh Token
/api/token/refresh/
Show code sample
Response
200 (OK)
Content-Type: application/json
{
"token": "98bd8864d81fcf2e36dfe20cf71d3893aa78c774",
"refresh_token": "66dca725bc7f058680aea7221fc9b09004635d38"
}
Response
400 (Bad Request)
Content-Type: application/json
{
"error_code": 10004,
"error_message": "Invalid token"
"errors": [],
}
省市区列表
对于所有的响应, 返回数据的顺序与管理后台的排序一致 ,也就是说,返回的数组是已经排好序的,所以请不要将 id 作为排序依据。
所有响应内容中的 id 均为对应的地域(省/市/区)的编号,将会在获取该地域下一级时使用。
获取省列表
该接口不需要任何参数,下面示例中限于篇幅,仅显示两省,并且 id顺序并非顺序 ,请注意。实际中将会返回全部省份。
如果管理后台没有添加省份数据,此处将会直接返回空数组。
获取省列表
/api/location/province/
Show code sample
Response
200 (OK)
Content-Type: application/json
[
{
id: 5,
name: "北京"
},
{
id: 1,
name: "湖北省"
}
]
获取市列表
该接口可以获得某个省所有市的列表,如果管理后台没有添加对应省的市数据,将会直接返回空数组。
当未找到序号为 id 的省,或者 id 所代表的地域的级别并非省,将会返回错误信息 Invalid ID ,具体见下面的示例。
获取市列表
/api/location/city/{id}
| Name | Description | Details |
|---|---|---|
| id | 省份ID,由 /api/location/province/ 获取得到 |
integer, required |
Show code sample
Response
200 (OK)
Content-Type: application/json
[
{
id: 2,
name: "武汉市"
},
{
id: 3,
name: "恩施市"
},
{
id: 4,
name: "鄂州市"
}
]
Response
400 (Bad Request)
Content-Type: application/json
{
error_message: "Invalid ID",
error_code: 10024,
errors: [ ]
}
获取区列表
该接口可以获得某个市所有区的列表,如果管理后台没有添加对应市的区数据,将会直接返回空数组。
当未找到序号为 id 的市,或者 id 所代表的地域的级别并非市,将会返回错误信息 Invalid ID ,具体见下面的示例。
获取区列表
/api/location/country/{id}
| Name | Description | Details |
|---|---|---|
| id | 市ID,由 /api/location/city/{id} 获取得到 |
integer, required |
Show code sample
Response
200 (OK)
Content-Type: application/json
[
{
id: 7,
name: "洪山区"
},
{
id: 8,
name: "武昌区"
}
]
Response
400 (Bad Request)
Content-Type: application/json
{
error_message: "Invalid ID",
error_code: 10024,
errors: [ ]
}
所有在站点中显示的图片(用户头像,身份证照片,项目封面,项目描述图片等)都需要通过此接口上传,当上传成功后会返回一个图片 ID ,此 ID 在所有的需要图片的 API 中通用。
获取图片 (GET) 不需要任何认证信息。
当进行 (POST, PUT, PATCH, DELETE) 操作时请注意此 API 接口需要认证信息,请不要忘记在 Header 中添加 Token。当无认证信息时仍然可以上传图片,但该图片将不会所属于某个用户,在其他需要验证图片所有权的 API 接口中将报 Invalid image user (no user) 错误,仅用于登录注册页面这种无用户状态的地方,其他地方请慎用。
当某个图片不属于任何用户时,任何无认证信息或有认证信息的请求均可对该图片进行更新修改或删除;当某个图片属于某个用户的时候,只有该用户自己拥有更新修改或删除的权利。
Request 参数说明
type :整型数字,说明了上传图片的类型,请注意选择正确的图片类型,错误的图片类型将在其他 API 使用时报 Invalid image type 错误。
0: 身份证照片
1: 用户头像
2: 项目封面
3: 项目回馈描述图片
image:图片文件。
Response 参数说明
id:整型数字,图片ID。在所有其他需要图片内容的 API 中通用。
user: 整型数字或 null 。如果为整型数字,则代表该图片所属用户的 ID;如果为 null ,则代表图片无所属用户。
type:整型数字,同 Request 中的参数 type。
url:该图片的 URL 地址,相对于网站根目录,可直接访问。
注意上传图片的时候, Content-Type 为 multipart/form-data ,下面示例中为简单起见,仍为 json 格式。
注: {image} 为需要上传的图片文件。
/api/image/
Show code sample
Response
201 (Created)
Content-Type: application/json
{
"id": 12,
"user": 1,
"type": 2,
"url": "/media/images/1351416403219.jpg"
}
Response
400 (Bad Request)
Content-Type: application/json
{
"errors": [
{
"field": "image",
"error_message": "Invalid data",
"error_code": 10000
},
{
"field": "type",
"error_message": "Required data",
"error_code": 10001
}
],
"error_code": 10006,
"error_message": "Validation Failed"
}
获取及修改删除图片
/api/image/{id}
| Name | Description | Details |
|---|---|---|
| id | integer, required |
Show code sample
Response
200 (OK)
Content-Type: application/json
{
"id": 2,
"user": 1,
"type": 1,
"url": "/media/images/1351416372388_12.jpg"
}
Response
404 (Not Found)
Content-Type: application/json
{
"error_message": "Not found",
"error_code": 10015,
"errors": []
}
/api/image/{id}
| Name | Description | Details |
|---|---|---|
| id | integer, required |
Show code sample
Response
200 (OK)
Content-Type: application/json
{
"id": 2,
"user": 1,
"type": 2,
"url": "/media/images/1351416403219_4.jpg"
}
Response
400 (Bad Request)
Content-Type: application/json
{
"errors": [
{
"field": "type",
"error_message": "Required data",
"error_code": 10001
}
],
"error_code": 10006,
"error_message": "Validation Failed"
}
Response
403 (Forbidden)
Content-Type: application/json
{
"error_message": "You do not have permission to perform this action.",
"error_code": 10014,
"errors": []
}
部分更新图片
PATCH
/api/image/{id}
| Name | Description | Details |
|---|---|---|
| id | integer, required |
Show code sample
Response
200 (OK)
Content-Type: application/json
{
"id": 14,
"user": null,
"type": 2,
"url": "/media/images/1351416403219_14.jpg"
}
Response
403 (Forbidden)
Content-Type: application/json
{
"error_message": "You do not have permission to perform this action.",
"error_code": 10014,
"errors": []
}
DELETE
/api/image/{id}
| Name | Description | Details |
|---|---|---|
| id | integer, required |
Show code sample
Response
204 (No Content)
Response
404 (Not Found)
Content-Type: application/json
{
"error_message": "Not found",
"error_code": 10015,
"errors": []
}
认证信息说明
此 API 不需要任何认证信息。
Response 参数说明
id:项目分类 ID
name:分类名称
获取项目分类
/api/crowdfunding/category/
Show code sample
Response
200 (OK)
Content-Type: application/json
[
{
"id": 1,
"name": "闽菜"
},
{
"id": 2,
"name": "徽菜"
},
{
"id": 3,
"name": "湘菜"
},
{
"id": 4,
"name": "浙菜"
},
{
"id": 5,
"name": "粤菜"
},
{
"id": 6,
"name": "苏菜"
},
{
"id": 7,
"name": "川菜"
},
{
"id": 8,
"name": "鲁菜"
},
{
"id": 9,
"name": "其他"
}
]
项目回馈描述
本 API 需要进行身份认证,请不要忘记在 Header 中添加 Token 信息。
Request 参数说明
project:整数类型, 项目 ID
content:字符串类型, 项目回馈描述内容
image(可选参数):整数类型,项目回馈描述图片 ID (请预先使用图片上传 API 上传图片得到图片 ID,上传图片时请正确选择图片类型为 项目回馈描述图片 ), 注意所使用的图片的所属用户必须和此次请求的用户一致,且图片不能没有所属用户,否则会报 Invalid image user (no user) 或 Invalid image user (other user) 错误
Response 参数说明
id:整数类型,项目回馈描述 ID
project:整数类型,同 Request 中的 project
content:字符串类型,同 Request 中的 content
image:整数类型或 null。当 Request 中没有提交 image 参数时,此处返回 null,而如果提交了 image 参数且成功创建对象,返回 201 状态,该值等于 Request 中的 image 的值。
添加项目回馈描述
添加项目回馈描述
/api/crowdfunding/feedback/
Show code sample
Response
201 (Created)
Content-Type: application/json
{
"id": 2,
"project": 1,
"content": "项目内容1",
"image": 6
}
Response
400 (Bad Request)
Content-Type: application/json
{
"errors": [
{
"field": "image",
"error_message": "Invalid image type",
"error_code": 10028
}
],
"error_code": 10006,
"error_message": "Validation Failed"
}
获取及修改删除项目回馈描述
获取项目回馈描述
/api/crowdfunding/feedback/{id}
| Name | Description | Details |
|---|---|---|
| id | 项目回馈描述 ID |
integer, required |
Show code sample
Response
200 (OK)
Content-Type: application/json
{
"id": 2,
"project": 1,
"content": "项目内容1",
"image": 6
}
Response
404 (Not Found)
Content-Type: application/json
{
"error_message": "Not found",
"error_code": 10015,
"errors": []
}
更新项目回馈描述
/api/crowdfunding/feedback/{id}
| Name | Description | Details |
|---|---|---|
| id | 项目回馈描述 ID |
integer, required |
Show code sample
Response
200 (OK)
Content-Type: application/json
{
"id": 2,
"project": 1,
"content": "项目内容修改版",
"image": 6
}
Response
400 (Bad Request)
Content-Type: application/json
{
"errors": [
{
"field": "content",
"error_message": "Required data",
"error_code": 10001
}
],
"error_code": 10006,
"error_message": "Validation Failed"
}
部分更新项目回馈描述
PATCH
/api/crowdfunding/feedback/{id}
| Name | Description | Details |
|---|---|---|
| id | 项目回馈描述 ID |
integer, required |
Show code sample
Response
200 (OK)
Content-Type: application/json
{
"id": 2,
"project": 1,
"content": "项目内容修改版111",
"image": 6
}
Response
400 (Bad Request)
Content-Type: application/json
{
"errors": [
{
"field": "project",
"error_message": "Invalid data",
"error_code": 10000
}
],
"error_code": 10006,
"error_message": "Validation Failed"
}
删除项目回馈描述
DELETE
/api/crowdfunding/feedback/{id}
| Name | Description | Details |
|---|---|---|
| id | 项目回馈描述 ID |
integer, required |
Show code sample
Response
204 (No Content)
Response
404 (Not Found)
Content-Type: application/json
{
"error_message": "Not found",
"error_code": 10015,
"errors": []
}
项目回馈描述 套餐方案
本 API 需要进行身份认证,请不要忘记在 Header 中添加 Token 信息。
Request 参数说明
project:整数类型, 项目 ID
money:浮点数类型,投资数额(单位:元)
limit:整数类型,名额限制(单位:人)
type:整数类型,投资类型
0: 普通赞助者
1: 合伙人
name:字符串类型,套餐名称
feedback:数组类型,项目回馈描述ID数组
Response 参数说明
id:整数类型,项目回馈描述套餐方案 ID
project:整数类型, 项目 ID,同 Request
money:浮点数类型,投资数额(单位:元),同 Request
limit:整数类型,名额限制(单位:人),同 Request
type:整数类型,投资类型,同 Request
name:字符串类型,套餐名称,同 Request
feedback:数组类型,项目回馈描述ID数组,同 Request
添加项目回馈描述 套餐方案
添加项目回馈描述 套餐方案
/api/crowdfunding/package/
Show code sample
Response
201 (Created)
Content-Type: application/json
{
"id": 6,
"project": 1,
"name": "阿斯蒂芬",
"money": 23.0,
"type": 1,
"limit": 23,
"feedback": [
1,
2
]
}
Response
400 (Bad Request)
Content-Type: application/json
{
"errors": [
{
"field": "money",
"error_message": "Required data",
"error_code": 10001
},
{
"field": "type",
"error_message": "Required data",
"error_code": 10001
},
{
"field": "limit",
"error_message": "Required data",
"error_code": 10001
}
],
"error_code": 10006,
"error_message": "Validation Failed"
}
获取及修改删除项目回馈描述 套餐方案
获取项目回馈描述 套餐方案
/api/crowdfunding/package/{id}
| Name | Description | Details |
|---|---|---|
| id | 项目回馈描述 套餐方案 ID |
integer, required |
Show code sample
Response
200 (OK)
Content-Type: application/json
{
"id": 4,
"project": 1,
"name": "????",
"money": 5.76,
"type": 0,
"limit": 20,
"feedback": [
1,
2
]
}
Response
404 (Not Found)
Content-Type: application/json
{
"error_message": "Not found",
"error_code": 10015,
"errors": []
}
更新项目回馈描述 套餐方案
/api/crowdfunding/package/{id}
| Name | Description | Details |
|---|---|---|
| id | 项目回馈描述 套餐方案 ID |
integer, required |
Show code sample
Response
200 (OK)
Content-Type: application/json
{
"id": 2,
"project": 1,
"name": "阿斯蒂芬",
"money": 23.0,
"type": 1,
"limit": 23,
"feedback": [
1,
2
]
}
Response
400 (Bad Request)
Content-Type: application/json
{
"errors": [
{
"field": "limit",
"error_message": "Invalid data",
"error_code": 10000
}
],
"error_code": 10006,
"error_message": "Validation Failed"
}
部分更新项目回馈描述
PATCH
/api/crowdfunding/package/{id}
| Name | Description | Details |
|---|---|---|
| id | 项目回馈描述 套餐方案 ID |
integer, required |
Show code sample
Response
200 (OK)
Content-Type: application/json
{
"id": 2,
"project": 1,
"name": "阿斯蒂芬",
"money": 23.0,
"type": 1,
"limit": 23,
"feedback": [
2
]
}
Response
400 (Bad Request)
Content-Type: application/json
{
"errors": [
{
"field": "project",
"error_message": "Invalid data",
"error_code": 10000
}
],
"error_code": 10006,
"error_message": "Validation Failed"
}
删除项目回馈描述 套餐方案
DELETE
/api/crowdfunding/package/{id}
| Name | Description | Details |
|---|---|---|
| id | 项目回馈描述 套餐方案 ID |
integer, required |
Show code sample
Response
204 (No Content)
Response
404 (Not Found)
Content-Type: application/json
{
"error_message": "Not found",
"error_code": 10015,
"errors": []
}
众筹项目有三个内容,分别为基本内容,项目回馈描述,项目回馈描述套餐方案。这套 API 仅供操作项目的基本内容,对于项目回馈描述及项目回馈描述套餐方案请参照上面它们各自对应的 API。
当利用项目回馈描述 API 和项目回馈描述套餐方案 API 创建对应的内容后,与之相关联的项目会直接响应到,不需要额外通知。
特别注意!!:当利用发布项目 API 新建一个项目后,默认状态为 草稿 状态,在此状态下,请利用项目回馈描述 API 和项目回馈描述套餐方案 API 新建相应信息,当所有信息都已经建立完毕,调用确认发布项目 API 来将项目状态更改为 待审核。
访问权限说明
获取项目 (GET) 不需要任何认证信息。
发布更新删除项目 (POST, PUT, PATCH, DELETE) 操作均需要认证信息,请不要忘记在 Header 中添加 Token 。
Request 参数说明
name:字符串类型,项目名称
cover:整数类型,项目封面图片 ID
location:整数类型,地理位置 ID
location_detail(可选参数):字符串类型,详细地址
category:整数类型,项目分类 ID
total_money:浮点数类型,筹款金额
total_days:整数类型,筹款天数
summary:字符串类型,项目简介
content:字符串类型,项目内容
tags(可选参数):数组类型,标签
Response 参数说明
(注:该参数说明为单个项目 Response 说明,多个项目返回的额外参数请参见下面的获取项目列表[GET]的说明)
id:整数类型,项目 ID
user:整数类型,项目发起人用户 ID
name:字符串类型,项目名称,同 Request
cover:整数类型,项目封面图片 ID,同 Request
location:整数类型,地理位置 ID,同 Request
location_detail:字符串类型,详细地址,同 Request
category:整数类型,项目分类 ID,同 Request
total_money:浮点数类型,筹款金额,同 Request
total_days:整数类型,筹款天数,同 Request
remaining_days:整数类型,距离截止日期的剩余天数,如果已过该日期,则为 0
summary:字符串类型,项目简介,同 Request
content:字符串类型,项目内容,同 Request
now_money:浮点数类型,已筹集金额
status:整数类型,项目的当前状态
0: 草稿
1: 等待审核
2: 审核失败
3: 进行中
4: 已成功
5: 已结束
6: 停滞中
attention_count:整数类型,项目的被关注数目
support_count:整数类型,项目的支持人数
normal_support_count:整数类型,普通支持人数(监督者)
partner_support_count:整数类型,合作者支持人数(管理人员)
tags:数组类型,项目的标签列表
post_datetime:日期类型,项目的发布时间
modify_datetime:日期类型,项目的最后修改时间
feedback:数组类型,项目的回馈描述 ID 列表
package:数组类型,项目的回馈描述套餐方案 ID 列表
personal_information:字典类型,显示当前用户和该项目的关联信息,有是否关注,是否支持,支持类型等,注意无身份信息提供时字典为空
is_attended: 布尔类型,表示当前用户是否关注了该项目
is_supported: 布尔类型,表示当前用户是否支持了该项目
support_type: 整数类型,表示当前用户对该项目的支持类型(无支持,普通,合作者)
-1: 无支持
0: 普通支持(监督者)
1: 合作者(管理人员)
关键参数说明
Request 和 Response 中的 tags:该参数为可选参数,如果没有提交该参数,则该项目没有标签,如果提交,请按照数组格式,如下:
"tags": ["tag 1", "tag 2", "tag 3"]
Response 中的 feedback 和 package:该返回结果仅供读取,且为对应的 ID ,示例如下:
"feedback": [
1,
2
],
"package": [
1
]
获取项目列表
当获取项目列表时,会对响应内容做分页处理,具体响应参数如下:
count:整数类型,查询结果总个数
next:字符串类型,下一页链接(如果当前已经是最后一页,则为 null)
previous:字符串类型,上一页链接(如果当前已经是第一页,则为 null)
results:数组类型,查询结果,数组中的每一项都为一个独立的项目 Response , 参见上面的 Response 参数说明 。
获取项目列表
/api/crowdfunding/project/{?id,user,name,location,category,status,ordering,search,page}
该 API 接收 GET 参数来满足多样化的查询结果,可任意组合获得自己需要的结果。
每个参数的含义参见下表 (在示例的下面!) ,这里提供几个示例查询:
/api/crowdfunding/project/?user=1&status=1&ordering=-post_datetime,id&search=美味
该请求在所有的项目中查询
- 用户 ID 为 1
- 项目状态为正在审核(1为正在审核)
- 排序按 post_datetime 字段(发布日期)逆序排序(注意 post_datetime 前面的负号),其次按项目 ID 排序(可以提供一个或多个排序标准,以排在前面的标准为主)
- 搜索内容为“美味”(只搜索项目名称)
如果有满足这些请求的项目,将会按照上面的多项目响应内容进行返回。
/api/crowdfunding/project/?user=1&ordering=-attention_count&search=test
该请求在所有项目中查询
- 用户 ID 为 1
- 按关注数目(attention_count)逆序排序
- 项目名称包含“test”
的所有项目。
| Name | Description | Details |
|---|---|---|
| id | integer, optional | |
| user | 项目发起人 ID |
integer, optional |
| name | string, optional | |
| location | 项目地理位置 ID |
integer, optional |
| category | 项目分类 ID |
integer, optional |
| status | 项目状态,值的内容参照上面的 Response 参数说明 |
integer, optional |
| ordering | 排序规则,可用排序字段为 post_datetime, name, attention_count |
string, optional |
| search | 搜索内容(仅搜索项目名称) |
string, optional |
| page | integer, optional |
Show code sample
Response
200 (OK)
Content-Type: application/json
{
"count": 1,
"next": null,
"previous": null,
"results": [
{
"id": 1,
"user": 1,
"name": "项目1",
"cover": 1,
"location": 1,
"location_detail": "项目地址",
"category": 1,
"total_money": 23,
"total_days": 32,
"remaining_days": 29,
"summary": "summary",
"content": "content",
"now_money": 23,
"status": 0,
"attention_count": 0,
"support_count": 1,
"normal_support_count": 1,
"partner_support_count": 0,
"tags": [ ],
"post_datetime": "2014-08-16T18:00:00Z",
"modify_datetime": "2014-05-08T22:22:22Z",
"feedback": [
1
],
"package": [
1,
2
],
"personal_information": { }
}
]
}
/api/crowdfunding/project/
Show code sample
Response
201 (Created)
Content-Type: application/json
{
"id": 2,
"user": 1,
"name": "项目test",
"cover": 1,
"location": 1,
"location_detail": "详细地址",
"category": 1,
"total_money": 1000.5,
"total_days": 5,
"remaining_days": 4,
"summary": "总结",
"content": "项目内容",
"now_money": 0,
"status": 0,
"attention_count": 0,
"support_count": 0,
"normal_support_count": 0,
"partner_support_count": 0,
"tags": [
"tag1",
"tag 2",
"tag3ff"
],
"post_datetime": "2014-08-19T12:36:44.100Z",
"modify_datetime": "2014-08-19T12:36:44.100Z",
"feedback": [ ],
"package": [ ],
"personal_information": {
"is_attended": false,
"support_type": -1,
"is_supported": false
}
}
Response
400 (Bad Request)
Content-Type: application/json
{
"errors": [
{
"field": "cover",
"error_message": "Invalid image type",
"error_code": 10028
}
],
"error_code": 10006,
"error_message": "Validation Failed"
}
获取及修改删除单个项目
获取单个项目
/api/crowdfunding/project/{id}
| Name | Description | Details |
|---|---|---|
| id | integer, required |
Show code sample
Response
200 (OK)
Content-Type: application/json
{
"id": 1,
"user": 1,
"name": "项目1",
"cover": 1,
"location": 1,
"location_detail": "项目地址",
"category": 1,
"total_money": 23,
"total_days": 32,
"remaining_days": 29,
"summary": "summary",
"content": "content",
"now_money": 23,
"status": 0,
"attention_count": 0,
"support_count": 1,
"normal_support_count": 1,
"partner_support_count": 0,
"tags": [ ],
"post_datetime": "2014-08-16T18:00:00Z",
"modify_datetime": "2014-05-08T22:22:22Z",
"feedback": [
1
],
"package": [
1,
2
],
"personal_information": {
"is_attended": true,
"support_type": 0,
"is_supported": true
}
}
Response
404 (Not Found)
Content-Type: application/json
{
"error_message": "Not found",
"error_code": 10015,
"errors": []
}
更新单个项目
/api/crowdfunding/project/{id}
| Name | Description | Details |
|---|---|---|
| id | integer, required |
Show code sample
Response
200 (OK)
Content-Type: application/json
{
"id": 1,
"user": 1,
"name": "项目testxxxx",
"cover": 1,
"location": 1,
"location_detail": "详细地址fffff",
"category": 1,
"total_money": 1002220.5,
"total_days": 5,
"remaining_days": 2,
"summary": "总结",
"content": "项目内容",
"now_money": 23,
"status": 0,
"attention_count": 0,
"support_count": 1,
"normal_support_count": 1,
"partner_support_count": 0,
"tags": [
"tag1tttt",
"tag 2",
"tag3ff"
],
"post_datetime": "2014-08-16T18:00:00Z",
"modify_datetime": "2014-08-19T12:39:10.098Z",
"feedback": [
1
],
"package": [
1,
2
],
"personal_information": {
"is_attended": true,
"support_type": 0,
"is_supported": true
}
}
Response
400 (Bad Request)
Content-Type: application/json
{
"errors": [
{
"field": "total_days",
"error_message": "Invalid data",
"error_code": 10000
}
],
"error_code": 10006,
"error_message": "Validation Failed"
}
部分更新单个项目
PATCH
/api/crowdfunding/project/{id}
| Name | Description | Details |
|---|---|---|
| id | integer, required |
Show code sample
Response
200 (OK)
Content-Type: application/json
{
"id": 1,
"user": 1,
"name": "项目testxxxx",
"cover": 1,
"location": 1,
"location_detail": "详细地址fffff",
"category": 1,
"total_money": 1002220.5,
"total_days": 5,
"remaining_days": 2,
"summary": "总结",
"content": "项目内容",
"now_money": 23,
"status": 0,
"attention_count": 0,
"support_count": 1,
"normal_support_count": 1,
"partner_support_count": 0,
"tags": [
"tag1tttt"
],
"post_datetime": "2014-08-16T18:00:00Z",
"modify_datetime": "2014-08-19T12:39:44.199Z",
"feedback": [
1
],
"package": [
1,
2
],
"personal_information": {
"is_attended": true,
"support_type": 0,
"is_supported": true
}
}
Response
400 (Bad Request)
Content-Type: application/json
{
"errors": [
{
"field": "cover",
"error_message": "Invalid image type",
"error_code": 10028
}
],
"error_code": 10006,
"error_message": "Validation Failed"
}
删除单个项目
DELETE
/api/crowdfunding/project/{id}
| Name | Description | Details |
|---|---|---|
| id | integer, required |
Show code sample
Response
204 (No Content)
Response
404 (Not Found)
Content-Type: application/json
{
"error_message": "Not found",
"error_code": 10015,
"errors": []
}
确认发布项目
确认发布项目
/api/crowdfunding/project/{id}/save/
Show code sample
Response
204 (No Content)
该 API 只针对当前登录用户使用,不能作为检查他人是否关注某个项目用途。
访问权限说明
所有操作均需要认证信息,请不要忘记在 Header 中添加 Token 。
获取项目关注状态
/api/crowdfunding/project/{id}/attention/
返回 HTTP 状态码 204 代表该用户已经关注该项目
返回 HTTP 状态码 404 代表该用户尚未关注该项目
| Name | Description | Details |
|---|---|---|
| id | integer, required |
Show code sample
Response
204 (No Content)
Response
404 (Not Found)
关注该项目
/api/crowdfunding/project/{id}/attention/
| Name | Description | Details |
|---|---|---|
| id | integer, required |
Show code sample
Response
204 (No Content)
Response
404 (Not Found)
Content-Type: application/json
{
"error_message": "Not found",
"error_code": 10015,
"errors": []
}
取消关注该项目
DELETE
/api/crowdfunding/project/{id}/attention/
| Name | Description | Details |
|---|---|---|
| id | integer, required |
Show code sample
Response
204 (No Content)
Response
404 (Not Found)
Content-Type: application/json
{
"error_message": "Not found",
"error_code": 10015,
"errors": []
}
项目完成后阶段
本 API 需要进行身份认证,请不要忘记在 Header 中添加 Token 信息。
Request 参数说明
project:整数类型, 项目 ID
title:整数类型, 阶段名称
description:字符串类型,阶段需求描述
status:整数类型,阶段状态
0: 尚未开始
1: 正在进行中
2: 已完成
order:整数类型,项目阶段顺序
Response 参数说明
id:整数类型,项目完成后阶段 ID
project:整数类型, 同 Request
title:整数类型, 同 Request
description:字符串类型,同 Request
status:整数类型,同 Request
order:整数类型,同 Request
获取及添加项目完成后阶段
获取单个项目所有的阶段信息
/api/crowdfunding/project/{id}/section/
| Name | Description | Details |
|---|---|---|
| id | integer, required |
Show code sample
Response
200 (OK)
Content-Type: application/json
[
{
"id": 1,
"project": 1,
"title": "title1",
"description": "description1",
"status": 1,
"order": 0
},
{
"id": 2,
"project": 1,
"title": "title1",
"description": "description1",
"status": 0,
"order": 1
},
{
"id": 3,
"project": 1,
"title": "title1",
"description": "description1",
"status": 0,
"order": 2
},
{
"id": 4,
"project": 1,
"title": "title1",
"description": "description1",
"status": 0,
"order": 3
},
{
"id": 5,
"project": 1,
"title": "title1",
"description": "description1",
"status": 0,
"order": 4
},
{
"id": 6,
"project": 1,
"title": "title",
"description": "description",
"status": 0,
"order": 1
}
]
添加项目完成后阶段
/api/crowdfunding/project/{id}/section/
| Name | Description | Details |
|---|---|---|
| id | integer, required |
Show code sample
Response
201 (Created)
Content-Type: application/json
{
"id": 6,
"project": 1,
"title": "title",
"description": "description",
"status": 0,
"order": 1
}
Response
400 (Bad Request)
Content-Type: application/json
{
"errors": [
{
"field": "status",
"error_message": "Required data",
"error_code": 10001
}
],
"error_code": 10006,
"error_message": "Validation Failed"
}
获取及修改删除项目完成后阶段
获取项目完成后阶段单个信息
/api/crowdfunding/project/section/{id}/
| Name | Description | Details |
|---|---|---|
| id | 项目完成后阶段 ID |
integer, required |
Show code sample
Response
200 (OK)
Content-Type: application/json
{
"id": 2,
"project": 1,
"title": "title1",
"description": "description1",
"status": 0,
"order": 1
}
Response
404 (Not Found)
Content-Type: application/json
{
"error_message": "Not found",
"error_code": 10015,
"errors": [ ]
}
更新项目完成后阶段单个信息
/api/crowdfunding/project/section/{id}/
| Name | Description | Details |
|---|---|---|
| id | 项目完成后阶段 ID |
integer, required |
Show code sample
Response
200 (OK)
Content-Type: application/json
{
"id": 2,
"project": 1,
"title": "title",
"description": "description",
"status": 1,
"order": 1
}
Response
400 (Bad Request)
Content-Type: application/json
{
"errors": [
{
"field": "status",
"error_message": "Required data",
"error_code": 10001
}
],
"error_code": 10006,
"error_message": "Validation Failed"
}
部分更新项目完成后阶段单个信息
PATCH
/api/crowdfunding/project/section/{id}/
| Name | Description | Details |
|---|---|---|
| id | 项目完成后阶段 ID |
integer, required |
Show code sample
Response
200 (OK)
Content-Type: application/json
{
"id": 2,
"project": 1,
"title": "title",
"description": "description",
"status": 1,
"order": 1
}
Response
400 (Bad Request)
Content-Type: application/json
{
"errors": [
{
"field": "status",
"error_message": "Invalid data",
"error_code": 10000
}
],
"error_code": 10006,
"error_message": "Validation Failed"
}
删除项目完成后阶段单个信息
DELETE
/api/crowdfunding/project/section/{id}/
| Name | Description | Details |
|---|---|---|
| id | 项目完成后阶段 ID |
integer, required |
Show code sample
Response
204 (No Content)
Response
404 (Not Found)
Content-Type: application/json
{
"error_message": "Not found",
"error_code": 10015,
"errors": [ ]
}
项目完成后任务
本 API 需要进行身份认证,请不要忘记在 Header 中添加 Token 信息。
Request 参数说明
project:整数类型, 项目 ID
section:整数类型,项目完成后阶段 ID
content:字符串描述,任务描述
status:整数类型,任务状态
0: 尚未开始
1: 正在进行中
2: 已完成
order:整数类型,项目任务顺序
Response 参数说明
id:整数类型,项目完成后任务 ID
project:整数类型,同 Request
section:整数类型,同 Request
content:字符串描述,同 Request
status:整数类型,同 Request
order:整数类型,同 Request
获取及添加项目完成后任务
获取单个项目完成后阶段的所有任务信息
/api/crowdfunding/project/section/{id}/task/
| Name | Description | Details |
|---|---|---|
| id | 项目完成后阶段 ID |
integer, required |
Show code sample
Response
200 (OK)
Content-Type: application/json
[
{
"id": 1,
"project": 1,
"section": 1,
"content": "content ssss",
"status": 0,
"order": 0
},
{
"id": 3,
"project": 1,
"section": 1,
"content": "content ssss",
"status": 0,
"order": 0
}
]
添加项目任务
/api/crowdfunding/project/section/{id}/task/
| Name | Description | Details |
|---|---|---|
| id | 项目完成后阶段 ID |
integer, required |
Show code sample
Response
201 (Created)
Content-Type: application/json
{
"id": 4,
"project": 1,
"section": 1,
"content": "content",
"status": 0,
"order": 1
}
Response
400 (Bad Request)
Content-Type: application/json
{
"errors": [
{
"field": "order",
"error_message": "Invalid data",
"error_code": 10000
}
],
"error_code": 10006,
"error_message": "Validation Failed"
}
获取及修改删除项目任务
获取单个项目任务
/api/crowdfunding/project/section/task/{id}/
| Name | Description | Details |
|---|---|---|
| id | 项目完成后任务 ID |
integer, required |
Show code sample
Response
200 (OK)
Content-Type: application/json
{
"id": 1,
"project": 1,
"section": 1,
"content": "content ssss",
"status": 0,
"order": 0
}
Response
404 (Not Found)
Content-Type: application/json
{
"error_message": "Not found",
"error_code": 10015,
"errors": [ ]
}
更新单个项目任务
/api/crowdfunding/project/section/task/{id}/
| Name | Description | Details |
|---|---|---|
| id | 项目完成后任务 ID |
integer, required |
Show code sample
Response
200 (OK)
Content-Type: application/json
{
"id": 1,
"project": 1,
"section": 1,
"content": "content",
"status": 1,
"order": 2
}
Response
400 (Bad Request)
Content-Type: application/json
{
"errors": [
{
"field": "order",
"error_message": "Invalid data",
"error_code": 10000
}
],
"error_code": 10006,
"error_message": "Validation Failed"
}
部分更新单个项目任务
PATCH
/api/crowdfunding/project/section/task/{id}/
| Name | Description | Details |
|---|---|---|
| id | 项目完成后任务 ID |
integer, required |
Show code sample
Response
200 (OK)
Content-Type: application/json
{
"id": 1,
"project": 1,
"section": 1,
"content": "content",
"status": 2,
"order": 2
}
Response
400 (Bad Request)
Content-Type: application/json
{
"errors": [
{
"field": "status",
"error_message": "Invalid data",
"error_code": 10000
}
],
"error_code": 10006,
"error_message": "Validation Failed"
}
删除单个项目任务
DELETE
/api/crowdfunding/project/section/task/{id}/
| Name | Description | Details |
|---|---|---|
| id | 项目完成后任务 ID |
integer, required |
Show code sample
Response
204 (No Content)
Response
404 (Not Found)
Content-Type: application/json
{
"error_message": "Not found",
"error_code": 10015,
"errors": [ ]
}
访问权限说明
获取评论 (GET) 不需要任何认证信息。
当匿名发布评论 (POST) 时,此 API 不需要任何认证信息。
当非匿名发布评论或对已发布评论进行修改删除 (POST,PUT,PATCH,DELETE) 时,需要提供认证信息,请不要忘记在 Header 中添加 Token。
Request 参数说明
type:字符串类型,说明该评论是匿名还是非匿名发布
normal: 非匿名发布
anonymous: 匿名发布
content:字符串类型,评论内容
parent(可选参数):评论父亲 ID,如果没有父亲 ID,不发送此项
Response 参数说明
id:整数类型,项目评论 ID
project:整数类型,评论所属项目 ID
user:整数类型或 null,当该评论为非匿名时,该值为发表评论的用户 ID;当该评论为匿名时,该值为 null
email:字符串类型或 null,当该评论为非匿名时,该值为发表评论的用户电子邮件地址;当该评论为匿名时,该值为 null
content:字符串类型,评论内容
datetime:日期类型,评论发表日期
parent:整数类型或 null,当该评论没有父亲时为 null,有父亲时为对应的评论父亲的评论 ID
children:数组类型,该评论的所有子评论,每个子评论的参数含义同本参数说明
获取单个项目所有评论及发布项目评论
获取项目所有评论
/api/crowdfunding/project/{id}/comment/
当获取项目列表时,会对响应内容做分页处理,具体响应参数如下:
count:整数类型,查询结果总个数
next:字符串类型,下一页链接(如果当前已经是最后一页,则为 null)
previous:字符串类型,上一页链接(如果当前已经是第一页,则为 null)
results:数组类型,查询结果,数组中的每一项都为一个独立的项目 Response , 参见上面的 Response 参数说明 。
| Name | Description | Details |
|---|---|---|
| id | integer, required |
Show code sample
Response
200 (OK)
Content-Type: application/json
{
"count": 4,
"next": null,
"previous": null,
"results": [
{
"id": 9,
"project": 2,
"user": 1,
"email": "admin@admin.com",
"content": "评论内容",
"datetime": "2014-07-28T08:22:00Z",
"parent": null,
"children": []
},
{
"id": 10,
"project": 2,
"user": 1,
"email": "admin@admin.com",
"content": "评论内容",
"datetime": "2014-07-28T08:43:12Z",
"parent": null,
"children": [
{
"id": 11,
"project": 2,
"user": null,
"email": null,
"content": "修改评论",
"datetime": "2014-07-28T08:55:35Z",
"parent": 10,
"children": [
{
"id": 13,
"project": 2,
"user": 1,
"email": "admin@admin.com",
"content": "评论内容",
"datetime": "2014-07-28T08:43:25Z",
"parent": 11,
"children": []
},
{
"id": 14,
"project": 2,
"user": 1,
"email": "admin@admin.com",
"content": "评论内容",
"datetime": "2014-07-28T08:43:27Z",
"parent": 11,
"children": [
{
"id": 15,
"project": 2,
"user": 1,
"email": "admin@admin.com",
"content": "评论内容",
"datetime": "2014-07-28T08:43:33Z",
"parent": 14,
"children": []
}
]
}
]
}
]
},
{
"id": 12,
"project": 2,
"user": 1,
"email": "admin@admin.com",
"content": "评论内容",
"datetime": "2014-07-28T08:43:18Z",
"parent": null,
"children": []
},
{
"id": 16,
"project": 2,
"user": 1,
"email": "admin@admin.com",
"content": "评论内容",
"datetime": "2014-07-28T08:45:31Z",
"parent": null,
"children": []
}
]
}
发布项目评论
/api/crowdfunding/project/{id}/comment/
| Name | Description | Details |
|---|---|---|
| id | integer, required |
Show code sample
Response
201 (Created)
Content-Type: application/json
{
"id": 16,
"project": 2,
"user": 1,
"email": "admin@admin.com",
"content": "评论内容",
"datetime": "2014-07-28T08:45:31.304Z",
"parent": null,
"children": []
}
Response
400 (Bad Request)
Content-Type: application/json
{
"errors": [
{
"field": "content",
"error_message": "Required data",
"error_code": 10001
}
],
"error_code": 10006,
"error_message": "Validation Failed"
}
获取及更新删除单个评论
获取单个评论
/api/crowdfunding/project/comment/{id}/
注意如果该评论含有子评论,会在 children 中包含全部的子评论。
| Name | Description | Details |
|---|---|---|
| id | integer, required |
Show code sample
Response
200 (OK)
Content-Type: application/json
{
"id": 11,
"project": 2,
"user": 1,
"email": "admin@admin.com",
"content": "评论内容",
"datetime": "2014-07-28T08:43:15Z",
"parent": null,
"children": [
{
"id": 13,
"project": 2,
"user": 1,
"email": "admin@admin.com",
"content": "评论内容",
"datetime": "2014-07-28T08:43:25Z",
"parent": 11,
"children": []
},
{
"id": 14,
"project": 2,
"user": 1,
"email": "admin@admin.com",
"content": "评论内容",
"datetime": "2014-07-28T08:43:27Z",
"parent": 11,
"children": [
{
"id": 15,
"project": 2,
"user": 1,
"email": "admin@admin.com",
"content": "评论内容",
"datetime": "2014-07-28T08:43:33Z",
"parent": 14,
"children": []
}
]
}
]
}
更新单个评论
/api/crowdfunding/project/comment/{id}/
| Name | Description | Details |
|---|---|---|
| id | integer, required |
Show code sample
Response
200 (OK)
Content-Type: application/json
{
"id": 11,
"project": 2,
"user": 1,
"email": "admin@admin.com",
"content": "修改评论",
"datetime": "2014-07-28T08:53:43.360Z",
"parent": 10,
"children": [
{
"id": 13,
"project": 2,
"user": 1,
"email": "admin@admin.com",
"content": "评论内容",
"datetime": "2014-07-28T08:43:25Z",
"parent": 11,
"children": []
},
{
"id": 14,
"project": 2,
"user": 1,
"email": "admin@admin.com",
"content": "评论内容",
"datetime": "2014-07-28T08:43:27Z",
"parent": 11,
"children": [
{
"id": 15,
"project": 2,
"user": 1,
"email": "admin@admin.com",
"content": "评论内容",
"datetime": "2014-07-28T08:43:33Z",
"parent": 14,
"children": []
}
]
}
]
}
部分更新单个评论
PATCH
/api/crowdfunding/project/comment/{id}/
| Name | Description | Details |
|---|---|---|
| id | integer, required |
Show code sample
Response
200 (OK)
Content-Type: application/json
{
"id": 11,
"project": 2,
"user": null,
"email": null,
"content": "修改评论",
"datetime": "2014-07-28T08:55:35.161Z",
"parent": 10,
"children": [
{
"id": 13,
"project": 2,
"user": 1,
"email": "admin@admin.com",
"content": "评论内容",
"datetime": "2014-07-28T08:43:25Z",
"parent": 11,
"children": []
},
{
"id": 14,
"project": 2,
"user": 1,
"email": "admin@admin.com",
"content": "评论内容",
"datetime": "2014-07-28T08:43:27Z",
"parent": 11,
"children": [
{
"id": 15,
"project": 2,
"user": 1,
"email": "admin@admin.com",
"content": "评论内容",
"datetime": "2014-07-28T08:43:33Z",
"parent": 14,
"children": []
}
]
}
]
}
删除单个评论
DELETE
/api/crowdfunding/project/comment/{id}/
| Name | Description | Details |
|---|---|---|
| id | integer, required |
Show code sample
Response
204 (No Content)
项目内部评论区主题
访问权限说明
只有发起者及已经支持该项目的用户有权限查看内部讨论区主题。
只有主题的发起者有权限更新删除自己的主题。
其他用户或未登录用户均无权限。
Request 参数说明
title:字符串类型,主题标题
content:字符串类型,主题内容
Response 参数说明
id:整数类型,内部讨论区主题 ID
project:整数类型,项目 ID
user:整数类型,用户 ID
title:字符串类型,同 Request
content:字符串类型,同 Request
post_datetime:日期类型,该主题发布时间
modify_datetime:日期类型,该主题最后修改时间
获取某个项目的所有主题或新建主题
获取某个项目的所有主题
/api/crowdfunding/project/{id}/topic/
当获取主题列表时,会对响应内容做分页处理,具体响应参数如下:
count:整数类型,查询结果总个数
next:字符串类型,下一页链接(如果当前已经是最后一页,则为 null)
previous:字符串类型,上一页链接(如果当前已经是第一页,则为 null)
results:数组类型,查询结果,数组中的每一项都为一个独立的项目 Response , 参见上面的 Response 参数说明 。
| Name | Description | Details |
|---|---|---|
| id | integer, required |
Show code sample
Response
200 (OK)
Content-Type: application/json
{
"count": 1,
"next": null,
"previous": null,
"results": [
{
"id": 1,
"project": 1,
"user": 1,
"title": "projecttopic",
"content": "project topic content",
"post_datetime": "2014-02-08T22:22:22Z",
"modify_datetime": "2014-02-09T22:22:22Z"
}
]
}
发布项目主题
/api/crowdfunding/project/{id}/topic/
| Name | Description | Details |
|---|---|---|
| id | integer, required |
Show code sample
Response
201 (Created)
Content-Type: application/json
{
"id": 2,
"project": 1,
"user": 1,
"title": "title",
"content": "content",
"post_datetime": "2014-08-19T12:09:09.407Z",
"modify_datetime": "2014-08-19T12:09:09.407Z"
}
Response
400 (Bad Request)
Content-Type: application/json
{
"errors": [
{
"field": "content",
"error_message": "Required data",
"error_code": 10001
},
{
"field": "title",
"error_message": "Required data",
"error_code": 10001
}
],
"error_code": 10006,
"error_message": "Validation Failed"
}
获取及更新删除单个主题
获取单个主题
/api/crowdfunding/project/topic/{id}/
| Name | Description | Details |
|---|---|---|
| id | 内部讨论区主题 ID |
integer, required |
Show code sample
Response
200 (OK)
Content-Type: application/json
{
"id": 1,
"project": 1,
"user": 1,
"title": "projecttopic",
"content": "project topic content",
"post_datetime": "2014-02-08T22:22:22Z",
"modify_datetime": "2014-02-09T22:22:22Z"
}
更新单个主题
/api/crowdfunding/project/topic/{id}/
| Name | Description | Details |
|---|---|---|
| id | 内部讨论区主题 ID |
integer, required |
Show code sample
Response
200 (OK)
Content-Type: application/json
{
"id": 1,
"project": 1,
"user": 1,
"title": "title",
"content": "content",
"post_datetime": "2014-02-08T22:22:22Z",
"modify_datetime": "2014-08-19T12:11:16.656Z"
}
部分更新单个主题
PATCH
/api/crowdfunding/project/topic/{id}/
| Name | Description | Details |
|---|---|---|
| id | 内部讨论区主题 ID |
integer, required |
Show code sample
Response
200 (OK)
Content-Type: application/json
{
"id": 1,
"project": 1,
"user": 1,
"title": "title",
"content": "content",
"post_datetime": "2014-02-08T22:22:22Z",
"modify_datetime": "2014-08-19T12:11:50.890Z"
}
删除单个主题
DELETE
/api/crowdfunding/project/topic/{id}/
| Name | Description | Details |
|---|---|---|
| id | 内部讨论区主题 ID |
integer, required |
Show code sample
Response
204 (No Content)
项目内部讨论区评论
访问权限说明
只有发起者及已经支持该项目的用户有权限查看内部讨论区评论。
只有评论的创建者有权限更新删除自己的评论。
其他用户或未登录用户均无权限。
Request 参数说明
content:字符串类型,评论内容
parent:(可选参数)整数类型,该评论的父评论 ID
Response 参数说明
id:整数类型,项目内部讨论区评论 ID
project:整数类型,项目 ID
topic:整数类型,项目内部讨论区主题 ID
user:整数类型,用户 ID
content:字符串类型,同 Request
datetime:日期类型,评论发布日期
parent:整数类型,父评论 ID
children:数组类型,该评论的所有子评论,每个子评论的参数含义同本参数说明
获取单个内部讨论区主题的所有评论或新建评论
获取单个主题的所有评论
/api/crowdfunding/project/topic/{id}/comment/
当获取评论列表时,会对响应内容做分页处理,具体响应参数如下:
count:整数类型,查询结果总个数
next:字符串类型,下一页链接(如果当前已经是最后一页,则为 null)
previous:字符串类型,上一页链接(如果当前已经是第一页,则为 null)
results:数组类型,查询结果,数组中的每一项都为一个独立的项目 Response , 参见上面的 Response 参数说明 。
| Name | Description | Details |
|---|---|---|
| id | 内部讨论区主题 ID |
integer, required |
Show code sample
Response
200 (OK)
Content-Type: application/json
{
"count": 2,
"next": null,
"previous": null,
"results": [
{
"id": 1,
"project": 1,
"topic": 1,
"user": 1,
"content": "comment content",
"datetime": "2014-02-02T22:22:22Z",
"parent": null,
"children": [
{
"id": 2,
"project": 1,
"topic": 1,
"user": 1,
"content": "comment content",
"datetime": "2014-02-02T22:22:22Z",
"parent": 1,
"children": [ ]
}
]
},
{
"id": 3,
"project": 1,
"topic": 1,
"user": 1,
"content": "comment content",
"datetime": "2014-02-02T22:22:22Z",
"parent": null,
"children": [ ]
}
]
}
/api/crowdfunding/project/topic/{id}/comment/
| Name | Description | Details |
|---|---|---|
| id | 内部讨论区主题 ID |
integer, required |
Show code sample
Response
201 (Created)
Content-Type: application/json
{
"id": 4,
"project": 1,
"topic": 1,
"user": 1,
"content": "content",
"datetime": "2014-08-19T12:24:33.706Z",
"parent": null,
"children": [ ]
}
Response
400 (Bad Request)
Content-Type: application/json
{
"errors": [
{
"field": "content",
"error_message": "Required data",
"error_code": 10001
},
{
"field": "parent",
"error_message": "Required data",
"error_code": 10001
}
],
"error_code": 10006,
"error_message": "Validation Failed"
}
获取及更新删除单个内部讨论区评论
获取单个评论
/api/crowdfunding/project/topic/comment/{id}/
注意如果该评论含有子评论,会在 children 中包含全部的子评论。
| Name | Description | Details |
|---|---|---|
| id | 内部讨论区评论 ID |
integer, required |
Show code sample
Response
200 (OK)
Content-Type: application/json
{
"id": 1,
"project": 1,
"topic": 1,
"user": 1,
"content": "comment content",
"datetime": "2014-02-02T22:22:22Z",
"parent": null,
"children": [
{
"id": 2,
"project": 1,
"topic": 1,
"user": 1,
"content": "comment content",
"datetime": "2014-02-02T22:22:22Z",
"parent": 1,
"children": [ ]
}
]
}
更新单个评论
/api/crowdfunding/project/topic/comment/{id}/
| Name | Description | Details |
|---|---|---|
| id | 内部讨论区评论 ID |
integer, required |
Show code sample
Response
200 (OK)
Content-Type: application/json
{
"id": 2,
"project": 1,
"topic": 1,
"user": 1,
"content": "content",
"datetime": "2014-02-02T22:22:22Z",
"parent": null,
"children": [ ]
}
部分更新单个评论
PATCH
/api/crowdfunding/project/topic/comment/{id}/
| Name | Description | Details |
|---|---|---|
| id | 内部讨论区评论 ID |
integer, required |
Show code sample
Response
200 (OK)
Content-Type: application/json
{
"id": 2,
"project": 1,
"topic": 1,
"user": 1,
"content": "content",
"datetime": "2014-02-02T22:22:22Z",
"parent": 1,
"children": [ ]
}
删除单个评论
DELETE
/api/crowdfunding/project/topic/comment/{id}/
| Name | Description | Details |
|---|---|---|
| id | 内部讨论区评论 ID |
integer, required |
Show code sample
Response
204 (No Content)
用户个人信息
获取及更新当前登录用户个人信息
该 API 需要身份信息认证,请不要忘记在 Header 中加入 Token。
该 API 可以获得当前登录用户的所有个人信息。
Request 参数说明
nickname:字符串类型,昵称
detailinfo:字典类型,包含用户详细信息,详细内容如下:
avatar:整数类型,用户头像图片 ID
name:字符串类型,用户姓名
sex:字符串类型,用户性别("u": 未知, "m": 男, "l": 女)
age:整数类型,用户年龄
native:整数类型,籍贯所在地 ID
profession:字符串类型,职业
idcard:字符串类型,身份证号码
idcard_image:整数类型,身份证图片 ID
mobile:字符串类型,手机号码
qq:字符串类型,QQ 号码
weibo:字符串类型,微博地址
blog:字符串类型,博客地址
fundinfo:字典类型,包含用户资金信息
alipay:字符串类型,用户支付宝地址
bank_name:字符串类型,开户行名称
bank_sub_name:字符串类型,支行名称
name:字符串类型,开户姓名
account:字符串类型,开户账号
Response 参数说明
id:整数类型,用户 ID
email:字符串类型,用户电子邮件地址
nickname:字符串类型,昵称
is_active:布尔类型,是否激活
is_staff:布尔类型,是否为管理员
is_authentication:布尔类型,是否认证
date_joined:日期类型,注册日期
detailinfo:字典类型,包含用户详细信息,详细内容如下:
avatar:整数类型,用户头像图片 ID
name:字符串类型,用户姓名
sex:字符串类型,用户性别("u": 未知, "m": 男, "l": 女)
age:整数类型,用户年龄
native:整数类型,籍贯所在地 ID
profession:字符串类型,职业
idcard:字符串类型,身份证号码
idcard_image:整数类型,身份证图片 ID
mobile:字符串类型,手机号码
qq:字符串类型,QQ 号码
weibo:字符串类型,微博地址
blog:字符串类型,博客地址
fundinfo:字典类型,包含用户资金信息
alipay:字符串类型,用户支付宝地址
bank_name:字符串类型,开户行名称
bank_sub_name:字符串类型,支行名称
name:字符串类型,开户姓名
account:字符串类型,开户账号
balanceinfo:字典类型,包含用户余额信息
- balance:浮点数类型,用户账户当前余额
projectinfo:字典类型,包含用户项目相关信息
launch:整数类型,已发起项目数目
attention:整数类型,已关注项目数目
support:整数类型,已支持项目数目
questioninfo:字典类型,包含用户问答相关信息
ask:整数类型,该用户提问数
answer:整数类型,该用户回答数
comment:整数类型,该用户评论数
vote:整数类型,该用户点赞数
获取当前登录用户个人信息
/api/accounts/user/
Show code sample
Response
200 (OK)
Content-Type: application/json
{
"id": 1,
"email": "admin@admin.com",
"nickname": "admin",
"is_active": true,
"is_staff": true,
"is_authentication": true,
"date_joined": "2014-07-26T07:44:57Z",
"detailinfo": {
"avatar": null,
"name": "测试名字",
"sex": "u",
"age": 20,
"native": 5,
"profession": "职业",
"idcard": "130984199509199999",
"idcard_image": null,
"mobile": "23444423",
"qq": "1234444",
"weibo": "http://weibo.com",
"blog": "http://blog.com"
},
"fundinfo": {
"alipay": "doraemonext@gmail.com",
"bank_name": "在战争中",
"bank_sub_name": "撒发生地方",
"name": "按时发生的",
"account": "23412342341234"
},
"balanceinfo": {
"balance": 0.0
},
"projectinfo": {
"launch": 0,
"attention": 0,
"support": 0
},
"questioninfo": {
"ask": 0,
"answer": 0,
"comment": 0,
"vote": 0
}
}
更新当前登录用户个人信息
/api/accounts/user/
Show code sample
Response
200 (OK)
Content-Type: application/json
{
"id": 1,
"email": "admin@admin.com",
"nickname": "测试昵称",
"is_active": true,
"is_staff": true,
"is_authentication": true,
"date_joined": "2014-07-26T07:44:57Z",
"detailinfo": {
"avatar": null,
"name": "更改测试瓶子",
"sex": "l",
"age": 20,
"native": 7,
"profession": "职业",
"idcard": "130984199509199999",
"idcard_image": null,
"mobile": "23444423",
"qq": "1234444",
"weibo": "http://weibo.com",
"blog": "http://blog.com"
},
"fundinfo": {
"alipay": "ttt@ttt.com",
"bank_name": "在战争中",
"bank_sub_name": "撒发生地方",
"name": "按时发生的",
"account": "2342342423423423"
},
"balanceinfo": {
"balance": 0.0
},
"projectinfo": {
"launch": 0,
"attention": 0,
"support": 0
},
"questioninfo": {
"ask": 0,
"answer": 0,
"comment": 0,
"vote": 0
}
}
Response
400 (Bad Request)
Content-Type: application/json
{
"errors": [
{
"field": "nickname",
"error_message": "Required data",
"error_code": 10001
}
],
"error_code": 10006,
"error_message": "Validation Failed"
}
部分更新当前登录用户个人信息
PATCH
/api/accounts/user/
Show code sample
Response
200 (OK)
Content-Type: application/json
{
"id": 1,
"email": "admin@admin.com",
"nickname": "测试昵称",
"is_active": true,
"is_staff": true,
"is_authentication": true,
"date_joined": "2014-07-26T07:44:57Z",
"detailinfo": {
"avatar": null,
"name": "更改测试瓶子",
"sex": "l",
"age": 20,
"native": 7,
"profession": "职业",
"idcard": "130984199509199999",
"idcard_image": null,
"mobile": "23444423",
"qq": "1234444",
"weibo": "http://weibo.com",
"blog": "http://blog.com"
},
"fundinfo": {
"alipay": "ttt@ttt.com",
"bank_name": "在战争中",
"bank_sub_name": "撒发生地方",
"name": "按时发生的",
"account": "2342342423423423"
},
"balanceinfo": {
"balance": 0.0
},
"projectinfo": {
"launch": 0,
"attention": 0,
"support": 0
},
"questioninfo": {
"ask": 0,
"answer": 0,
"comment": 0,
"vote": 0
}
}
获取其他用户个人信息
该 API 可以获得其他用户的部分个人信息,无需任何认证信息。
Response 参数说明
id:整数类型,用户 ID
email:字符串类型,用户电子邮件地址
nickname:字符串类型,昵称
detailinfo:字典类型,包含用户详细信息,详细内容如下:
avatar:整数类型,用户头像图片 ID
native:整数类型,籍贯所在地 ID
profession:字符串类型,职业
qq:字符串类型,QQ 号码
weibo:字符串类型,微博地址
blog:字符串类型,博客地址
获取其他用户个人信息
/api/accounts/user/{id}/
| Name | Description | Details |
|---|---|---|
| id | integer, required |
Show code sample
Response
200 (OK)
Content-Type: application/json
{
"id": 1,
"email": "admin@admin.com",
"nickname": "测试昵称",
"detailinfo": {
"avatar": null,
"native": 7,
"profession": "职业",
"qq": "1234444",
"weibo": "http://weibo.com",
"blog": "http://blog.com"
}
}
获取当前用户的发布项目列表
本 API 需要身份认证信息,请不要忘记在 Header 中添加 Token
获取当前用户的发布项目列表
/api/accounts/user/project/
Show code sample
Response
200 (OK)
Content-Type: application/json
[
{
id: 1,
user: 1,
name: "项目1",
cover: 1,
location: 1,
location_detail: "项目地址",
category: 1,
total_money: 23,
total_days: 32,
remaining_days: 29,
summary: "summary",
content: "content",
now_money: 23,
status: 0,
attention_count: 0,
support_count: 1,
normal_support_count: 1,
partner_support_count: 0,
tags: [],
post_datetime: "2014-08-16T18:00:00Z",
modify_datetime: "2014-05-08T22:22:22Z",
feedback: [
1
],
package: [
1,
2
],
personal_information: {
is_attended: true,
support_type: 0,
is_supported: true
}
}
]
获取当前用户的参与项目列表
本 API 需要身份认证信息,请不要忘记在 Header 中添加 Token
获取当前用户的参与项目列表
/api/accounts/user/project/support/
Show code sample
Response
200 (OK)
Content-Type: application/json
[
{
"id": 3,
"project": {
"id": 1,
"user": 1,
"name": "项目1",
"cover": 1,
"location": 1,
"location_detail": "项目地址",
"category": 1,
"total_money": 23,
"total_days": 32,
"remaining_days": 29,
"summary": "summary",
"content": "content",
"now_money": 23,
"status": 0,
"attention_count": 0,
"support_count": 1,
"normal_support_count": 1,
"partner_support_count": 0,
"tags": [],
"post_datetime": "2014-08-16T18:00:00Z",
"modify_datetime": "2014-05-08T22:22:22Z",
"feedback": [
1
],
"package": [
1,
2
],
"personal_information": {
"is_attended": true,
"support_type": 0,
"is_supported": true
}
},
"package": 1,
"money": 22,
"status": 0,
"datetime": "2014-05-06T11:11:02Z"
}
]
获取当前用户的关注项目列表
本 API 需要身份认证信息,请不要忘记在 Header 中添加 Token
获取当前用户的关注项目列表
/api/accounts/user/project/attention/
Show code sample
Response
200 (OK)
Content-Type: application/json
[
{
"id": 1,
"project": {
"id": 1,
"user": 1,
"name": "项目1",
"cover": 1,
"location": 1,
"location_detail": "项目地址",
"category": 1,
"total_money": 23,
"total_days": 32,
"remaining_days": 29,
"summary": "summary",
"content": "content",
"now_money": 23,
"status": 0,
"attention_count": 0,
"support_count": 0,
"normal_support_count": 0,
"partner_support_count": 0,
"tags": [],
"post_datetime": "2014-08-16T18:00:00Z",
"modify_datetime": "2014-05-08T22:22:22Z",
"feedback": [
1
],
"package": [
1,
2
],
"personal_information": {
"is_attended": true,
"support_type": -1,
"is_supported": false
}
},
"datetime": "2014-05-08T22:22:22Z"
}
]