Contents:
This API call provides information on collisions based on STATS19 data.
This includes all data from 1999 to 2021 inclusive. Please let us know if you have a use-case for earlier data.
An example usage of this API can be seen on the Bikedata website.
Currently, for filtering by type of road user, it can filter only for locations where the casualty(ies) include a cyclist(s), but further development is pending to generalise this.
You can also retrieve details of an individual collision using collisions.location
API call.
Example which retrieves collisions near the Catholic Church junction, Cambridge, requesting friendly datetime strings, including random jitter.
(In this example, a limit of only 3 locations has been set, to avoid a long example on this page, but normally a limit of 400 would be appropriate for web viewing.)
https://api.cyclestreets.net/v2/collisions.locations?bbox=0.1252,52.1979,0.1302,52.1999&casualtiesinclude=cyclist&limit=3&datetime=friendly&jitter=1&zoom=17
https://api.cyclestreets.net/v2/collisions.locations?boundary=[[0.126659,52.199417],[0.127463,52.199759],[0.127860,52.199174],[0.127211,52.198710],[0.126659,52.199417]]&casualtiesinclude=cyclist&limit=3&datetime=friendly&jitter=1&zoom=17
Result:
{ "type": "FeatureCollection", "features": [ { "type": "Feature", "properties": { "id": "2013353084513", "datetime": "6:55pm, 4th October 2013", "severity": "serious", "casualties": "Cyclist", "number_of_casualties": "2", "number_of_vehicles": "2", "url": "https://www.cyclestreets.net/collisions/reports/2013353084513/", "apiUrl": "https://api.cyclestreets.net/v2/collisions.location?id=2013353084513", "latitude": "52.199108", "longitude": "0.127413" }, "geometry": { "type": "Point", "coordinates": [ 0.12741219, 52.19910810 ] } }, { "type": "Feature", "properties": { "id": "2012350237312", "datetime": "9:00am, 25th May 2012", "severity": "serious", "casualties": "Cyclist", "number_of_casualties": "1", "number_of_vehicles": "2", "url": "https://www.cyclestreets.net/collisions/reports/2012350237312/", "apiUrl": "https://api.cyclestreets.net/v2/collisions.location?id=2012350237312", "latitude": "52.198328", "longitude": "0.125765" }, "geometry": { "type": "Point", "coordinates": [ 0.12576501, 52.19832810 ] } }, { "type": "Feature", "properties": { "id": "2013353071213", "datetime": "12:25pm, 30th September 2013", "severity": "slight", "casualties": "Cyclist", "number_of_casualties": "1", "number_of_vehicles": "2", "url": "https://www.cyclestreets.net/collisions/reports/2013353071213/", "apiUrl": "https://api.cyclestreets.net/v2/collisions.location?id=2013353071213", "latitude": "52.199816", "longitude": "0.128032" }, "geometry": { "type": "Point", "coordinates": [ 0.12803217, 52.19981589 ] } } ] }
A boundary string as geojson-style polygonal coordinates of longitude,latitude that encloses the results.
If the limit is not sufficient to cover all, the order of results will be the most severe casualties then most recent year; the ordering may change in future to match the behaviour of bbox.
The bbox and boundary parameters are mutually exclusive.
Filter to fields in the data, e.g. field:Location_Easting_OSGR=369779
would add this as a search constraint. This is useful for advanced search interfaces.
If values are comma-separated, they will be treated as an OR list. E.g. field:severity=slight,serious would match collisions whose severity is either slight or serious. As another example, casualties=Cyclist,Pedestrian would match a casualty list 'Car occupant,Goods vehicle occupant,Pedestrian' because at least one of the OR values is present in that list.
Fieldnames match those shown in the 'accident'
part of the collisions.location API call output, or via the collisions.metadata API call.
Controls what information is returned; the fields id is included by default, and longitude and latitude are in the GeoJSON geometry properties.
Available fields, all of which will be returned by default, are:
bbox
to indicate when the map is close to the ground (17 or above) to avoid spread filtering at close levels; and (ii) by jitter
if required.Whether to apply tiny random jitter of a few metres (±3m max in each of N/S and E/W directions) to all points when at close zoom levels (17 or above), to deal with the problem of overlapping points given the limitations of OS northings/eastings grid resolution which is especially problematic at larger junctions with many collisions. Randomisation only affects the GeoJSON geometry values and not the latitude/longitude in the feature properties. This feature requires that zoom
is also supplied.
Randomisation is currently generated each time rather than persistent between requests; we hope to change this in future. Also, this feature applies jitter even when points are not overlapping; again, we hope to fix this in future.
Sets the output format. Not normally required except in the use-case of requiring an export. The appropriate HTTP headers will be sent. Available values are:
fields
order will be respected.If specified, the datetime field (if requested in the fields list) will be converted from unixtime (the default output format) to a formatted version; the available output formats are:
date ('g:ia, jS F Y', $date)
in PHPdate ('jS F, Y', $date)
in PHPGeoJSON feature list as per example above. Geometry types will always be Point.
(See GeoJSON example above.)
If using format=float
, the structure will be flat JSON, with a pagination block and heading labels, to enable a full interface to be created:
{ "pagination": { "page": 1, "totalPages": 34, "totalAvailable": 102 }, "labels": { "id": "Accident Index", "accyr": "Year", "casualties": "Casualties", […] }, "data": { "2013353084513": { "id": "2013353084513", "datetime": "6:55pm, 4th October 2013", "severity": "serious", "casualties": "Cyclist", "number_of_casualties": "2", "number_of_vehicles": "2", "url": "https://www.cyclestreets.net/collisions/reports/2013353084513/", "apiUrl": "https://api.cyclestreets.net/v2/collisions.location?id=2013353084513", "latitude": "52.199108", "longitude": "0.127413" }, "2012350237312": { "id": "2012350237312", "datetime": "9:00am, 25th May 2012", "severity": "serious", "casualties": "Cyclist", "number_of_casualties": "1", "number_of_vehicles": "2", "url": "https://www.cyclestreets.net/collisions/reports/2012350237312/", "apiUrl": "https://api.cyclestreets.net/v2/collisions.location?id=2012350237312" "latitude": "52.198328", "longitude": "0.125765" }, […] } }
JSON object containing an error key and a text string.
Example errors (text string will vary):
{
"error": "Neither a bbox nor a detailed boundary have been supplied."
}
{
"error": "Jittering has been enabled but no zoom has been supplied."
}