Values wrapped in < >
are placeholders for what the field values should be. Also be sure to read the request route carefully when you implement it.
http://34.86.144.120/
POST /api/users/register/
Request:
{
"name": "Alvaro Deras",
"username": "aaderas",
"email": "[email protected]",
"password": "pass"
}
Response:
{
"session_token": <session_token>,
"session_expiration": <session_expiration>,
"refresh_token": <refresh_token>
}
POST /api/users/login/
Request:
{
"username": "aaderas",
"password": "pass"
}
Response:
{
"session_token": <session_token>,
"session_expiration": <session_expiration>,
"refresh_token": <refresh_token>
}
POST /api/users/logout/
Request Header:
Key | Value |
---|---|
Authorization | Bearer <session_token> |
Response:
{ "message": "You have been logged out" }
Note:
- If no user is found:
{"message": "Invalid session token"}
- If user's session token is invalid:
{"message": "Invalid session token"}
POST /api/users/session/
Request Header:
Key | Value |
---|---|
Authorization | Bearer <refresh_token> |
Response:
{
"session_token": <session_token>,
"session_expiration": <new session_expiration>,
"refresh_token": <refresh_token>
}
GET /api/users/
Response:
{
"users": [
{
"id": 1,
"name": "Alvaro Deras",
"username": "aaderas",
"email": "[email protected]",
"pfp": <IMAGE URL (IF USER PROVIDED PFP)>,
"posts": [<SERIALIZED POST>],
"conversations": [<SERIALIZED CONVERSATION>]
},
...
]
}
GET /api/users/<user_id>/
Response:
{
"id": 1,
"name": "Alvaro Deras",
"username": "aaderas",
"email": "[email protected]",
"pfp": <IMAGE URL (IF USER PROVIDED PFP)>,
"posts": [<SERIALIZED POST>],
"conversations": [<SERIALIZED CONVERSATION>]
}
POST /api/users/edit/
Request Header:
Key | Value |
---|---|
Authorization | Bearer <session_token> |
Request:
{
"name": <USER INPUT (OPTIONAL)>,
"username": <USER INPUT (OPTIONAL)>,
"email": <USER INPUT (OPTIONAL)>,
"pfp": <USER INPUT (OPTIONAL - MUST BE BASE64 ENCODED)>,
"password": <USER INPUT (OPTIONAL)>
}
Response:
{
"id": <ID>,
"name": <USER INPUT OR PREVIOUS NAME IF NOT PROVIDED>,
"username": <USER INPUT OR PREVIOUS USERNAME IF NOT PROVIDED>,
"email": <USER INPUT OR PREVIOUS EMAIL IF NOT PROVIDED>,
"pfp": <IMAGE URL OR PREVIOUS IMAGE URL IF NOT PROVIDED>,
"posts": [<SERIALIZED POST>],
"conversations": [<SERIALIZED CONVERSATION>]
}
Note:
- The edit user endpoint works by editing the user that is currently logged in with a session token.
DELETE /api/users/delete/
Request Header:
Key | Value |
---|---|
Authorization | Bearer <session_token> |
Response:
{
"id": <ID>,
"name": <NAME> ,
"username": <USERNAME>,
"email": <EMAIL>,
"pfp": <IMAGE URL>,
"posts": [<SERIALIZED POST>],
"conversations": [<SERIALIZED CONVERSATION>]
}
Note:
- The delete user endpoint works by deleting the user that is currently logged in with a session token.
GET /api/users/<user_id>/posts/
Response:
{
"posts": [<SERIALIZED POST>]
}
GET /api/posts/
Response:
{
"posts": [
{
"id": 1,
"title": "Found these AirPods",
"image": <IMAGE URL (IF IMAGE WAS PROVIDED)>,
"item": "AirPods",
"status": "Lost",
"text": "I found these yesterday - message me if they are yours!",
"location": "Morrison Dining Hall",
"timestamp": "2022-09-20 10:27:21.240752",
"user_id": 1
},
...
]
}
Note:
- Timestamp is a String representation of the DateTime object, and it is the time the post was created.
GET /api/posts/<post_id>/
Response:
{
"id": <ID>,
"title": <TITLE>,
"image": <IMAGE URL (IF IMAGE WAS PROVIDED)>,
"item" <ITEM>:,
"status": <STATUS>,
"text": <TEXT>,
"location": <LOCATION>,
"timestamp": <TIMESTAMP>,
"user_id" <USER_ID>:
}
POST /api/posts/
Request Header:
Key | Value |
---|---|
Authorization | Bearer <session_token> |
Request:
{
"title": <USER INPUT>,
"image": <USER INPUT (OPTIONAL - MUST BE BASE64 ENCODED)>,
"item": <USER INPUT>,
"status": <USER INPUT>,
"text": <USER INPUT (OPTIONAL)>,
"location": <USER INPUT>,
}
Response:
{
"id": <ID>,
"title": <USER INPUT>,
"image": <IMAGE URL OR NULL IF NOT PROVIDED>,
"item": <USER INPUT>,
"status": <USER INPUT>,
"text": <USER INPUT OR NULL IF NOT PROVIDED>,
"location": <USER INPUT>,
"timestamp": <NOW>,
"user_id": <USER_ID>
}
Note:
- Timestamp is the string representation of the DateTime object at the time the post is created.
POST /api/posts/<post_id>/
Request Header:
Key | Value |
---|---|
Authorization | Bearer <session_token> |
Request:
{
"title": <USER INPUT (OPTIONAL)>,
"image": <USER UNPUT (OPTIONAL - MUST BE BASE64 ENCODED)>,
"item": <USER INPUT (OPTIONAL)>,
"status": <USER INPUT (OPTIONAL)>,
"text": <USER INPUT (OPTIONAL)>,
"location": <USER INPUT (OPTIONAL)>,
}
Response:
{
"id": <ID>,
"title": <USER INPUT OR PREVIOUS TITLE IF NOT PROVIDED>,
"image": <IMAGE URL OR PREVIOUS IMAGE URL IF NOT PROVIDED>
"item": <USER INPUT OR PREVIOUS ITEM IF NOT PROVIDED>,
"status": <USER INPUT OR PREVIOUS STATUS IF NOT PROVIDED>,
"text": <USER INPUT OR PREVIOUS TEXT IF NOT PROVIDED>,
"location": <USER INPUT OR PREVIOUS LOCATION IF NOT PROVIDED>,
"timestamp": <ORIGINAL TIMESTAMP>,
"user_id": <USER_ID>
}
DELETE /api/posts/<post_id>/
Request Header:
Key | Value |
---|---|
Authorization | Bearer <session_token> |
Response:
{
"id": <ID>,
"title": <TITLE>,
"image": <IMAGE URL>
"item": <ITEM>,
"status": <STATUS>,
"text": <TEXT>,
"location": <LOCATION>,
"timestamp": <TIMESTAMP>,
"user_id": <USER_ID>
}
GET /api/users/<user_id>/convos/
Response:
{
"conversations": [
{
"id": <ID>,
"user1_messages": [<SERIALIEZD MESSAGE>],
"user2_messages": [<SERIALIZED MESSAGE>],
"user1_id": <USER1_ID>,
"user2_id": <USER2_ID>
},
...
]
}
GET /api/users/<user_id>/convos/<conversation_id>/
Response:
{
"id": <ID>,
"user1_messages": [<SERIALIZED MESSAGE>],
"user2_messages": [<SERIALIZED MESSAGE>],
"user1_id": <USER1_ID>,
"user2_id": <USER2_ID>
}
Note:
- User1_id is the ID of the user that first made the conversation
- User2_id is the ID of the user that <user_id> is messaging
POST /api/users/<user_id>/convos/
Request Header:
Key | Value |
---|---|
Authorization | Bearer <session_token> |
Request:
{
"username": <USER INPUT>
}
Response:
{
"id": <ID>,
"user1_messages": [],
"user2_messages": [],
"user1_id": <user_id>,
"user2_id": <ID OF USER INPUT>
}
DELETE /api/users/<user_id>/convos/<conversation_id>/
Request Header:
Key | Value |
---|---|
Authorization | Bearer <session_token> |
Response:
{
"id": <conversation_id>,
"user1_messages": [<SERIALIZED MESSAGE>],
"user2_messages": [<SERIALIZED MESSAGE>],
"user1_id": <USER1_ID>,
"user2_id": <USER2_ID>
}
POST /api/users/<user_id>/convos/<conversation_id>/
Request Header:
Key | Value |
---|---|
Authorization | Bearer <session_token> |
Request:
{
"receiver": <USER INPUT (USERNAME)>,
"content": <USER INPUT>,
}
Response:
{
"id": <ID>,
"sender_id": <user_id>,
"receiver_id": <receiver_id>,
"content": <USER INPUT>,
"timestamp": <NOW>,
"conversation_id": <conversation_id>
}
Note:
- Timestamp is the string representation of the DateTime object at the time the message is created.
GET /api/users/<user_id>/convos/<conversation_id>/messages/
Response:
{
"messages": [
{
"id": <ID>,
"sender_id": <SENDER_ID>,
"receiver_id": <RECEIVER_ID>,
"content": <CONTENT>,
"timestamp": <NOW>,
"conversation_id": <CONVERSATION_ID>
},
...
]
}
GET /api/users/<user_id>/convos/<conversation_id>/user/
Request Header:
Key | Value |
---|---|
Authorization | Bearer <session_token> |
Response:
{
"messages": [<SERIALIZED MESSAGE>]
}
GET /api/users/<user_id>/convos/<conversation_id>/other/
Request Header:
Key | Value |
---|---|
Authorization | Bearer <session_token> |
Response:
{
"messages": [<SERIALIZED MESSAGE>]
}