Skip to content

Repository files navigation

Book API

Simple REST API for books – CRUD only, no auth. Good for demos and learning.

Quick start

npm install && npm run dev

Base URL: http://localhost:3000

Endpoints

MethodEndpointDescription
GET/healthHealth check
GET/api/v1/booksList all books
GET/api/v1/books/:idGet one book
POST/api/v1/booksCreate a book
PUT/api/v1/books/:idUpdate a book
DELETE/api/v1/books/:idDelete a book

No authentication required.

Examples

List books

curl http://localhost:3000/api/v1/books

Create book

curl -X POST http://localhost:3000/api/v1/books \
-H "Content-Type: application/json" \
-d '{"title":"Dune","author":"Frank Herbert","year":1965}'

Update book (PUT with full or partial fields)

curl -X PUT http://localhost:3000/api/v1/books/1 \
-H "Content-Type: application/json" \
-d '{"title":"Dune","author":"Frank Herbert","year":1965}'

Delete book

curl -X DELETE http://localhost:3000/api/v1/books/1

Book shape

  • title (string, required)
  • author (string, required)
  • year (number, optional)

Responses use { book: {...} } or { books: [...] }. Errors use { error: { name, message } }.

Commands

  • npm run dev – dev server with reload
  • npm start – production
  • npm test – run tests
  • npm run lint – lint

Project layout

src/
├── server.js
├── database/db.js # In-memory store
├── models/Book.js
├── routes/books.js
└── middleware/errorHandler.js

Config

Optional .env: PORT=3000

License: ISC

About

This is a demo API used to demo native git support in Postman

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages