<jupyter_start><jupyter_text>Let's make an API call!<jupyter_code># Find the endpoint for our data
url = 'https://data.seattle.gov/resource/fire-911.json?'
# Use Requests module to query the API
r = requests.get(url)
# Make sure our request went through as planned
# 200 = OK, 400 = Client Error, 404 = Not Found
r.status_code
# Process the data, and make it pretty
data = r.json()
pprint.pprint(data[:3])<jupyter_output>[{'type': ' --T::00'},
 {'address': '10049 College Way N',
  'incident_number': 'F110104009',
  'latitude': '47.701756',
  'longitude': '-122.335022',
  'report_location': {'latitude': '47.701756',
                      'longitude': '-122.335022',
                      'needs_recoding': False},
  'type': 'Aid Response'},
 {'address': '5929 Beach Dr Sw',
  'incident_number': 'F110104008',
  'latitude': '47.550431',
  'longitude': '-122.397816',
  'report_location': {'latitude': '47.550431',
                      'longitude': '-122.397816',
                      'needs_recoding': False},
  'type': 'Aid Response'}]<jupyter_text>Now let's take it a step further - filtering our data set to an address we're looking for<jupyter_code># We can tell the API what data we want by using a filter. Let's filter for a specific address
filters = 'address=5929 Beach Dr Sw'
new_url = url + filters
# Add HTML 'Headers', including our API key - this allows us to make more calls of the API
# NOTE!!! Use %load_dotenv if your API key is sensitive - never post your key on Github!
headers = {'APP_TOKEN': '<PASSWORD>'}
# Calling the API - with our new filter, and the API key
r = requests.get(new_url, headers=headers)
r.status_code
data = r.json()
pprint.pprint(data[:6])<jupyter_output>[{'address': '5929 Beach Dr Sw',
  'incident_number': 'F110104008',
  'latitude': '47.550431',
  'longitude': '-122.397816',
  'report_location': {'latitude': '47.550431',
                      'longitude': '-122.397816',
                      'needs_recoding': False},
  'type': 'Aid Response'}]<jupyter_text>Or, we can ask for only calls of 'Aid Response'<jupyter_code>filter = 'type=Aid Response'
new_url = url + filter
# Calling the API - with our new filter, and the API key
r = requests.get(new_url, headers=headers)
r.status_code
data = r.json()
pprint.pprint(data[:3])<jupyter_output>[{'address': 'N 50th St / Stone Way N',
  'datetime': 1320881520,
  'incident_number': 'F110104164',
  'latitude': '47.665034',
  'longitude': '-122.340207',
  'report_location': {'latitude': '47.665034',
                      'longitude': '-122.340207',
                      'needs_recoding': False},
  'type': 'Aid Response'},
 {'address': 'E John St / E Olive Way',
  'datetime': 1320881520,
  'incident_number': 'F110104165',
  'latitude': '47.619575',
  'longitude': '-122.324257',
  'report_location': {'latitude': '47.619575',
                      'longitude': '-122.324257',
                      'needs_recoding': False},
  'type': 'Aid Response'},
 {'address': '611 12th Av S',
  'datetime': 1320881340,
  'incident_number': 'F110104162',
  'latitude': '47.597406',
  'longitude': '-122.317228',
  'report_location': {'latitude': '47.597406',
                      'longitude': '-122.317228',
                      'needs_recoding': False},
  'type': 'Aid Response'}]
{'fraction_non_alphanumeric': 0.16111280953836749, 'fraction_numerical': 0.10058086212167533, 'mean_word_length': 3.3919463087248323, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '312374', 'license': 'MIT', 'n_tokens_mistral': 1338, 'n_tokens_neox': 1118, 'n_words': 312, 'path': 'investigations/Investigations - API Calls.ipynb', 'repo_name': 'athena15/metis', 'size': '3286'}