所有接口的返回格式都是统一的,如下方所示:
{
"success": true,
"message": null,
"data": null
}
所有接口的数据都被上方的JSON格式包裹,success和message说明了本次接口调用的成功状态和提示信息,data是当前接口的返回的数据。
-
success: 数据状态, true代表成功,false返回失败。如果是false则message会有错误信息。
-
message: 提示信息,一般当success返回false时会包含错误信息,其他情况参考接口文档定义。
- data: 接口返回的数据信息,每个接口不一样,具体参考接口文档定义。
以毒鸡汤举例,接口正常返回如下,可以拿到内容content和点击量hits:
{
"success": true,
"message": null,
"data": {
"content": "不要等明天交不上差,再找借口,今天就要找好。",
"hits": 23543
}
}
接口错误信息返回如下,可以知道报错原因message:
{
"success": false,
"message": "无效的API KEY",
"data": null
}