Introducing the SmartCambridge API

Introducing the SmartCambridge API  

  By: jw35 on Sept. 20, 2018, 11:28 a.m.

In September 2018 we enabled access to the 'SmartCambridge API', giving programmatic access to information maintained by the Smart Cambridge project. Currently this includes:

  • Air Quality data from a selection of sensors deployed around Cambridge between June 2016 and February 2017.
  • Car Parking data showing the occupancy of Cambridge City Centre and Park and Ride car parks from 2017 onward.
  • Traffic Speed data for a number of roads within Cambridge based on bus position reports from October 2017 onward.
  • API access to bus transport data from the National Public Transport Access Nodes (NaPTAN) and Traveline National Dataset (TNDS) resources.

There's some general information about using the API (also linked from the SmartCambridge home page), and a reference page documenting the API endpoints..

This is a first stab at providing an API and we'd welcome comments and suggestions for how it could be improved. We also encourage you to ask questions about it here and we'll do our best to answer them.

Jon.

--
Jon Warbrick
Adaptive Cities Programme, University of Cambridge

 Last edited by: jw35 on Sept. 20, 2018, 12:57 p.m., edited 1 time in total.

Re: Introducing the SmartCambridge API  

  By: boba on Dec. 9, 2019, 10:42 a.m.

This could be very useful. I do have a question about the 'sirivmaddjourney' endpoint, it returns "500 Internal Server Error: error while processing siriVM data: string indices must be integers" for anything but empty request data in the body. What is the siriVM format meant to be used in the request? Does the endpoint allow vehicle monitoring or is the idea to only add journey information to existing siriVM data?

Re: Introducing the SmartCambridge API  

  By: jw35 on Dec. 16, 2019, 10:07 a.m.

I'll make sure someone gets back to you shortly.

Jon.

--
Jon Warbrick
Adaptive Cities Programme, University of Cambridge

Re: Introducing the SmartCambridge API  

  By: jw35 on Dec. 16, 2019, 4:57 p.m.

Right - I've taken a look at this. I suspect this API endpoint isn't going to be much use to people outside the SmartCambridge project.

This endpoint takes a list of SIRI-VM records that have been converted to a JSON format that we use internally and adds a list of timetable 'vehicle journey' references for the timetabled journey(s) that appear to correspond to each SIRI-VM record. We don't make SIRI-VM data available (because we are not allowed to redistribute the SIRI VM that we receive) and we don't currently document our JSON format.

I think I can probably include an example. Given this SIRI-VM JSON fragment:

{ "feed_id": "cloudamber.sirivm", "filename": "1576511671.236_2019-12-16-15-54-31", "filepath": "2019/12/16", "module_id": "A", "module_name": "feedmaker", "msg_type": "feed_sirivm", "request_data": [ { "Bearing": "306", "DataFrameRef": "2019-12-16", "DatedVehicleJourneyRef": "104", "Delay": "-PT1M40S", "DestinationName": "North Station", "DestinationRef": "0500CCITY541", "DirectionRef": "INBOUND", "InPanic": "0", "Latitude": "52.2003441", "LineRef": "2", "Longitude": "0.1364030", "Monitored": "true", "OperatorRef": "SCCM", "OriginAimedDepartureTime": "2019-12-16T15:46:00+00:00", "OriginName": "Sainsbury''s", "OriginRef": "0500CCITY039", "PublishedLineName": "2", "RecordedAtTime": "2019-12-16T15:54:19+00:00", "ValidUntilTime": "2019-12-16T15:54:19+00:00", "VehicleMonitoringRef": "SCCM-36043", "VehicleRef": "SCCM-36043", "acp_id": "SCCM-36043", "acp_lat": 52.2003441, "acp_lng": 0.136403, "acp_ts": 1576511659 } ], "ts": 1576511671 }

then pushing it through this API endpoint results in this:

{ "feed_id": "cloudamber.sirivm", "filename": "1576511671.236_2019-12-16-15-54-31", "filepath": "2019/12/16", "module_id": "A", "module_name": "feedmaker", "msg_type": "feed_sirivm", "request_data": [ { "Bearing": "306", "DataFrameRef": "2019-12-16", "DatedVehicleJourneyRef": "104", "Delay": "-PT1M40S", "DestinationName": "North Station", "DestinationRef": "0500CCITY541", "DirectionRef": "INBOUND", "InPanic": "0", "Latitude": "52.2003441", "LineRef": "2", "Longitude": "0.1364030", "Monitored": "true", "OperatorRef": "SCCM", "OriginAimedDepartureTime": "2019-12-16T15:46:00+00:00", "OriginName": "Sainsbury''s", "OriginRef": "0500CCITY039", "PublishedLineName": "2", "RecordedAtTime": "2019-12-16T15:54:19+00:00", "ValidUntilTime": "2019-12-16T15:54:19+00:00", "VehicleMonitoringRef": "SCCM-36043", "VehicleRef": "SCCM-36043", "acp_id": "SCCM-36043", "acp_lat": 52.2003441, "acp_lng": 0.136403, "acp_ts": 1576511659, "vehicle_journeys": [ "ea-20-2-A-y08-1-131-T0" ] } ], "ts": 1576511671 }

Note the addition of a vehicle_journeys field.

Jon.

--
Jon Warbrick
Adaptive Cities Programme, University of Cambridge

 Last edited by: jw35 on Dec. 16, 2019, 5:05 p.m., edited 1 time in total.