Welcome to the Book Store API documentation. This page shows the available endpoints for the Book Store API.
All endpoints are relative to: https://books-b.netlify.app/.netlify/functions/api
Note: For convenience, many endpoints can also be accessed without the /.netlify/functions/api
prefix.
Get all books. You can also use /api/books
for backward compatibility.
category
- Filter by book categorylimit
- Limit the number of results[{ "_id": "60d21b4667d0d8992e610c85", "title": "The Book Title", "author": "Author Name", "price": 19.99, "image": "https://example.com/book.jpg", "description": "Book description here", "category": ["fiction", "adventure"] }]
Get a specific book by its ID. You can also use /api/books/:id
.
{ "_id": "60d21b4667d0d8992e610c85", "title": "The Book Title", "author": "Author Name", "price": 19.99, "image": "https://example.com/book.jpg", "description": "Book description here", "category": ["fiction", "adventure"] }
Get a specific Bhagavad Gita slok. You can also use /api/slok/:chapter/:slok
.
{ "_id": "BG1.1", "chapter": 1, "verse": 1, "slok": "dharma-kṣetre kuru-kṣetre samavetā yuyutsavaḥ...", "transliteration": "dharma-kṣetre kuru-kṣetre...", "tej": { "ht": "धर्मक्षेत्रे कुरुक्षेत्रे..." }, "translations": { "en": "Observing the armies..." } }
Authenticate a user. You can also use /api/auth/login
.
{ "email": "user@example.com", "password": "password123" }
{ "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...", "user": { "id": "60d21b4667d0d8992e610c85", "name": "User Name", "email": "user@example.com", "isAdmin": false } }
Create a new book (requires admin authentication). You can also use /api/books/create-book
.
Authorization: Bearer YOUR_TOKEN
{ "title": "New Book Title", "author": "Author Name", "price": 24.99, "image": "https://example.com/new-book.jpg", "description": "Description of the new book", "category": ["fiction", "mystery"] }
All endpoints will return appropriate HTTP status codes and JSON error messages in case of failure.
For any issues or questions about the API, please contact the administrator.