We have recently been looking at Planning Application data and how it could best be accessed by programmers to create their own displays or to create plug-ins for Word Press etc.
As such, this is a sort of Request For Comments to find out if we are thinking on the right lines and whether we have missed any vital functionality.
An API implemented as a standard JSON web service using HTTP GET and POST requests.
Last Application:
eg /api/api.php?lastapplication
Returns :
{ "Date": "2014-03-31" }
Authorities held
eg /api/authorities
Returns :
[ { "Authority": "Birmingham", "Count": 2567 }, ... ]
By Application number
eg /api/api.php?Birmingham&application=2014/01632/PA
Returns:
[ { "application": "2014/01632/PA", "type": "Full Planning", "address": "43-49 Vittoria Street Standard Works Birmingham B1 3ND", "registered": "26-03-2014", "decision": "Approve subject to Conditions", "decisiondate": "", "proposal": "Change of use to non residential institution (Use Class D1) with ancillary retail (A1), restaurant (A3), light industrial (B1c), residential (C2), assembly & leisure (D2) and associated works.", "officer": "Joanne McCallion", "areateam": "P & R - City Centre Team", "applicant": "RMLT", "ward": "Ladywood", "constituency": "Ladywood", "appeal": "No", "latitude": "52.4852057", "longitude": "-1.9103936" }, ... ]
Constituencies within an Authority
eg /api/api.php?authority=Birmingham&constituencies
Returns:
[ { "constituency": "", "count": 350}, { "constituency": "Edgbaston", "count": 273}, { "constituency": "Edgbaston, Erdington", "count": 1}, { "constituency": "Erdington", "count": 135}, { "constituency": "Hall Green", "count": 296}, { "constituency": "Hodge Hill", "count": 207}, { "constituency": "Ladywood", "count": 357}, { "constituency": "Northfield", "count": 115}, { "constituency": "Perry Barr", "count": 233}, { "constituency": "Selly Oak", "count": 217}, { "constituency": "Sutton Coldfield", "count": 264}, { "constituency": "Yardley", "count": 169} ]
Wards within an Authority
eg /api/api.php?authority=Birmingham&wards
Returns:
[ {"ward": "", "count": 352}, { "ward": "Acocks Green", "count": 59}, ... { "ward": "Weoley", "count": 39} ] Applications for a Constituency eg /api/api.php?authority=Birmingham&constituency=Edgbaston Returns:
[ { "application": "2014/01666/PA", "type": "Householder", "address": "76 Quinton Lane Quinton Birmingham B32 2TX", "registered": "13-03-2014", "decision": "Approve subject to Conditions", "decisiondate": "", "proposal": "Erection of two storey side and single storey rear and forward extensions", "officer": "George Baker", "areateam": "P & R - Householder Team", "applicant": "Mr Kieran Somerville", "ward": "Quinton", "constituency": "Edgbaston", "appeal": "No", "latitude": "52.4622565", "longitude": "-1.9882998"}, ... } ]
Applications for a Ward
eg /api/api.php?authority=”Birmingham”&ward=”Edgbaston”
Returns:
[ { "application": "2014/01673/PA", "type": "Non Material Amendment", "address": "St Augustines Court 269 Hagley Road Birmingham B16 9JU", "registered": "13-03-2014", "decision": "Approve", "decisiondate": "", "proposal": "Non Material Amendment attached to approval 2011/08743/PA for alterations to panels of roller shutter and double louvre doors on the St Augustines Road and Hagley Road elevations.", "officer": "Andrew Conroy", "areateam": "P & R - South Team", "applicant": "Mr Sam Wong", "ward": "Edgbaston", "constituency": "Edgbaston", "appeal": "No", "latitude": "52.4719667", "longitude": "-1.9485604" }, ... ]
Applications round a Postcode
eg eg /api/api.php?postcode=”B1+1BB”&radius=500
where radius is in metres.
Returns:
[ { "application": "2014/03369/PA", "type": "Discharge Of Condition", "address": "Edmund House 12 Newhall Street Birmingham B3 3EF", "registered": "16-05-2014", "decision": "Approve", "decisiondate": "", "proposal": "Application to determine the details for condition number 1 attached to approval 2013/07255/PA", "officer": "Nicholas Jackson", "areateam": "P & R - City Centre Team", "applicant": "Prime Solutions (UK) Ltd", "ward": "Ladywood", "constituency": "Ladywood", "appeal": "No", "latitude": "52.4812075", "longitude": "-1.9020824", "distance": 101}, ... ]
Stuart Harrison says
I’d probably make the API more RESTful, so rather than having query strings, you’d have something like this to see all applications for all authorities:
/applications/{authority}
And then this for the last updated
/applications/{authority}/lastupdated
And this for a list of authorities
/applications/authorities
Followed by this for wards
/applications/{authority}/ward/{ward}
And then this for constituency
/applications/{authority}/constituency/{constituency}
Lists of wards and constituencies could be queried like so:
/applications/{authority}/{wards|consituencies}
Each application should also have its own unique URI, in something like this format:
/applications/{authority}/{application ID}
Radius is a bit more tricky, but as it’s not necessarily authority-based perhaps something like:
/applications/postcode/{postcode}?radius={radius}
(I added the radius as a query string as it’s not necessarily a static thing)
Also, you should use content negotiation to return results in json, xml or csv, depending on what the user wants (either by providing a file extension or sending an accept HTTP header). The default response would be fine to have as JSON, but it might be even nicer to return the data as HTML, so it’s human readable too 🙂
Hope this helps!
Mike Cummins says
The intention is to use MOD_REWRITE to make it more RESTful once I have thought of a way of handling the fact that Constituency & Ward names can sometimes be the same eg Edgbaston 🙂 Your solution above worked for some but (and I cannot remember which now) caused other problems.
I intend to add JSON & CSV both as URI options/content-negotiation but also via an HTML page that will allow you to navigate to the level you require and hit a download button.
I was, at this stage, more interested in whether I had missed a level or type of query…
Thanks for that.
Stuart Harrison says
Cool, yeah, I think querying the ONS GSS codes instead of the name helps that issue. Also avoids any doubt and / or misspelling / local variations in naming
Mike Cummins says
If less obvious 🙂
It would require adding a lookup for the codes which presents the same problem…
Stuart Harrison says
Oooh, also the authority / ward codes etc should be ONS GSS codes, as per:
http://www.ons.gov.uk/ons/guide-method/geography/products/names–codes-and-look-ups/index.html
Philip John says
Great stuff!
I’d question the need for counts on some of those responses however. We can easily determine the number of items returned using whatever language we’re writing in. Having that count entry at the top means we have to skip over it, which is kind of a pain 🙂
Jason Kay says
Hi, Did this Api ever get written?
I could do with this.
Simon Whitehouse says
Hi Jason
Sorry for not getting back to you before now. No, we didn’t develop this API I’m afraid.