🎏

Homie API詳細

2022/09/30に公開約7,700字

FastAPIでの実装

自分のアカウント関連

新規登録(/user/)

詳細

/user/

CURL
curl -X 'POST' \
  'http://127.0.0.1:8000/user/' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "username": "testUser001",
  "password": "testUser001",
  "disabled": false
}'
RESPONSE
{
  "password": "$2b$12$c6Y7TN3/vV.hKaEq.fR.l.odxp7T4/.7WTxEWdCSTaqnnJCduVnq.",
  "disable": false,
  "username": "testUser001",
  "level": 1,
  "uuid": "a2cdeb98-d6de-482a-991d-c233e5c47566"
}

ログイン(/token)

詳細

/token

CURL
curl -X 'POST' \
  'http://127.0.0.1:8000/token' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -d 'grant_type=&username=testUser001&password=testUser001&scope=&client_id=&client_secret='
RESPONSE
{
  "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ0ZXN0VXNlcjAwMSIsImV4cCI6MTY2NDU0MTU5MX0.fFHxOrnT8aA_CME4LhaNm11nPE37RO5EAHlaAwuRGgs",
  "token_type": "bearer"
}

UserName判定(/user/name_judge/{UserName}/)

詳細

/user/name_judge/{UserName}/

CURL
curl -X 'GET' \
  'http://127.0.0.1:8000/user/name_judge/testUser001/' \
  -H 'accept: application/json'
RESPONSE_0
"すでに存在しているユーザーネームです。"
RESPONSE_1
"このユーザーネームは使用できます。"

Profile作成(/profile/)

詳細

/profile/

CURL
curl -X 'POST' \
  'http://127.0.0.1:8000/profile/' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ0ZXN0VXNlcjAwMSIsImV4cCI6MTY2NDU0MTUwOX0.QrZ2WsVa10Yotr3sGsbZs7rBa0mY7tbl_3_L3QpfXig' \
  -H 'Content-Type: application/json' \
  -d '{
  "fullname": "testUser001",
  "mail": "shouhei.k224k@keio.jp",
  "birth": "2002-09-30",
  "imageurl": "string"
}'
RESPONSE
{
  "id": 1,
  "mail": "shouhei.k224k@keio.jp",
  "imageurl": "string",
  "fullname": "testUser001",
  "uuid": "a2cdeb98-d6de-482a-991d-c233e5c47566",
  "birth": "2002-09-30T00:00:00"
}

Profile編集(/profile/change)

詳細

/profile/change

CURL
curl -X 'PUT' \
  'http://127.0.0.1:8000/profile/change' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ0ZXN0VXNlcjAwMSIsImV4cCI6MTY2NDU0MTUwOX0.QrZ2WsVa10Yotr3sGsbZs7rBa0mY7tbl_3_L3QpfXig' \
  -H 'Content-Type: application/json' \
  -d '{
  "fullname": "testUser001",
  "mail": "shouhei.k224k@keio.jp",
  "birth": "2002-09-30",
  "imageurl": "string"
}'
RESPONSE_0
{}

メール認証のための送信(/validate)

詳細

/validate

CURL
curl -X 'GET' \
  'http://127.0.0.1:8000/validate' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ0ZXN0VXNlcjAwMSIsImV4cCI6MTY2NDU0MTUwOX0.QrZ2WsVa10Yotr3sGsbZs7rBa0mY7tbl_3_L3QpfXig'
RESPONSE
"Mail Sent"

自分のuser情報取得(users/me/)

詳細

users/me/

CURL
curl -X 'GET' \
  'http://127.0.0.1:8000/users/me/' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ0ZXN0VXNlcjAwMSIsImV4cCI6MTY2NDU0MTUwOX0.QrZ2WsVa10Yotr3sGsbZs7rBa0mY7tbl_3_L3QpfXig'
RESPONSE
{
  "id": "a2cdeb98-d6de-482a-991d-c233e5c47566",
  "level": 3,
  "username": "testUser001"
}

自分のProfile情報取得(users/me/profile)

詳細

users/me/profile

CURL
curl -X 'GET' \
  'http://127.0.0.1:8000/users/me/profile' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ0ZXN0VXNlcjAwMSIsImV4cCI6MTY2NDU0MTUwOX0.QrZ2WsVa10Yotr3sGsbZs7rBa0mY7tbl_3_L3QpfXig'
RESPONSE
{
  "mail": "shouhei.k224k@keio.jp",
  "id": 1,
  "imageurl": "string",
  "birth": "2002-09-30T00:00:00",
  "uuid": "a2cdeb98-d6de-482a-991d-c233e5c47566",
  "fullname": "testUser001"
}

フレンド関連

Friend申請(friend/request/{username})

詳細

friend/request/{username}

CURL
curl -X 'POST' \
  'http://127.0.0.1:8000/friend/request/testUser001' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ0ZXN0VXNlcjAwMSIsImV4cCI6MTY2NDU0NjQxOX0.LiPuluUnJfuIRS47cE7BUN6HPjd_36HJ6E-TJzxb3qY' \
  -d ''
RESPONSE_自分にやった場合
{
  "detail": "これはあなたのユーザーネームです。"
}
RESPONSE_他人にやった場合 (まだ)
"フレンド申請が送られました。"
RESPONSE_存在しない人にやった場合
{
  "detail": "存在しないユーザーです。"
}

Friend申請リスト取得(friend/request/list/)

詳細

friend/request/list/

CURL
curl -X 'GET' \
  'http://127.0.0.1:8000/friend/request/list/' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ0ZXN0VXNlcjAwMSIsImV4cCI6MTY2NDU0ODMxMn0.17J9oewtYIb0706Jpg_T8bg3J08fuiYjthnoCShm0rU'
RESPONSE_きてない場合
"まだ申請が来ていません。"
RESPONSE_きている場合
{
  "request1": "cba409e5-8005-4ade-87b8-5f443d5f5cc5"
}

Friend申請許可(friend/request/list/)

詳細

friend/request/list/

CURL_許可
curl -X 'POST' \
  'http://127.0.0.1:8000/friend/request/approval/1' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ0ZXN0VXNlcjAwMSIsImV4cCI6MTY2NDU0ODMxMn0.17J9oewtYIb0706Jpg_T8bg3J08fuiYjthnoCShm0rU' \
  -H 'Content-Type: application/json' \
  -d '{
  "response": true
}'
CURL_不許可
curl -X 'POST' \
  'http://127.0.0.1:8000/friend/request/approval/1' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ0ZXN0VXNlcjAwMSIsImV4cCI6MTY2NDU0ODMxMn0.17J9oewtYIb0706Jpg_T8bg3J08fuiYjthnoCShm0rU' \
  -H 'Content-Type: application/json' \
  -d '{
  "response": false
}'
RESPONSE_まだ

Friend取得(friend/list/) 未実装

詳細

friend/request/list/

CURL
curl -X 'GET' \
  'http://127.0.0.1:8000/friend/list/' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ0ZXN0VXNlcjAwMSIsImV4cCI6MTY2NDU0ODMxMn0.17J9oewtYIb0706Jpg_T8bg3J08fuiYjthnoCShm0rU'
RESPONSE_まだ

Friend削除(friend/{friendID}) 未実装

詳細

friend/{friendID}

CURL
RESPONSE

Friend削除(friend/{friendID}) 未実装

詳細

friend/{friendID}

CURL
RESPONSE

マップ関連

Pin投稿(/pin)

詳細

/pin

CURL
curl -X 'POST' \
  'http://127.0.0.1:8000/pin' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ0ZXN0VXNlcjAwMSIsImV4cCI6MTY2NDU0ODMxMn0.17J9oewtYIb0706Jpg_T8bg3J08fuiYjthnoCShm0rU' \
  -H 'Content-Type: application/json' \
  -d '{
  "comment": "コメントだお!004",
  "longitude": 0,
  "latitude": 0,
  "address": "これは住所です",
  "url": "string"
}'
RESPONSE
[
  {
    "latitude": 0,
    "user": "a2cdeb98-d6de-482a-991d-c233e5c47566",
    "address": "これは住所です",
    "url": "string",
    "longitude": 0,
    "id": 1,
    "comment": "コメントだお!"
  },
  {
    "latitude": 0,
    "user": "a2cdeb98-d6de-482a-991d-c233e5c47566",
    "address": "これは住所です",
    "url": "string",
    "longitude": 0,
    "id": 2,
    "comment": "コメントだお!002"
  },
  {
    "latitude": 0,
    "user": "a2cdeb98-d6de-482a-991d-c233e5c47566",
    "address": "これは住所です",
    "url": "string",
    "longitude": 0,
    "id": 3,
    "comment": "コメントだお!003"
  },
  {
    "latitude": 0,
    "user": "a2cdeb98-d6de-482a-991d-c233e5c47566",
    "address": "これは住所です",
    "url": "string",
    "longitude": 0,
    "id": 4,
    "comment": "コメントだお!004"
  }
]

Pin削除(pin/{pinID}) 未実装

詳細

pin/{pinID}

CURL
RESPONSE

FriendのPin取得(pin/list) 未実装

詳細

pin/list

CURL
RESPONSE

Discussion

ログインするとコメントできます