Check out the latest features here
- FastAPI (Python)
- MongoDB
id: str
username: str
body: str
time_added: str
likes:int
comments:list
tags:list
"example": {
"id": "00010203-0405-0607-0809-0a0b0c0d0e0f",
"username": "John",
"body": "Hello this is John",
"time_added":"2021-10-07 00:02:13.886088",
"likes":10,
"comments":["jrk6659gfk","fjkj56565"],
"tags":["#newpost","#firstpost","#lovethis","#newintech"]
}
id: str
user_to_request: str
user_to_accept: Optional[str]
type: str
body: str
accepted: Optional[bool] = None
"example": {
"user_to_request": "1b5b2986-8fc0-4c85-89ea-1e74bfc24118",
"type": "Backend",
"body": "hey I need help with CORS error",
"accepted": False,
}
id: str
first_name: str
last_name: str
username: str
email: str
password: str
gender: str
phone: str
following_count: int
following: list
followers_count: int
followers: list
posts_id: list
disabled: Optional[bool] = None
"example": {
"id": "00010203-0405-0607-0809-0a0b0c0d0e0f",
"first_name": "John",
"last_name": "Doe",
"username": "John123",
"email": "[email protected]",
"password": "##@@##**",
"gender": "Male",
"phone": "1234567890",
"following_count": 3,
"following":["57hjhj5hg","748jhjkh75h","fhdjhjhkjfh"],
"followers_count": 1,
"followers": ["4jhkjl34hk"],
"posts_id":["83iyuhh34","3hjkjkl4k4","djfjkjklh44"],
"disabled":False
}
Routes | HTTP | Description |
---|---|---|
/post/ | GET |
Get all posts |
/post/{id} | GET |
Get Single post |
/post/ | POST |
Create a post |
/post/{id} | DELETE |
Delete a post |
/post/{id} | PUT |
Update data of a post |
/post/users/{username} | GET |
Get posts from a user |
/post/tag/{tag} | GET |
Get posts with a requested tag |
/post/{id}/like | POST |
Like a post |
/post/{id}/comment | POST |
Comment on a post |
/post/{id}/comments | GET |
Show comments on a post |
/post/{id}/comment/metadata | GET |
Show data about comment on a post |
Routes | HTTP | Description |
---|---|---|
/user/active | GET |
Get all active users |
/user/{username}/details | GET |
Get Single user |
/user/ | POST |
Create a user |
/user/login | POST |
Login a user |
/user/logout | POST |
Logout a user |
/user/{username}/follow/{username_to_follow} | POST |
Follow a user |
/user/{username}/unfollow/{username_to_unfollow} | POST |
Unfollow a user |
/user/{username}/feed | GET |
Get feed of logged in user |
/user/{id}/delete | DELETE |
Delete a user |
/user/update/{id} | PUT |
Edit user profile |
- Added Authentication using JWT token
Logs in a user and returns JWT token with a validity of 30 minutes
-
URL
/user/token
-
Method:
POST
-
Data Params
username=str
password=str
-
Success Response:
-
Code: 200
Content:
{ "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjoiam9objEyMyIsImV4cCI6MTYzNzY5NDYzNH0.7jFLeyqpMDi4bHyj9zcrG1kQ0N-2-Ij7dijdWt4IHpU", "token_type": "bearer" }
-
-
Error Response:
-
Code: 404 NOT FOUND
Content:
{"detail": "No user found with username <username>" }
-
Sample Call:
curl -X 'POST' \
'http://0.0.0.0:8000/user/token' \
-H 'accept: application/json' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'grant_type=&username=john123&password=<password>&scope=&client_id=&client_secret='
Routes | HTTP | Description |
---|---|---|
/user/ | GET |
Get token of logged in user |
/user/me | GET |
Get details of current user |
/user/me/feed | GET |
Get feed of current user |
/user/ | POST |
Create a user |
/user/login | POST |
Login a user |
/user/me/logout | POST |
Logout current user |
/user/me/follow/{username_to_follow} | POST |
Follow a user |
/user/me/unfollow/{username_to_unfollow} | POST |
Unfollow a user |
/user/me/delete | DELETE |
Delete current user |
/post/ | POST |
Create a post |
/post/{id} | DELETE |
Delete a post |
/post/{id} | PUT |
Update data of a post |
/post/{id}/like | POST |
Like a post |
/post/{id}/comment | POST |
Comment on a post |
- Sample request for post creation after authentication
curl -X 'POST' \
'http://0.0.0.0:8000/post/' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer {JWT_TOKEN}β \
-d '{
"id": "00010203-0405-0607-0809-0a0b0c0d0e0f",
"username": "John",
"body": "Hello this is John",
"time_added": "2021-10-07 00:02:13.886088",
"likes": 10,
"comments": [
"jrk6659gfk",
"fjkj56565"
],
"tags": [
"#newpost",
"#firstpost",
"#lovethis",
"#newintech"
]
}'
- Added
Collaboration Request
Feature
Routes | HTTP | Description |
---|---|---|
/request/create | POST |
create a request |
/request/created/{id} | GET |
Get details of requests created by user |
/request/{id}/accept | PUT |
accept a request |
/request/accepted/{id} | GET |
list requests accepted by user |
DevStation-API returns the following status codes in its API:
Status Code | Description |
---|---|
200 | OK |
201 | CREATED |
400 | BAD REQUEST |
404 | NOT FOUND |
500 | INTERNAL SERVER ERROR |
git clone https://github.com/batman004/DevStation-Backend.git
cd DevStation-Backend
vi .env
<fill in credentials>
DB_URL=
DB_NAME=
PORT=
PROD=
JWT_SECRET_KEY=
ALGORITHM=
ACCESS_TOKEN_EXPIRE_MINUTES=
#create a virtual environment
virtualenv env
source env/bin/activate (for MacOS/Linux)
env\Scripts\activate (for Windows)
# install dependencies
pip install -r requirements.txt
# Driver file
python main.py
- User Signup π
- User Login and Authentication π
- CRUD operations with user posts ποΈ
- Like and comment on user posts βοΈ
- Create Collaborative Requests β
- Accept Collaborative Requests β
- User Explore Feed π±
- User Follow/ Unfollow πββοΈ
- User Signup through third-party authentication services (Gmail/Github) π
- Add direct messaging π£οΈ
- Personalised User Explore Feed π±
- Add third party integrations to user profile (like github stats/spotify stats) π