Copy of your example and added my key:
import requests
url = “https://crime-data-by-zipcode-api.p.rapidapi.com/crime_data”
querystring = {“zip”:“94109”}
headers = {
“X-RapidAPI-Key”: “177ca92fc3msh20a796fb7be565ep1d81d2jsn267ca7f44408”,
“X-RapidAPI-Host”: “crime-data-by-zipcode-api.p.rapidapi.com”
}
response = requests.get(url, headers=headers, params=querystring)
if response.status_code == 200:
print(‘Success!’)
else:
# Print an error message
print(f"Request failed with status code: {response.status_code}")
print(response.json())
Join in the discussion - add comment below: