API設計ガイドライン

RESTful URL

  • GET /tickets
  • GET /tickets/12
  • POST /tickets
  • PUT /tickets/12
  • PATCH /tickets/12
  • DELETE /tickets/12

Documents

Swggaer Docの利用 (Rails 利用時)

Version

/v1/tickets

Query

Filter
GET /tickets?state=open

Sort
GET /tickets?sort=-priority

Search
GET /tickets?q=return

Format

JSON

Naming

Snake case

Request body

{
        "id" : 123,
        "name" : "John"
}

Paging

/posts?page=3&offset=10

Auth

Response header

Status code

200 OK
201 Created
204 No Content
400 Bad Request
401 Unauthorized
403 Forbidden
404 Not Found
405 Method Not Allowed

Error

Invalid status code

Response body

{
  "code" : 1234,
  "message" : "Something bad happened :(",
  "description" : "More details about the error here"
}

タイトルとURLをコピーしました