git clone https://github.com/wtrbtl03/django-notetaking-app-api
pip install -r requirements.txt
python3 manage.py migrate
python3 manage.py runserver
This is a simple REST API built using Django for managing notes. The API allows one to create, fetch, query, and update notes.
/api/
- URL:
/note/
- Method:
POST
- Description: Creates a new note with a
title
andbody
. - Body:
{ "title": "Note Title", "body": "Note Body" }
- Success Response:
- Code:
201 Created
- Content:
{ "id": 1, "title": "Note Title", "body": "Note Body", "created_at": "2024-09-06T12:00:00Z", "updated_at": "2024-09-06T12:00:00Z" }
- Code:
- Error Response:
- Code:
400 Bad Request
- Content:
{ "error": "Both 'title' and 'body' are required fields" }
- Code:
- URL:
/note/all/
- Method:
GET
- Description: Retrieves all notes stored in the database.
- Success Response:
- Code:
200 OK
- Content:
[ { "id": 1, "title": "Note Title", "body": "Note Body", "created_at": "2024-09-06T12:00:00Z", "updated_at": "2024-09-06T12:00:00Z" }, { "id": 2, "title": "Another Note Title", "body": "Another Note Body", "created_at": "2024-09-06T12:10:00Z", "updated_at": "2024-09-06T12:10:00Z" } ]
- Code:
- Error Response:
- Code:
404 Not Found
- Content:
{ "error": "No notes found" }
- Code:
- URL:
/note/<int:note_id>/
- Method:
GET
- Description: Retrieves a specific note by its ID.
- Success Response:
- Code:
200 OK
- Content:
{ "id": 1, "title": "Note Title", "body": "Note Body", "created_at": "2024-09-06T12:00:00Z", "updated_at": "2024-09-06T12:00:00Z" }
- Code:
- Error Response:
- Code:
404 Not Found
- Content:
{ "error": "Note not found" }
- Code:
- URL:
/note/search/?title=<search_term>
- Method:
GET
- Description: Searches for notes with titles containing the given search term.
- Success Response:
- Code:
200 OK
- Content:
[ { "id": 1, "title": "Note Title", "body": "Note Body" }, ... ]
- Code:
- Error Response:
- Code:
400 Bad Request
- Content:
{ "error": "Query parameter 'title' is required" }
- Code:
404 Not Found
- Content:
{ "error": "No notes found" }
- Code:
- URL:
/note/<int:note_id>/update/
- Method:
PUT
- Description: Updates an existing note by its ID. Either
title
orbody
or both can be updated. - Body:
{ "title": "Updated Title", "body": "Updated Body" }
- Success Response:
- Code:
200 OK
- Content:
{ "id": 1, "title": "Updated Title", "body": "Updated Body", "created_at": "2024-09-06T12:00:00Z", "updated_at": "2024-09-06T13:00:00Z" }
- Code:
- Error Response:
- Code:
400 Bad Request
- Content:
{ "error": "At least one of 'title' or 'body' must be provided for update" }
- Code:
404 Not Found
- Content:
{ "error": "Note not found" }
- Code:
The code for this project is available for use under the MIT License.