|
| 1 | +# ToDo List API |
| 2 | + |
| 3 | +A simple ToDo List API built with Django and Django REST Framework. This project allows users to manage their to-do items through a set of RESTful endpoints. |
| 4 | + |
| 5 | +Project idea from: [roadmap.sh/projects/todo-list-api](https://roadmap.sh/projects/todo-list-api) |
| 6 | + |
| 7 | +## Features |
| 8 | + |
| 9 | +* **User Authentication**: Secure user registration and login using JSON Web Tokens (JWT). |
| 10 | +* **CRUD Operations**: Full Create, Read, Update, and Delete functionality for to-do items. |
| 11 | +* **Ownership**: Users can only view and modify their own to-do items. |
| 12 | +* **Filtering and Searching**: Filter todos by completion status and search by title or description. |
| 13 | +* **Ordering**: Sort todos based on creation date, title, or completion status. |
| 14 | +* **API Throttling**: Rate limiting for both anonymous and authenticated users to prevent abuse. |
| 15 | + |
| 16 | +## Prerequisites |
| 17 | + |
| 18 | +* Python 3.8+ |
| 19 | +* pip |
| 20 | +* virtualenv (recommended) |
| 21 | + |
| 22 | +## Setup and Installation |
| 23 | + |
| 24 | +1. **Clone the repository:** |
| 25 | + |
| 26 | + ```bash |
| 27 | + git clone <your-repository-url> |
| 28 | + cd "ToDo API" |
| 29 | + ``` |
| 30 | + |
| 31 | +2. **Create and activate a virtual environment:** |
| 32 | + |
| 33 | + * On macOS and Linux: |
| 34 | + ```bash |
| 35 | + python3 -m venv venv |
| 36 | + source venv/bin/activate |
| 37 | + ``` |
| 38 | + * On Windows: |
| 39 | + ```bash |
| 40 | + python -m venv venv |
| 41 | + .\venv\Scripts\activate |
| 42 | + ``` |
| 43 | + |
| 44 | +3. **Install dependencies:** |
| 45 | + |
| 46 | + ```bash |
| 47 | + pip install -r requirements.txt |
| 48 | + ``` |
| 49 | + |
| 50 | +4. **Apply database migrations:** |
| 51 | + |
| 52 | + ```bash |
| 53 | + python manage.py migrate |
| 54 | + ``` |
| 55 | + |
| 56 | +5. **Run the development server:** |
| 57 | + |
| 58 | + ```bash |
| 59 | + python manage.py runserver |
| 60 | + ``` |
| 61 | + |
| 62 | + The API will be available at `http://127.0.0.1:8000/`. |
| 63 | + |
| 64 | +## API Endpoints |
| 65 | + |
| 66 | +Here is a list of the available API endpoints. |
| 67 | + |
| 68 | +### Authentication |
| 69 | + |
| 70 | +* `POST /register/` |
| 71 | + * **Description**: Register a new user. |
| 72 | + * **Body**: `{ "name": "Your Name", "email": "user@example.com", "password": "yourpassword" }` |
| 73 | + |
| 74 | +* `POST /login/` |
| 75 | + * **Description**: Log in to receive JWT access and refresh tokens. |
| 76 | + * **Body**: `{ "email": "user@example.com", "password": "yourpassword" }` |
| 77 | + |
| 78 | +* `POST /refresh/` |
| 79 | + * **Description**: Obtain a new access token using a refresh token. |
| 80 | + * **Body**: `{ "refresh": "your_refresh_token" }` |
| 81 | + |
| 82 | +### ToDo Items |
| 83 | + |
| 84 | +*All ToDo endpoints require authentication.* |
| 85 | + |
| 86 | +* `GET /todos/` |
| 87 | + * **Description**: Get the list of todos for the authenticated user. Supports filtering, searching, and ordering. |
| 88 | +* `POST /todos/` |
| 89 | + * **Description**: Create a new todo item. |
| 90 | + * **Body**: `{ "title": "New Todo", "description": "A description for the new todo." }` |
| 91 | +* `GET /todos/<int:todo_id>/` |
| 92 | + * **Description**: Retrieve a specific todo item. |
| 93 | +* `PUT /todos/<int:todo_id>/` |
| 94 | + * **Description**: Update a specific todo item. |
| 95 | +* `DELETE /todos/<int:todo_id>/` |
| 96 | + * **Description**: Delete a specific todo item. |
| 97 | +* `PUT /todos/<int:todo_id>/complete/` |
| 98 | + * **Description**: Toggle the completion status of a todo item. |
0 commit comments