$request = 'https://data.police.uk/api/crimes-street/all-crime?lat=51.232417&lng=-0.332361&date=2015-01';
Then we would process the result in the same way that we have been doing. This call returns several pieces of information including the date, crime category of the offense, the street ID and other location information of where the crime took place, the police force type that responded (either a normal police force or the British Transport Police which is a special police force for railways and light-rail systems), and a unique 64-character identifier for that specific crime. This unique identifier serves as a primary key which can be used to track outcomes for a specific crime. I wanted to see all the crime in the database which occurred in January of this year within 1 mile of the town of Dorking located South of London in Surrey. You can see the results of this request here.
$request = 'https://data.police.uk/api/crimes-at-location?date=2015-01&lat=51.500796&lng=-0.124357';
I was curious about the level of crime that occurs in the immediate vicinity of Big Ben so I created a request and processed the results for that location. I didn't expect the number of arson related offenses.
$request = 'https://data.police.uk/api/outcomes-for-crime/7e7a6ef5ba39f5322bbbbc6df4cbf4e104b5af84d372cdc53ebcb788e25b7234';
We can then process the request as we have done before including decoding the JSON formatted string into an array. But this array actually has nested arrays so we are going to display this information a little differently by using a function that will be recursively called when it comes across a nested array. We use the following code to do that.
function printArray($JSONarray) {
echo '"<"br>';
foreach ($JSONarray as $key => $value) {
echo "$key: ";
if (is_array($value)) {
printArray($value);
}
else {
echo $value . '<'br />';
}
}
echo '<'br>';
}
printArray($JSONarray);
You can see the outcome of a particular crime which occurred in March of this year in the Hatton Garden neighborhood of London (which is the jewelry district). In this case, no suspect was identified in the crime but in other instances it is possible to track the status of a crime from the initial investigation phase all the way through sentencing. In the next section, I'll cover Neighborhood Related service requests.