UK Police Data
UK Police has a great API that’s full of crime and police information. You can filter the data based on regions, cities, neighborhoods, coordinates, officer names, crime category etc. inside the United Kingdom. With the help of webbrowser library we can then open these links right from the python terminal.
Here is a simply code that uses requests, json and webbrowser libraries harmoniously.
import webbrowser import requests import json f = r'https://data.police.uk/api/forces' j = r'https://data.police.uk/api/city-of-london/neighbourhoods' data = requests.get(j) a = data.text a = json.loads(a) for i in a: print(i) f = r'https://data.police.uk/api/forces' j = r'https://data.police.uk/api/city-of-london/neighbourhoods' f2 = r"https://data.police.uk/api/crimes-street/all-crime?lat=53.414226&lng=-2.923026&date=2019-08" data = requests.get(f2) a = data.text a = json.loads(a) print(a) for i in a: print(i["outcome_status"]) print(i["category"])
If you need a refresher on user defined functions lesson in Python here is a link to our Defining Functions Lesson.
Source of API: UK Police Data