RESTful API Design Guide
RESTful API 设计规范
充分理解RESTful API, 并严格遵循RESTful API的设计规范 例如:
- GET /tickets - 获取 tickets 列表
- GET /tickets/12 - 获取一个单独的 ticket
- POST /tickets - 创建一个新的 ticket
- PUT /tickets/12 - 更新 ticket #12
- PATCH /tickets/12 - 部分更新 ticket #12
- DELETE /tickets/12 - 删除 ticket #12
充分理解HTTP协议,在设计API时遵循HTTP协议 例如:
- 1xx: Infomational
- 2xx: Success
- 200 OK
- 201 Created
- 204 No Content
- 3xx: Redirection
- 301 Moved Permanently
- 302 Found
- 304 Not Modified
- 4xx: Client Error
- 400 Bad Request
- 401 Unauthorized
- 403 Forbidden
- 404 Not Found
- 405 Method Not Allowed
- 5xx: Server Error
- 500 Internal Server Error
- 两种基本结构:键值对,数组
- 数据结构:object, array, value, string, number
可参考: