Skip to content

Kenneth4562/comp3011_coursework_1

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TfL Analytics API

Project Overview

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_ID
  • TFL_APP_KEY

These must be set before running the server (more information in section 3).

API Documentation

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.


Setup Instructions

1. Clone the repository

git clone https://github.com/Kenneth4562/comp3011_coursework_1.git

In the base folder of the repository:

cd comp3011_coursework_1

2. Create and activate a virtual environment (Optional)

Linux / macOS

python3 -m venv venv
source venv/bin/activate

Windows (PowerShell)

python -m venv venv
venv\Scripts\Activate.ps1

3. Set Environment Variables

Replace [your_app_id] and [your_app_key] with the respective id/key provided in the technical report (submitted via Minerva).

macOS (zsh)

Edit your ~/.zshrc:

export TFL_APP_ID="your_app_id"
export TFL_APP_KEY="your_app_key"

Reload:

source ~/.zshrc

Linux (bash)

Edit your ~/.bashrc:

export TFL_APP_ID="your_app_id"
export TFL_APP_KEY="your_app_key"

Reload:

source ~/.bashrc

Windows (PowerShell)

setx TFL_APP_ID "your_app_id"
setx TFL_APP_KEY "your_app_key"

Restart PowerShell afterwards so the variables load.


4. Install Dependencies

pip install -r requirements.txt

In requirements.txt:

Django==6.0.2
djangorestframework
drf-yasg
django-filter
requests

5. Apply Migrations

python manage.py migrate

6. Run the Server

python manage.py runserver

The 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/

7. User Authentication

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

About

COMP3011 at University of Leeds - Coursework 1

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors