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/LocomotiveDataAPI
Go 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-headers
Start the server
python manage.py runserver
Update the database before making an API call.
python manage.py updatemodels
Create a superuser via CI.
python manage.py createsuperuser
Register your standard users using Postman
POST /api/register
Pass the following parameters
Parameter | Type | Description |
---|---|---|
name |
string |
${name} |
email |
string |
${email} |
password |
string |
${passwrd} |
POST /api/login
Pass the following parameters
Parameter | Type | Description |
---|---|---|
email |
string |
${email} |
password |
string |
${passwrd} |
To check if you're logged in
GET /api/user
If you're logged in you will see your user details in the response
POST /api/logout
Provide 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 |