This is a simple Blog API built using Django and Django REST Framework (DRF). The API provides endpoints for managing blog posts, categories, comments, and user authentication.
- User authentication (Register, Login, JWT token support)
- Blog post management (Create, Read, Update, Delete)
- Category management (Create, List, Retrieve, Update, Delete)
- Comment system (Users can comment on blog posts)
- Pagination & Filtering for posts
- Admin panel for managing users, posts, categories, and comments
- Dockerized for easy deployment
- Swagger API documentation
- Backend: Django 4.2, Django REST Framework
- Database: PostgreSQL
- Authentication: JWT Authentication
- Cache: Redis
- Containerization: Docker & Docker Compose
- Web Server: Gunicorn
- Python 3.11+
- Docker & Docker Compose
git clone https://github.com/Hr-ArshA/BlogAPI.git
cd blog-api
python -m venv venv
source venv/bin/activate # On Windows use `venv\Scripts\activate`
pip install -r requirements.txt
Copy .env-sample
to .env
and update the required values.
cp .env-sample .env
python manage.py migrate
python manage.py createsuperuser
python manage.py runserver
- Build & Start Containers
docker-compose up --build
- Access the API
- API runs on: http://127.0.0.1:8000
- Admin Panel: http://127.0.0.1:8000/admin
- Swagger Docs: http://127.0.0.1:8000/api/v1/swagger
Method | Endpoint | Description |
---|---|---|
POST | /api/v1/user/register/ |
Register a new user |
POST | /api/v1/token/ |
Obtain JWT token |
POST | /api/v1/token/refresh/ |
Refresh JWT token |
Method | Endpoint | Description |
---|---|---|
GET | /api/v1/post/ |
List all posts |
POST | /api/v1/post/create/ |
Create a new post |
GET | /api/v1/post/<slug>/ |
Retrieve post details |
PUT | /api/v1/post/<slug>/ |
Update a post |
DELETE | /api/v1/post/<slug>/ |
Delete a post |
Method | Endpoint | Description |
---|---|---|
GET | /api/v1/post/<slug>/comment/ |
List all comments on a post |
POST | /api/v1/post/<slug>/comment/create/ |
Add a comment to a post |
GET | /api/v1/post/<slug>/comment/<id>/ |
Retrieve a specific comment |
PUT | /api/v1/post/<slug>/comment/<id>/ |
Update a comment |
DELETE | /api/v1/post/<slug>/comment/<id>/ |
Delete a comment |
Method | Endpoint | Description |
---|---|---|
GET | /api/v1/category/<slug> |
List posts under a category |
POST | /api/v1/category/create/ |
Create a new category |
GET | /api/v1/category/detail/<slug> |
Retrieve category details |
PUT | /api/v1/category/detail/<slug> |
Update a category |
DELETE | /api/v1/category/detail/<slug> |
Delete a category |
To run the test suite, use:
python manage.py test
-
Prepare your environment
- Ensure your
.env
file is correctly configured. - Ensure all dependencies are installed.
- Ensure your
-
Build and start the Docker container
docker-compose up --build -d
- Run database migrations
docker exec -it <container_id> python manage.py migrate
This project is licensed under the MIT License.
ArshA
Contact: [email protected]