Intro: We are a team of third year Computing Science students at the University of Glasgow.
Project aims: To use the Open Transport API specifications to demonstrate the sharing of customer data between transport operators.
Timescale: 14th October 2020 – 31st March 2021
Names: Torrin McQueen, Tomas Mikus, Paul Traynor, Kameron Eralp, Jamie McKay
With Django, we created an example Operator lookup and model Operator site “Zebras”. The Open Transport API was implemented within our websites using the Django REST Framework. We populated our database with some sample customer data to demonstrate account linking. We have shown that by deploying two separate instances of Zebras and registering them with the Operator lookup, it is possible to link user accounts and share ticket data.
We came into the project with prior knowledge on databases and web app development. However, none of us had worked with APIs before, so using Django REST framework was a bit of a learning curve. Listed below is a couple of challenges we faced using Django, and how we overcame them.
Python does not support hyphens in variable names. We used underscores instead, but this was a problem during serialization. To make this work we passed field names with hyphens as extra keyword arguments in the Meta class of each serializer. If those fields were serializing data themselves, we had to specify the field name and source field in the init function too. For example:
Another problem with serialization was formatting the dates and times correctly. In order to display datetime objects with milliseconds we had to create a custom encoder class within the JSON renderer. This is our custom encoder:
Overall, working on this project has been an enjoyable and rewarding experience. The Open Transport API has the potential to make a great impact on the transport industry, and we can really get behind the idea of standardising communication and data sharing in this sector. Our websites mark the first working implementation of the Open Transport API and stand as a taster of what this platform could be used for.
GitHub library URL: