The Ticket Reservation API is a robust system built with JavaScript, designed to handle ticket reservations for train journeys. The API provides endpoints for user registration, login, ticket management, and seat availability queries.
- User Authentication: Register and log in securely.
- Ticket Management: Reserve, view, and cancel reservations.
- Seat Availability: Check available seats for specific journeys.
-
POST /register
Registers a new user.
Payload:{ "email": "user@example.com", "password": "password123", "name": "John Doe" }
-
POST /login
Logs in an existing user.
Payload:{ "email": "user@example.com", "password": "password123" }
-
POST /ticket/makeReservation
Makes a new ticket reservation.
Payload:{ "trainId": "12345", "departureTime": "2025-04-24T10:00:00Z", "arrivalTime": "2025-04-24T14:00:00Z", "from": "City A", "to": "City B" }
-
GET /ticket/getAvailableTickets
Retrieves available tickets for a specific route.
Payload:{ "from": "City A", "to": "City B" }
-
DELETE /ticket/cancelReservation/:id
Cancels a reservation by its ID.
Query Parameter:id
: Reservation ID
POST /voyage/availableSeats
Fetches the available seats for a specific journey.
Payload:{ "from": "City A", "to": "City B" }
-
Clone the repository:
git clone https://github.com/saaya-code/Ticket-Reservation-API.git cd Ticket-Reservation-API
-
Install dependencies:
npm install
-
Start the API server:
npm start
- Use tools like Postman or cURL to test the endpoints.
- Ensure the server is running before making requests to the API.
Contributions are welcome! Please follow these steps:
- Fork this repository.
- Create a feature branch:
git checkout -b feature-name
- Commit your changes:
git commit -m "Add a meaningful message"
- Push your branch:
git push origin feature-name
- Open a pull request.
This project is licensed under the MIT License.
For any questions or feedback, feel free to reach out:
- GitHub: saaya-code