A simple and clean REST API for note-taking built with Flask and SQLite. Features full CRUD operations with a minimal, easy-to-understand codebase.
- Create Notes: Add new notes with title and content
- Read Notes: Retrieve all notes or a specific note by ID
- Update Notes: Modify existing note titles and content
- Delete Notes: Remove notes permanently
- SQLite Database: Lightweight persistent storage
- RESTful Design: Standard HTTP methods and status codes
- Automatic Timestamps: Created date tracked for each note
- Python 3
- Flask (Web Framework)
- SQLite3 (Database)
CREATE TABLE notes (
id INTEGER PRIMARY KEY AUTOINCREMENT,
title TEXT NOT NULL,
content TEXT,
created_at TEXT NOT NULL
)GET /api/notes/
Response: Array of all notes with id, title, content, and timestamp
Example Response:
[
{
"id": 1,
"title": "First Note",
"content": "This is my first note",
"created_at": "11/12/2025, 18:35:37"
}
]GET /api/notes/<id>
Response: Single note object or 404 error if not found
POST /api/notes/
Content-Type: application/json
{
"title": "Note title",
"content": "Note content"
}
Response: 201 Created with success message
PUT /api/notes/<id>
Content-Type: application/json
{
"title": "Updated title",
"content": "Updated content"
}
Response: 200 OK with success message or 404 if not found
Note: Both fields are optional - send only the fields you want to update
DELETE /api/notes/<id>
Response: 200 OK with success message or 404 if not found
- Clone the repository:
git clone https://github.com/jandaghi14/beginner-flask-notes-api.git
cd beginner-flask-notes-api- Install Flask:
pip install flask- Run the application:
python app.py- Server runs on:
http://127.0.0.1:5000
curl -X POST http://127.0.0.1:5000/api/notes/ -H "Content-Type: application/json" -d "{\"title\": \"My first note\", \"content\": \"This is the content\"}"curl http://127.0.0.1:5000/api/notes/curl http://127.0.0.1:5000/api/notes/1curl -X PUT http://127.0.0.1:5000/api/notes/1 -H "Content-Type: application/json" -d "{\"title\": \"Updated title\"}"curl -X DELETE http://127.0.0.1:5000/api/notes/2beginner-flask-notes-api/
│
├── app.py # Flask application and API routes
├── database.py # Database operations and schema
├── .gitignore # Git ignore rules
└── README.md # Project documentation
- Separation of concerns (routes vs database logic)
- Modular code organization
- Easy to understand and maintain
- Proper HTTP status codes (200, 201, 404)
- Descriptive error messages
- Validation for missing notes
- Automatic ID generation
- Timestamp tracking
- Optional content field
- Parameterized queries for security
- Building REST APIs with Flask
- SQLite database operations
- HTTP methods and status codes
- JSON request/response handling
- API testing with curl
- Error handling in web applications
- Code organization and modularity
- Add user authentication
- Implement search functionality
- Add tags/categories for notes
- Pagination for large note collections
- Input validation and sanitization
- Deploy to cloud platform
- Add unit tests
This project is open source and available for educational purposes.
Built as part of a Python learning journey - practicing Flask and SQLite integration.