A Django REST Framework API for storing and sharing syntax-highlighted code snippets.
- Create, list, retrieve, update, and delete code snippets
- Syntax highlighting via Pygments (
/snippets/{id}/highlight/) - Read-only user endpoints (
/users/,/users/{id}/) - JWT-based authentication with
dj-rest-auth - OpenAPI schema and interactive API docs (Swagger UI + ReDoc)
- Python 3.12+
- Django 6
- Django REST Framework
- dj-rest-auth + django-allauth
- drf-spectacular
- SQLite (default)
git clone https://github.com/rhythmd18/pastebin-API.git
cd pastebin-API
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
pip install -r requirements.txtpython manage.py migrate
python manage.py createsuperuser # optional
python manage.py runserverThe API will be available at http://127.0.0.1:8000/.
This project is configured to use JWT auth.
- Login:
POST /api/auth/login/ - Refresh token:
POST /api/auth/token/refresh/ - Verify token:
POST /api/auth/token/verify/ - Logout:
POST /api/auth/logout/ - Current user:
GET /api/auth/user/ - Registration:
POST /api/auth/registration/
Use the access token in the Authorization header:
Authorization: Bearer <access_token>GET /snippets/— list snippetsPOST /snippets/— create snippet (authenticated)GET /snippets/{id}/— retrieve snippetPUT/PATCH /snippets/{id}/— update snippet (owner only)DELETE /snippets/{id}/— delete snippet (owner only)GET /snippets/{id}/highlight/— HTML highlighted snippetGET /users/— list usersGET /users/{id}/— retrieve user
- OpenAPI schema:
GET /schema/ - Swagger UI:
GET /schema/swagger-ui/ - ReDoc:
GET /schema/redoc/
python manage.py test