> For the complete documentation index, see [llms.txt](https://api-v2-docs.disasteraware.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://api-v2-docs.disasteraware.com/hazards/requesting-historical-hazards.md).

# Requesting Historical Hazards

The endpoint for fetching historical hazards:

{% openapi src="/files/wYQaKpPZEdPb68ZWOF6w" path="/historical\_hazards" method="get" %}
[openapi.yaml](https://3664004773-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbwQ2AvqpbIy1hD3QFTQG%2Fuploads%2Fgit-blob-ad3207376652be88415648e56d649a656e8df8f6%2Fopenapi.yaml?alt=media)
{% endopenapi %}

{% hint style="info" %}
See [Authorizing Requests](/authentication/authorizing-requests.md#get-accesstoken-and-refreshtoken) page to get your accessToken.
{% endhint %}

## Checking Result Count

Before querying historical hazards, use the `hazards_count` endpoint to verify your search will return fewer than 1000 matches:

```
https://api-v2.disasteraware.com/hazards_count?where=<your_query>
```

## Query Fields

The `where` parameter accepts the following fields:

| Field                        | Description                                                        | Example                                                                                                                                             |
| ---------------------------- | ------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------- |
| **status**                   | Hazard status. Use `'E'` for expired hazards.                      | `status = 'E'`                                                                                                                                      |
| **type\_id**                 | Hazard type: AVALANCHE, TORNADO, WILDFIRE, etc.                    | `type_id = 'AVALANCHE' OR type_id = 'WILDFIRE'`                                                                                                     |
| **category\_id**             | Hazard category: EVENT, EXERCISE, OTHER, RESPONSE                  | `category_id = 'EVENT'`                                                                                                                             |
| **severity\_id**             | Hazard severity: WARNING, WATCH, ADVISORY, INFORMATION             | `severity_id = 'WARNING'`                                                                                                                           |
| **hazard\_name**             | Hazard name (use `UPPER()` and `LIKE` for case-insensitive search) | `UPPER(hazard_name) LIKE '%HAWAII%'`                                                                                                                |
| **comment\_text**            | Any comment text associated with the hazard                        | `UPPER(comment_text) LIKE '%TSUNAMI%'`                                                                                                              |
| **create\_date**             | Hazard creation date, typically used to check a range of dates     | `create_date >= to_date('2023-05-01 00:00:00', 'yyyy-mm-dd hh24:mi:ss') AND create_date <= to_date('2023-05-31 00:00:00', 'yyyy-mm-dd hh24:mi:ss')` |
| **latitude** / **longitude** | Bounding box using latitude and longitude                          | `(latitude >= 36.58 AND latitude <= 39.06) AND (longitude >= -123.99 AND longitude <= -119.68)`                                                     |

## Examples

### Filter by hazard type

```
?where=type_id = 'WILDFIRE'
```

### Filter by multiple types

```
?where=type_id = 'AVALANCHE' OR type_id = 'WILDFIRE'
```

### Search by hazard name (case-insensitive)

```
?where=UPPER(hazard_name) LIKE '%HAWAII%'
```

### Filter by date range

```
?where=create_date >= to_date('2023-05-01 00:00:00', 'yyyy-mm-dd hh24:mi:ss') AND create_date <= to_date('2023-05-31 00:00:00', 'yyyy-mm-dd hh24:mi:ss')
```

### Filter by geographic bounding box

```
?where=(latitude >= 36.58151 AND latitude <= 39.06433) AND (longitude >= -123.99719 AND longitude <= -119.68719)
```

### Multi-field query

The following searches for expired WILDFIRE hazards of type EVENT, severity WARNING, created between 5/1/23 and 5/31/23, with "namefoo" (case-insensitive) in the hazard name and "commentfoo" (case-insensitive) in the comment text:

```
https://api-v2.disasteraware.com/hazards_count?where=((category_id = 'EVENT')) AND (UPPER(comment_text) LIKE '%COMMENTFOO%') AND (create_date >= to_date('2023-05-01 00:00:00', 'yyyy-mm-dd hh24:mi:ss') AND create_date <= to_date('2023-05-31 00:00:00', 'yyyy-mm-dd hh24:mi:ss')) AND (UPPER(hazard_name) LIKE '%NAMEFOO%') AND ((severity_id = 'WARNING')) AND ((status = 'E')) AND ((type_id = 'WILDFIRE'))
```

{% hint style="warning" %}
The multi-field example above uses the `hazards_count` endpoint to first verify the result count before fetching the actual hazards via `historical_hazards`.
{% endhint %}
