This project implements a Django + Django REST Framework API for analysing Transport for London (TfL) data alongside user‑reported incidents and routes. It provides CRUD functionality, user‑scoped data handling, and analytics endpoints that summarise line and stop reliability.
The API integrates with the official TfL Unified API, which requires authentication via two environment variables:
TFL_APP_IDTFL_APP_KEY
These must be set before running the server (more information in section 3).
For API documentation (as a PDF) generated by Swagger, click here or here (Swagger UI printed)! The documentation can also be accessed when the server is started.
git clone https://github.com/Kenneth4562/comp3011_coursework_1.gitIn the base folder of the repository:
cd comp3011_coursework_1python3 -m venv venv
source venv/bin/activatepython -m venv venv
venv\Scripts\Activate.ps1Replace [your_app_id] and [your_app_key] with the respective id/key provided in the technical report (submitted via Minerva).
Edit your ~/.zshrc:
export TFL_APP_ID="your_app_id"
export TFL_APP_KEY="your_app_key"Reload:
source ~/.zshrcEdit your ~/.bashrc:
export TFL_APP_ID="your_app_id"
export TFL_APP_KEY="your_app_key"Reload:
source ~/.bashrcsetx TFL_APP_ID "your_app_id"
setx TFL_APP_KEY "your_app_key"Restart PowerShell afterwards so the variables load.
pip install -r requirements.txtIn requirements.txt:
Django==6.0.2
djangorestframework
drf-yasg
django-filter
requests
python manage.py migratepython manage.py runserverThe API Swagger Docs, detailing all endpoints will be available at:
http://127.0.0.1:8000/swagger/
The admin page is available at:
http://127.0.0.1:8000/admin/
There is a button that allows for user login in Swagger. A test user has been created, with the credentials:
login: test
password: test
Alternatively, a new superuser/admin user can be created with:
python manage.py createsuperuser