The Social Media API is a RESTful API that allows users to interact with a social media application. It provides various endpoints to perform actions such as creating posts, commenting on posts, liking posts, and managing user profiles.
- User authentication: Users can register, log in, and log out.
- Post management: Users can create posts, view posts, edit posts, and delete posts.
- Commenting: Users can comment on posts and view comments.
- Likes: Users can like posts and view the number of likes on each post.
- User profiles: Users can view and update their profile information, see posts they create, see posts they liked.
- Followers & following: you can follow and unfollow users, see whom you follow & and whom follow you, see quantity of followers
- Defer post creation: you have an opportunity to indicate date and time for defer post creation.
- Django: a Python web framework for building the API.
- Django REST framework: a powerful toolkit for building RESTful APIs.
- Token auth: for user authentication and authorization.
- Celery: defer post creation
- Swagger/redoc: this api fully documented in swagger application, so endpoint info fully available there.
To get started with the Social Media API, follow these steps: (using PyCharm you can click on the green arrow without copying command)
-
Clone the repository:
git clone https://github.com/phaishuk/Social-media-API
-
Navigate to the project directory (don't forget to check the directory where you clone the project):
cd Social-media-API
-
Create a virtual environment:
python -m venv venv
-
Activate the virtual environment:
- For Windows:
env\Scripts\activate
- For MacOS, Unix, Linux:
source env/bin/activate
-
Install the required dependencies:
pip install -r requirements.txt
- Apply database migrations & and prepared data for testing:
python manage.py migrate
- Run server:
In this project sensitive data moved to .env.sample
file.
Please rename it .env.sample -> .env
before running server.
python manage.py runserver
- Authenticate to check functionality:
This project has preinstalled data, and you can check it out using next credentials:
USERNAMEs:
admin@admin.com (superuser)
user@user.com
user1@user.com
user2@user.com
PASSWORD: (the same for all)
1234qwer!@#$
Using this credential you can easily obtain token on the endpoint /api/user/login/
.
Using app add header with key Authorization
and value Token <obtained token value>
.
If you would like to register new user you need to provide email, username, and password.
Using this functionality that's required to have installed redis server on your local computer.
Server have to be up on default redis port redis://localhost:6379
Check it out how to configure it here: Official link on configuration
- Open separate from django server terminal check it works by command
redis-cli ping
. If answer isPONG
everything works. - Go to directory where project is cloned
cd Social-media-API
- Start celery worker in terminal by command
celery -A app worker --loglevel=info
After that actions defer post creation have to work properly.
The API documentation, including the available endpoints and their request/response formats, can be found at http://localhost:8000/api/doc/swagger when the server is running.