Build a Restful CRUD API for a simple Note-Taking application using Node.js, Express and MongoDB.
- Install dependencies
npm install- Run Server
node server.jsYou can browse the apis at http://localhost:3000
| Method | Path | Description |
|---|---|---|
| POST | /notes |
Create a note |
| GET | /notes |
List notes (optional filters) |
| GET | /notes/:noteId |
Get one note |
| PUT | /notes/:noteId |
Update a note |
| DELETE | /notes/:noteId |
Delete a note |
| Field | Type | Required | Description |
|---|---|---|---|
title |
string | No | Defaults to "Untitled Note" |
content |
string | Yes | Note body |
tags |
string[] | No | Labels for organizing notes; defaults to [] |
curl -X POST http://localhost:3000/notes \
-H "Content-Type: application/json" \
-d '{"title":"Q3 Budget","content":"Review expenses","tags":["work","finance"]}'Omitting tags creates a note with an empty tags array.
# All notes
curl http://localhost:3000/notes
# Filter by tag
curl "http://localhost:3000/notes?tag=work"
# Filter by multiple tags (OR)
curl "http://localhost:3000/notes?tag=work&tag=personal"
# Keyword search in title and content
curl "http://localhost:3000/notes?q=budget"
# Combined tag filter and keyword search
curl "http://localhost:3000/notes?tag=work&q=meeting"curl -X PUT http://localhost:3000/notes/:noteId \
-H "Content-Type: application/json" \
-d '{"title":"Updated","content":"New content","tags":["personal"]}'If tags is omitted from the request body, existing tags are preserved. Send "tags": [] to clear all tags.
You can find the tutorial for this application at The CalliCoder Blog -
https://www.callicoder.com/node-js-express-mongodb-restful-crud-api-tutorial/