[关闭]
@Humbert 2019-03-20T07:01:37.000000Z 字数 2392 阅读 583

记忆API文档

Host: 39.108.79.110:3125

注册

Method URL Header
POST /api/signup/ None

POST BODY

  1. {
  2. "username": "string", // 30个英文字符或15个汉字之内
  3. "password": "string", // 30个字符之内
  4. "email": "string" // 30个字符之内
  5. }

Responses

  1. 201: Created
  2. {
  3. "msg": "ok"
  4. }
  5. 403: Forbidden 用户名或邮箱重复
  6. {
  7. "msg": "username|email duplicated"
  8. // "username duplicated" 或 "email duplicated"
  9. }

登录

Method URL Header
POST /api/signin/ None

POST BODY

  1. {
  2. "username": "string",
  3. "password": "string"
  4. }

Responses

  1. 200: OK
  2. {
  3. "msg": "ok",
  4. "user_id": 1
  5. }
  6. 403: Forbidden 用户名或密码错误
  7. {
  8. "msg": "login error"
  9. }

获取用户信息

Method URL Header
GET /api/myinfo/ Token

此处Token直接传user_id即可.

Response

  1. 200: OK
  2. {
  3. "avatar": "http://picture.com/",
  4. "score": 100,
  5. "blank_type": "格式", // "粗体" "斜体" "下划线"
  6. }
  7. 403: Forbidden 无权限

获取全部tags

Method URL Header
GET /api/tags/ Token

获取所有分类.

Response

  1. {
  2. "tags": [
  3. {
  4. "tag_id": 1,
  5. "tag_name": "string"
  6. },
  7. {
  8. "tag_id": 2,
  9. "tag_name": "string"
  10. },
  11. ]
  12. }

获取全部碎片

Method URL Header
GET /api/fragments/ Token

Response

  1. 200: OK
  2. {
  3. "fragments": [
  4. {
  5. "id": 1,
  6. "title": "string",
  7. "content": "string",
  8. "tags": ["tag1", "tag2", "tag3" ...]
  9. },
  10. {
  11. "id": 2,
  12. "title": "string",
  13. "content": "string",
  14. "tags": ["tag1", "tag2", "tag3" ...]
  15. },
  16. {
  17. "id": 1,
  18. "title": "string",
  19. "content": "string",
  20. "tags": ["tag1", "tag2", "tag3" ...]
  21. },
  22. ......
  23. ]
  24. }
  25. 403: Forbidden

获取某个tag下的碎片

Method URL Header
GET /api/fragments/<int:tag_id>/ Token

Response

  1. 200: OK
  2. {
  3. "fragments": [
  4. {
  5. "id": 1,
  6. "title": "string",
  7. "content": "string",
  8. "tags": ["tag1", "tag2", "tag3" ...]
  9. },
  10. {
  11. "id": 2,
  12. "title": "string",
  13. "content": "string",
  14. "tags": ["tag1", "tag2", "tag3" ...]
  15. },
  16. {
  17. "id": 1,
  18. "title": "string",
  19. "content": "string",
  20. "tags": ["tag1", "tag2", "tag3" ...]
  21. },
  22. ......
  23. ]
  24. }
  25. 403: Forbidden

创建碎片

Method URL Header
POST /api/fragments/ Token

POST BODY

  1. {
  2. "title": "标题",
  3. "content": "内容内容内容内容内容",
  4. "blanks": [
  5. {
  6. "start_index": 10,
  7. "end_index": 20,
  8. "content": "十个字十个字十个字十"
  9. },
  10. {
  11. "start_index": 30,
  12. "end_index": 40,
  13. "content": "十个字十个字十个字十"
  14. },
  15. ... ...
  16. ],
  17. "tags": ["tag1", "tag2"... ...]
  18. }

Response

  1. 200: OK
  2. {
  3. "msg": "ok"
  4. }

修改碎片

Method URL Header
PUT /api/fragments/<int:fragments_id>/ Token

POST BODY

  1. {
  2. "title": "标题",
  3. "content": "内容内容内容内容内容",
  4. "blanks": [
  5. {
  6. "start_index": 10,
  7. "end_index": 20,
  8. "content": "十个字十个字十个字十"
  9. },
  10. {
  11. "start_index": 30,
  12. "end_index": 40,
  13. "content": "十个字十个字十个字十"
  14. },
  15. ... ...
  16. ],
  17. "tags": ["tag1", "tag2"... ...]
  18. }

Response

  1. 200: OK
  2. 404: Not Found

获取碎片详情

获取碎片详情之后,前端比较来确定正确与错误

Method URL Header
GET /api/fragments/detail/<int:fragments_id>/ Token

Response

  1. {
  2. "title": "标题",
  3. "content": "内容内容内容内容内容",
  4. "blanks": [
  5. {
  6. "start_index": 10,
  7. "end_index": 20,
  8. "content": "十个字十个字十个字十"
  9. },
  10. {
  11. "start_index": 30,
  12. "end_index": 40,
  13. "content": "十个字十个字十个字十"
  14. },
  15. ... ...
  16. ],
  17. "tags": ["tag1", "tag2"... ...]
  18. }

给用户加分

Method URL Header
POST /api/user/score/ Token

POST DATA

  1. {
  2. "score": 10
  3. }

Response

  1. 200: ok
  2. 403: Forbidden
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注