A simple, strictly RESTful Todo List API built using Flask. This API allows users to manage a list of tasks with operations such as retrieving tasks, adding new tasks, updating existing tasks, and deleting tasks.
The API is secured using basic HTTP authentication and is designed with modern Flask practices, making it easy to extend and integrate with a proper database.
- HTTP Basic Authentication
- RESTful API for managing tasks (CRUD operations)
- Structured and readable codebase
Make sure you have the following installed on your machine:
- Python 3.6 or higher
- pip (Python package installer)
-
Clone the repository:
git clone https://github.com/Patoski-patoski/To-Do-List-RESTFUL-API.git cd To-Do-List-RESTFUL-API
-
Create and activate a virtual environment:
python3 -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Run the application:
flask run
The app will now be running on http://127.0.0.1:5000/
.
You can interact with the API using tools like
curl
,Postman, or your web browser.
(i'll recommend getting started with PostMan 🙂 for this README, we use curl)
Example of getting all tasks using curl
:
curl -u username:password http://127.0.0.1:5000/todo/api/v1.0/tasks
To run this project, you will need to set up the necessary environment variables.
-
Copy the
.env.example
file to.env
:cp .env.example .env
-
Open the .env file and add your desired username and password:
TODO_USERNAME=your_username TODO_PASSWORD=your_password
-
Save the file, and the app will load these variables when it runs.
- Endpoint:
/todo/api/v1.0/tasks
- Method:
GET
- Authentication: Required
- Description: Returns a list of all onboarding tasks..
{
"tasks": [
{
"id": 1
"title": "Set up your GitHub account",
"description": "Create a new GitHub account, push your first repository.",
"done": false
}
]
}
- Endpoint:
/todo/api/v1.0/tasks/<int:task_id>
- Method:
GET
- Authentication: Required
- Description: Retrieve a single onboarding task by its ID.
- Endpoint: /todo/api/v1.0/tasks
- Method:
POST
- Authentication: Required
- Description: Create a new task. The
title
field is mandatory.
Request body
:
{
"title": "Set up your GitHub account",
"description": "Create a new GitHub account, push your first repository."
}
Request
:
{
"new task!":{
"id": 3,
"title": "Attend team meeting",
"description": "Join the weekly team meeting to discuss current projects and updates.",
"done": false
}
}
- Endpoint:
/todo/api/v1.0/tasks/<int:task_id>
- Method:
PUT
- Authentication: Required
- Description: Update an existing task with new values.
Request body
:
{
"title": "Complete onboarding documentation",
"done": true,
}
- Endpoint:
/todo/api/v1.0/tasks/<int:task_id>
- Method:
DELETE
- Authentication: Required
- Description: Delete a task by its ID.
Response
{
"message": "Task 1 deleted successfully"
}
This API uses HTTP Basic Authentication for security. You will need to provide your username and password when making API requests.
Username: username
Password: secretpassword
You can provide authentication details using tools like curl:
curl -u username:secretpassword http://127.0.0.1:5000/todo/api/v1.0/tasks
To run the test suite (if you have added tests), execute the following command:
python -m unittest discover tests/
- May Implement token-based authentication (e.g., JWT) for better security.
- May Integrate a database (e.g., SQLite, PostgreSQL) using SQLAlchemy for persistence.
- May Add pagination support to the GET /tasks endpoint.
- May Implement a web frontend using a framework like React or Vue.js.
This project is licensed under the MIT License - see the MIT License file for details.
1. **Project Title**: Name of the project.
2. **Description**: Short description of what the project does.
3. **Features**: Key features that stand out in the project.
4. **Installation**: Step-by-step instructions to install and run the project.
5. **Usage**: An example of how to use the API (with curl or Postman).
6. **API Endpoints**: A detailed explanation of all the endpoints, the HTTP
methods they use, the request format, and response format.
7. **Authentication**: Information on how to authenticate with the API
(HTTP Basic Authentication in this case).
8. **Running Tests**: Instructions for running tests.
9. **Future Improvements**: Areas of improvement
10. **License**: Project License