- Anybody can create an account and become a user.
- Authenticated users can login to their individual account.
- Authenticated users can create posts.
- Authenticated users can read personal posts.
- Authenticated users can view everybody's posts.
- Authenticated users can view a specific post.
- Authenticated users can delete personal post.
- Authenticated users can update personal post.
- Authenticated users can can like any post of their choice.
- Authenticated users can can unlike any post of their choice.
- Can get a specific user by Id.
- Users have the ability to search for keywords and get back response if it matches any keyword in the post content available on the database
- Users have the ability to set pagination, default pagination is set to 10
API documentation:
field | data_type | constraints | validation |
---|---|---|---|
id | Object | required | None |
string | required | unique, email must conform to email (example: [email protected]) | |
password | string | required | pasword must contain at least one uppercase, one lowercase, one number, and must be at least 8 characters |
created_at | timestamp | automatically set |
field | data_type | constraints | validation |
---|---|---|---|
id | integer | required | None |
title | string | required | None |
content | string | required | None |
publised | boolean | optional, default value set to false | None |
created_at | timestamp | required, automatically set |
field | data_type | constraints | validation |
---|---|---|---|
user_id | integer | required | None |
post_id | integer | required | None |
- Route: /
- Method: GET
- Header
- Authorization: None
- Responses: Success
{
"message": "Welcome to Social Hub"
}
- Route: /users
- Method: POST
- Header
- Authorization: None
- Body:
{
"email": "[email protected]",
"password": "Password123"
}
- Responses: Success
{
"id": 1,
"email": "[email protected]",
"created_at": "2023-02-05T15:29:24.712Z"
}
- Route: /login
- Method: POST
- Body:
{
"username": "[email protected]",
"password": "Password123"
}
- Responses: Success
{
"access_token": "accesstokenexample&8ofiwhb.fburu276r4ufhwu4.o82uy3rjlfwebj",
"token_type": "Bearer"
}
- Route: /posts
- Method: POST
- Header
- Authorization: Bearer {token}
- Body:
{
"title": "string",
"content": "string",
"published": true
}
- Responses: Success
{
"title": "string",
"content": "string",
"published": true,
"id": 0,
"created_at": "2023-02-05T19:02:41.204Z",
"owner_id": 0,
"owner": {
"id": 0,
"email": "[email protected]",
"created_at": "2023-02-05T19:02:41.204Z"
}
}
- Route: /posts
- Method: GET
- Header
- Authorization: Bearer {token}
- Body:
[
{
"Post": {
"title": "string",
"content": "string",
"published": true,
"id": 4,
"created_at": "2023-02-05T19:10:08.030Z",
"owner_id": 4,
"owner": {
"id": 4,
"email": "[email protected]",
"created_at": "2023-02-05T19:10:08.030Z"
}
},
"likes": 0
}
{
"Post": {
"title": "string",
"content": "string",
"published": true,
"id": 1,
"created_at": "2023-02-05T19:10:08.030Z",
"owner_id": 2,
"owner": {
"id": 2,
"email": "[email protected]",
"created_at": "2023-02-05T19:10:08.030Z"
}
},
"likes": 4
}
{
"Post": {
"title": "string",
"content": "string",
"published": true,
"id": 3,
"created_at": "2023-02-05T19:10:08.030Z",
"owner_id": 2,
"owner": {
"id": 2,
"email": "[email protected]",
"created_at": "2023-02-05T19:10:08.030Z"
}
},
"likes": 2
}
]
In order to run this project locally, you would need to have the following installed on your local machine.
- Python ^3.10,
- PostgreSQL
- Docker - optional
- Clone this repository
git clone [https://github.com/Nkasi-e/social-api.git]
- update env with .env.example.txt
- Download all dependecies using
pip install -r requirements.txt
orpipenv install
that's if you have pipenv installed already on your machine - run uvicorn app.main:app --reload