LocomotiveDataAPI is a RESTful Web Service made in Django REST framework which aims to provide information Indian locomotives (Indian Railways) scraped from Wikipedia using Beautiful Soup.
Clone the project
git clone https://github.com/cyberpsychofc/LocomotiveDataAPIGo to the project directory
Install dependencies
pip install beautifulsoup4
pip install requests
pip install Django
pip install djangorestframework
pip install pyjwt
pip install django-cors-headersStart the server
python manage.py runserverUpdate the database before making an API call.
python manage.py updatemodelsCreate a superuser via CI.
python manage.py createsuperuserRegister your standard users using Postman
POST /api/registerPass the following parameters
| Parameter | Type | Description |
|---|---|---|
name |
string |
${name} |
email |
string |
${email} |
password |
string |
${passwrd} |
POST /api/loginPass the following parameters
| Parameter | Type | Description |
|---|---|---|
email |
string |
${email} |
password |
string |
${passwrd} |
To check if you're logged in
GET /api/userIf you're logged in you will see your user details in the response
POST /api/logoutProvide the generated JWT token at the time of login in the Authorization tab in Postman

Endpoint demonstration of the API. For more information refer to the documentaiton.
https://localhost:8000/locomotives
Lets search for a particular locomotive e.g. WAP-1
https://localhost:8000/locomotives/wap-1
GET /api/locomotives/| Parameter | Type | Description |
|---|---|---|
locomotives |
string |
Required. Returns entire list of locomotives |
GET /api/locomotives/${name}| Parameter | Type | Description |
|---|---|---|
name |
string |
Required. Returns the details of a particular locomotive |
GET /api/locomotives/electric| Parameter | Type | Description |
|---|---|---|
electric |
string |
Required. Returns entire list of electric locomotives |
GET /api/locomotives/diesel| Parameter | Type | Description |
|---|---|---|
diesel |
string |
Required. Returns entire list of diesel locomotives |
GET /api/locomotives/broad| Parameter | Type | Description |
|---|---|---|
broad |
string |
Required. Returns entire list of broad-gauge locomotives |
GET /api/locomotives/meter| Parameter | Type | Description |
|---|---|---|
meter |
string |
Required. Returns entire list of meter-gauge locomotives |
GET /api/locomotives/narrow| Parameter | Type | Description |
|---|---|---|
narrow |
string |
Required. Returns entire list of narrow-gauge locomotives |
GET /api/locomotives/narrower| Parameter | Type | Description |
|---|---|---|
narrower |
string |
Required. Returns entire list of narrower-gauge locomotives |

