Skip to content

mugdha273/railway-backend

Repository files navigation

Railway-Backend

Development 🔧

Setup

git clone https://github.com/mugdha273/railway-backend.git
cd railway-backend

For setting virtual environment

virtualenv venv

For activating virtual environment in Windows

venv/Scripts/activate

For activating virtual environment in Linux and macOS

source venv/bin/activate

For deactivating virtual environment

deactivate

After creating virtual environment

Start

pip install -r requirements.txt
python manage.py makemigrations
python manage.py migrate
python manage.py runserver

APIs in Use:

  1. https://railway-backend.herokuapp.com/api/token/: to obtain token of an account.

Curl Request: (Type your registered username and password in the body)

curl --location --request POST 'http://127.0.0.1:8000/api/token/' \
--header 'Content-Type: application/json' \
--header 'Cookie: csrftoken=62KjlMixjCOIaieXB4eUNjQidMxmzhsxHmcrjhXZpaPlzMvZb4EhCqdOQNg5t8wx' \
--data-raw '{
    "username": "<username>",
    "password": "<password>"
}'
  1. SignUp/Registration: https://railway-backend.herokuapp.com/api/users/register/
curl --location --request POST 'http://127.0.0.1:8000/api/users/register/' \
--header 'Content-Type: application/json' \
--header 'Cookie: csrftoken=62KjlMixjCOIaieXB4eUNjQidMxmzhsxHmcrjhXZpaPlzMvZb4EhCqdOQNg5t8wx' \
--data-raw '{
    "first_name": "Mugdha",
    "last_name": "Sharma" ,
    "email": "[email protected]",
    "phone_number": "9174400406",
    "date_of_birth": "2002-03-27",
    "password": "demopass",
    "password2": "demopass",
    "occupation": "student",
    "gender": "female",
    "city": "Indore" ,
    "state": "MP" ,
    "pincode": "452018"
}'

image

  1. Login: https://railway-backend.herokuapp.com/api/users/login/
curl --location --request POST 'https://railway-backend.herokuapp.com/api/users/login/' \
--header 'Content-Type: application/json' \
--data-raw '{
   "email": "[email protected]",
   "password": "demopass"
}'

image

  1. Trains: https://railway-backend.herokuapp.com/api/train/trains/

  2. Route: https://railway-backend.herokuapp.com/api/train/route/

  3. Train Status: https://railway-backend.herokuapp.com/api/train/train_status/

  4. Stations: https://railway-backend.herokuapp.com/api/train/station/

  5. Route Station: https://railway-backend.herokuapp.com/api/train/route-station/

  6. Ticket Booking: https://railway-backend.herokuapp.com/api/booking/book/

curl --location --request POST 'http://127.0.0.1:8000/api/booking/book/' \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNjY4NDg2MDk4LCJpYXQiOjE2NTEyMDYwOTgsImp0aSI6IjQ4M2RiZWM5ZTdiYjRkODY4NzY5YTliNTNhZTg0M2IxIiwidXNlcl9pZCI6M30.9Um4LKWwSV4Iki4sz_mO9f_tuZ7t7l7e4X7ref6HuVU' \
--header 'Content-Type: application/json' \
--header 'Cookie: csrftoken=62KjlMixjCOIaieXB4eUNjQidMxmzhsxHmcrjhXZpaPlzMvZb4EhCqdOQNg5t8wx' \
--data-raw '{
    "train_class": "2 AC",
    "date_of_journey": "2022-05-20",
    "account": 1,
    "train": 4,
    "route": 6
}'

image

  1. Passenger Details: https://railway-backend.herokuapp.com/api/booking/passenger
curl --location --request GET 'https://railway-backend.herokuapp.com/api/booking/passenger' \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNjY4MDc3Njg2LCJpYXQiOjE2NTA3OTc2ODYsImp0aSI6IjVhOTZiZjMwZDA4NDRiODk4MjFhYmMyMDM3M2YwNDdkIiwidXNlcl9pZCI6Mn0.jFPzjS7yOECSJhlU3jQagWN7i7FT7Ti7LKBUhb06i8A' \
--data-raw ''

image