バージョン | Laravel 8 |
---|---|
形式 | REST API |
認証ツール | passport |
テストツール | Postman |
Docs | Scribe 2 |
endpoint: http://18.177.202.240:8000/api
docs: http://18.177.202.240:8000/docs
Method | URI | Name | Action | Middleware |
---|---|---|---|---|
GET | HEAD | / | Closure | |
GET | HEAD | api/games | games.index | App\Http\Controllers\GameController@index |
auth:api | ||||
POST | api/games | games.store | App\Http\Controllers\GameController@store | api |
auth:api | ||||
GET | HEAD | api/games/{game} | games.show | App\Http\Controllers\GameController@show |
auth:api | ||||
PUT | PATCH | api/games/{game} | games.update | App\Http\Controllers\GameController@update |
auth:api | ||||
DELETE | api/games/{game} | games.destroy | App\Http\Controllers\GameController@destroy | api |
auth:api | ||||
GET | HEAD | api/games/{id} | App\Http\Controllers\GameController@show | |
POST | api/login | App\Http\Controllers\AuthController@login | api | |
POST | api/logout | Closure | api | |
auth:api | ||||
POST | api/signup | App\Http\Controllers\AuthController@signup | api | |
GET | HEAD | api/user | Closure | |
auth:api |
Middleware は auth:api
である場合、Authorization は Bearer Auth
に token の設定が必要です。
HEADER設定
Accept: application/json
返信はOKの場合、一部共通の内容は下記通りです。
{
"success": true,
"data": ...,
"msg": ""
}
実用例にはdata
の中身だけを記入します。
登録: api/signup 送信:
{
"username": "lorem_ipsum",
"email": "lorem@ipsum.com",
"password": "******",
"r_password": "******"
}
返信:201 Created, 共通内容と違う
{
"name": "lorem_ipsum",
"email": "lorem@ipsum.com",
"updated_at": "2021-03-05T00:30:27.000000Z",
"created_at": "2021-03-05T00:30:27.000000Z",
"id": 3
}
ログイン: api/login 送信:
{
"email": "example@email.com",
"password": "******"
}
返信:
{
"token": "...",
"username": "hanabinoir"
}
ログアウト: api/logout 送信:token 以外は必要なし 返信:200 OK で内容はなし
全表示: games.index 送信:api/games 返信:
[
...,
{
"asin": "B07L2YXZZM",
"title": "戦国無双4",
"price": 24.51,
"created_at": "2021-03-05T00:43:23.000000Z",
"updated_at": "2021-03-05T00:52:56.000000Z"
},
...
]
表示: games.show 送信:api/games/B08NJXN756 返信:
{
"asin": B08NJXN756,
"title": "仁王2 Complete Edition",
"price": 52.18,
"created_at": "2021-03-05T00:38:38.000000Z",
"updated_at": "2021-03-05T00:38:38.000000Z"
}
追加: games.store 送信:
{
"asin": "B08NJXN756",
"title": "仁王2 Complete Edition",
"price": 52.18
}
返信:
{
"asin": B08NJXN756,
"title": "仁王2 Complete Edition",
"price": 52.18,
"updated_at": "2021-03-05T00:38:38.000000Z",
"created_at": "2021-03-05T00:38:38.000000Z"
}
更新: games.update 送信:api/games/B07L2YXZZM
{
"title": "戦国無双4",
"price": 24.51
}
返信:
{
"asin": "B07L2YXZZM",
"title": "戦国無双4",
"price": 24.51,
"created_at": "2021-03-05T00:43:23.000000Z",
"updated_at": "2021-03-05T00:52:56.000000Z"
}
削除: games.destroy 送信:api/games/B123456789 返信:
"Game deleted: B123456789."