Example API Request: Applying Request Parameters to Filter Results

Before Getting Started

Additional documentation for the Agency Incidents API can be found here.

GET Incidents Endpoint Documentation

The Agency Incidents > Get Incidents documentation references the filter Request Parameter in the following format:

Request Parameters
filter string Format - string. Filter on any field in the resource that can be updated with eq (equal), ne (not equal), ge (greater than or equal), gt (great than), le (less than or equal to), lt (less than).

Operators we can use to compare values in the request URL include:

  • lt (less than)
  • le (less than or equal to)
  • gt (greater than)
  • ge (greater than or equal to)
  • eq (equal to)
  • ne (not equal to)

Following the outlined format, the GET Incidents request URL would translate to:

GET

https://data.emergencyreporting.com/agencyincidents/incidents?filter=[string] eq "[string]"

An example request URL would look like the following, where the filter string is "stationID" and the value is "12345". This GET request would list Incidents for an account where the Station ID was 12345.

Example API Request: Filter Incidents by Station ID

GET

https://data.emergencyreporting.com/agencyincidents/incidents?filter=stationID eq "12345"

Now let's use the Filter Request Parameter to find data for a specific Timeframe.


Example API Request: Filter Incidents by Date/Time using an Incident GET Request

The Filter Request Parameter is quite robust and can be paired with other Request Parameters (orderby, limit) to return focused datasets. Let's find incidents associated with an account for a specific date range.

First we'll find all incidents by calling the incidents API endpoint.

GET

https://data.emergencyreporting.com/agencyincidents/incidents

Then we'll expand our search to make sure we include all available incidents.

GET

https://data.emergencyreporting.com/agencyincidents/incidents?limit=10000

Now we'll add Date/Time filter to show all incidents from January 1, 2040 and newer.

GET

https://data.emergencyreporting.com/agencyincidents/incidents?limit=10000&filter=incidentDateTime ge "2040-01-01"

Let's isolate incidents to January of 2040 only by setting an le (less than or equal to) range on our incidentDateTime filter.

GET

https://data.emergencyreporting.com/agencyincidents/incidents?limit=10000&filter=incidentDateTime ge "2040-01-01", incidentDateTime le "2040-01-31"

By default, the newer incidents should appear at the top of the API response. Let's finish off this query by ordering results in Ascending (ASC) order using orderby. This query will return the oldest incidents in the range at the top of the API response.

GET

https://data.emergencyreporting.com/agencyincidents/incidents?limit=10000&filter=incidentDateTime ge "2040-01-01", incidentDateTime le "2040-01-31"&orderby=incidentDateTime ASC

Example API Request: Filter Incidents by Incident Number Across Specified Years

Maybe you're feeling like finding how many times a specific incident number occurred across the lifetime of an account? By Filtering on Incident Number and specifying a date range, this can be accomplished with the following GET request where "12345" is the Incident Number and the date range is from 2020 - 2030.

GET

https://data.emergencyreporting.com/agencyincidents/incidents?filter=incidentNumber eq 12345,incidentDateTime gt 2020-01-01,incidentDateTime lt 2030-12-31

The expected result would include incidents 2020-12345, 2021-12345, 2022-12345, etc.


Back to Top