A comprehensive Blog API built with Django REST Framework that provides JWT authentication, user management, and full CRUD operations for blog posts with pagination support and Swagger documentation.
-
User Management
- User Registration with validation
- Profile Updates for authenticated users
- JWT Token Authentication
- Session-based authentication for Swagger UI
-
Blog Management
- Create Blog Posts (Authenticated users only)
- Read Blog Posts (Public access with pagination)
- Update Blog Posts (Author only)
- Delete Blog Posts (Author only)
- Paginated responses (3 items per page)
-
API Documentation
- Interactive Swagger UI documentation
- ReDoc documentation
- JWT token integration in Swagger
-
Security & Performance
- Permission-based access control
- Author verification for blog modifications
- JWT token authentication with refresh
- Optimized database queries
- Python 3.8+
- Django 4.x
- Django REST Framework
- djangorestframework-simplejwt
- drf-yasg (for Swagger documentation)
-
Clone the repository
git clone https://github.com/PTHARRISH/BlogAPI.git cd BlogAPI
-
Create virtual environment
python -m venv venv
venv\Scripts\activate
source venv/bin/activate
-
Install dependencies
pip install -r requirements.txt
-
Configure environment variables
cp .env.example .env
Edit .env file with your configuration:
- SECRET_KEY=your-secret-key-here
-
Run migrations
python manage.py makemigrations python manage.py migrate
-
Create superuser (Optional)
python manage.py createsuperuser
-
Start development server
python manage.py runserver
-
Access the API
- API Base URL: http://localhost:8000/api/
- Swagger Documentation: http://localhost:8000/swagger/
- ReDoc Documentation: http://localhost:8000/redoc/
Method | Endpoint | Description | Auth Required |
---|---|---|---|
POST | /api/token/ |
Obtain JWT token pair | No |
POST | /api/token/refresh/ |
Refresh JWT access token | No |
POST | /api/register_users/ |
Register new user | No |
PUT | /api/update_user_profile/ |
Update user profile | Yes |
Method | Endpoint | Description | Auth Required |
---|---|---|---|
GET | /api/blog_list/ |
Get paginated blog list | No |
POST | /api/create_blog/ |
Create new blog post | Yes |
POST | /api/update_blog/<int:pk>/ |
Update specific blog | Yes (Author only) |
POST | /api/delete_blog/<int:pk>/ |
Delete specific blog | Yes (Author only) |
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Harrish P T
- GitHub: @PTHARRISH
- Email: harrish@example.com
This project is licensed under the MIT License - see the LICENSE file for details.
Thank you for taking the time to explore this Blog API project! This comprehensive Django REST Framework application demonstrates modern API development practices with JWT authentication, interactive documentation, and clean architecture.
- Production-Ready: Built with industry best practices
- Well-Documented: Complete API documentation with Swagger UI
- Secure: JWT authentication with proper authorization
- Developer-Friendly: Interactive API testing with Swagger
- Scalable: Clean, maintainable codebase
- Star this repository if you find it helpful! ⭐
- Fork it to create your own version
- Contribute by submitting pull requests
- Share with fellow developers
- Check out the Issues page
- Create a new issue for bugs or feature requests
- Connect with me on GitHub: @PTHARRISH
Whether you're learning Django REST Framework, building your own blog API, or just exploring modern web development, I hope this project serves as a valuable resource. Keep coding, keep learning, and keep building amazing things!
Remember: The best way to learn is by doing. So clone this repository, experiment with the code, and make it your own!
Built with ❤️ by Harrish P T