Travel-Book API Documentation

Table of contents

To check out the project click on Travel-Book .
The web application offers several features, starting with CRUD operations that allow users to create, read, update, and delete their stories. Users can also share their stories with friends by generating a unique URL. Additionally, they can download the image of their story and share it on their Instagram Story. (We are still working on this feature, using the HTML2CANVAS library for image generation.)
Let's go over the API documentation for this web application, so other developers can easily interact with the backend using Postman or any other platform. This will allow them to perform API operations and learn about RESTful APIs. The backend of the project is hosted on the Render platform.
The Backend Base URL is Travel-Book-Backend-URL
We will go over each route in detail, covering their respective domains, such as Authentication, Story Creation, Update, Deletion, Reading, and Image Upload.
๐ ๏ธ Authentication in Travel-Book โ
Users can authenticate themselves by providing their Email-ID and Password.
To log in, users need to enter their Email-ID and Password to access their Travel Book.
To create an account, users need to provide their Full Name, Email-ID, and Password.
- Register a New User :
Endpoint: POST /create-account
Description: Creates a new user account.
Request Body:
{
"fullName": "John Doe",
"email": "
john@example.com
",
"password": "securepassword"
}
Response:
{
"error": false,
"user": { "fullName": "John Doe", "email": "
john@example.com
" },
"accessToken": "your-jwt-token",
"message": "Successfully Registered for a Travel Book!"
}
- Login User :
Endpoint : POST /login
Description: Logs in a user and returns a JWT token.
Request Body:
{
"email": "
john@example.com
",
"password": "securepassword"
}
Response:
{
"error": false,
"message": "Login Successfully to Travel Book",
"user": { "fullName": "John Doe", "email": "
john@example.com
" },
"accessToken": "your-jwt-token"
}
- Get User Profile :
Endpoint: GET /get-user
Description: Fetches user details.
Authentication Required: โ
Yes (JWT Token)
Headers:
{
"Authorization": "Bearer your-jwt-token"
}
Response:
{
"user": { "_id": "1234", "fullName": "John Doe",
"email": "
john@example.com
"}
}
๐ Travel Story Routes โ
The user will get all the stories information and appending new story or deleting stories features from the below routes.
- Add a Travel Story :
Endpoint: POST /add-travel-story
Description: Adds a new travel story.
Authentication Required: โ
Yes
Request Body:
{
"title": "Trip to Paris",
"story": "Visited the Eiffel Tower!",
"visitedLocation": "Paris",
"imageUrl": "
https://example.com/image.jpg
",
"visitedDate": "1704045623000"
}
Response:
{
"story": { "title": "Trip to Paris",
"visitedLocation": "Paris" },
"message": "Added Successfully"
}
- Get all Travel Stories :
Endpoint: GET /get-all-stories
Description: Fetches all travel stories of the logged-in user.
Authentication Required: โ
Yes
Response:
{
"stories": [ { "_id": "123", "title": "Trip to Paris",
"visitedLocation": "Paris",
"isFavourite": false } ]
}
- Edit a Travel Story :
Endpoint: PUT /edit-story/:id
Description: Edits an existing travel story.
Authentication Required: โ
Yes
Request Body:
{
"title": "Updated Title",
"story": "Updated Story",
"visitedLocation": "New Location",
"imageUrl": "
https://example.com/new-image.jpg
",
"visitedDate": "1704045623000"
}
Response:
{
"story": { "title": "Updated Title",
"visitedLocation": "New Location" },
"message": "Update Successful"
}
- Delete a Travel Story :
Endpoint: DELETE /delete-story/:id
Description: Deletes a travel story.
Authentication Required: โ
Yes
Response:
{
"message": "Travel Story deleted successfully!"
}
๐ท Image Upload Routes โ
The user can upload the images of the place that they have visited from the below routes where we have used Cloudinary to store the images.
- Upload an Image :
Endpoint: POST /image-upload
Description: Uploads an image to Cloudinary.
Authentication Required: โ No
Request (multipart/form-data)
Key: image
Value: (Select an image file)
Response:
{
"imageUrl": "
https://cloudinary.com/travelbook/image.jpg
"
}
โญ Favorite and Search Routes โ
Endpoint: PUT /update-is-favourite/:id
Description: Marks a story as a favorite.
Authentication Required: โ
Yes
Request Body:
{
"isFavourite": true
}
Response:
{
"story": { "title": "Trip to Paris", "isFavourite": true },
"message": "Update Successful"
}
๐ Search Travel Stories โ
Endpoint: GET /search?query=Paris
Description: Searches for travel stories by title, location, or description.
Authentication Required: โ
Yes
Response:
{
"stories": [ { "_id": "123", "title": "Trip to Paris",
"visitedLocation": "Paris" } ]
}
๐ Filter By Date โ
Endpoint: GET /travel-stories-filter?startDate=1704045623000&endDate=1707045623000
Description: Filters travel stories by a date range.
Authentication Required: โ
Yes
Response:
{
"stories": [ { "title": "Trip to Paris",
"visitedDate": "2024-01-01T00:00:00.000Z" } ]
}
๐ Share Travel Stories โ
Endpoint: GET /api/story/:id
Description: Fetches a specific travel story for public sharing.
Authentication Required: โ No
{
"_id": "123",
"title": "Trip to Paris",
"story": "Visited the Eiffel Tower",
"visitedLocation": "Paris"
}
โ ๏ธ Error Handling
Status Code | Meaning | Example Cause |
400 | Bad Request | Missing required fields |
401 | Unauthorized | Missing or invalid JWT token |
403 | Forbidden | Access denied |
404 | Not Found | Story ID doesn't exist |
500 | Server Error | Internal backend issue |
๐ Deployment
Frontend:
travelbook.sahilportfolio.me
Backend:
travel-book-backend.onrender.com
For more information or to connect with me, feel free to check out my portfolio, GitHub, LinkedIn, and Twitter:
Portfolio: https://sahilportfolio.me
GitHub: https://github.com/Sahilll94
LinkedIn: https://www.linkedin.com/in/sahilll94
Twitter: https://x.com/Sa_hilll94
Instagram: https://www.instagram.com/sa_hilll94
Hashnode: https://hashnode.com/Sahil
Subscribe to my newsletter
Read articles from Sahil directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Sahil
Sahil
Iโm a passionate third-year BTech student pursuing Computer Science and Engineering at SRM Institute of Science and Technology, Chennai. Currently, Iโm deep diving into Data Structures & Algorithms (DSA) and working with the MERN stack, focusing on building scalable web applications.