2025-05-17 18:53:46 +00:00

119 lines
1.9 KiB
Markdown

# Simple Todo API
A simple Todo API built with FastAPI and SQLite.
## Features
- CRUD operations for Todo items
- Filtering and pagination for todos list
- Health check endpoint
- OpenAPI documentation
## Requirements
- Python 3.8+
- FastAPI
- SQLAlchemy
- Alembic
- SQLite
- Uvicorn
## Installation
1. Clone the repository:
```bash
git clone https://github.com/yourusername/simpletodoapi.git
cd simpletodoapi
```
2. Install the dependencies:
```bash
pip install -r requirements.txt
```
3. Apply migrations:
```bash
alembic upgrade head
```
## Running the Application
Start the application with:
```bash
uvicorn main:app --reload
```
The API will be available at `http://localhost:8000`
## API Documentation
Once the application is running, you can access the interactive API documentation at:
- Swagger UI: `http://localhost:8000/docs`
- ReDoc: `http://localhost:8000/redoc`
## API Endpoints
### Todos
- `GET /api/todos` - List all todos with optional filtering and pagination
- `POST /api/todos` - Create a new todo
- `GET /api/todos/{todo_id}` - Get a specific todo
- `PUT /api/todos/{todo_id}` - Update a todo
- `DELETE /api/todos/{todo_id}` - Delete a todo
### Health
- `GET /health` - Check API health status
## Examples
### Create a Todo
```bash
curl -X 'POST' \
'http://localhost:8000/api/todos' \
-H 'Content-Type: application/json' \
-d '{
"title": "Buy groceries",
"description": "Milk, eggs, bread",
"completed": false
}'
```
### List Todos
```bash
curl -X 'GET' 'http://localhost:8000/api/todos'
```
### Get a specific Todo
```bash
curl -X 'GET' 'http://localhost:8000/api/todos/1'
```
### Update a Todo
```bash
curl -X 'PUT' \
'http://localhost:8000/api/todos/1' \
-H 'Content-Type: application/json' \
-d '{
"completed": true
}'
```
### Delete a Todo
```bash
curl -X 'DELETE' 'http://localhost:8000/api/todos/1'
```
## License
MIT