Comment on page
Requesting Hazard Types
To request the list of hazard types configured in the system please use the route defined here:
get
https://api.disasteraware.com/
hazards/types
Get hazard types
cURL
Java
Node.js
PHP
Python
curl --location --request GET \
'https://api.disasteraware.com/hazards/types' \
--header 'Authorization: Bearer your_accessToken'
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Scanner;
class Main {
public static void main(String[] args) throws IOException {
URL url = new URL("https://api.disasteraware.com/hazards/types");
HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
httpConn.setRequestMethod("GET");
httpConn.setRequestProperty("Authorization", "Bearer your_accessToken");
InputStream responseStream = httpConn.getResponseCode() / 100 == 2
? httpConn.getInputStream()
: httpConn.getErrorStream();
Scanner s = new Scanner(responseStream).useDelimiter("\\A");
String response = s.hasNext() ? s.next() : "";
System.out.println(response);
}
}
var fetch = require('node-fetch');
fetch('https://api.disasteraware.com/hazards/types', {
headers: {
'Authorization': 'Bearer your_accessToken'
}
});
<?php
include('vendor/rmccue/requests/library/Requests.php');
Requests::register_autoloader();
$headers = array(
'Authorization' => 'Bearer your_accessToken'
);
$response = Requests::get('https://api.disasteraware.com/hazards/types', $headers);
import requests
headers = {
'Authorization': 'Bearer your_accessToken',
}
response = requests.get('https://api.disasteraware.com/hazards/types', headers=headers)
This request will return an array that contains all of the hazard types. Each element in the array will have three properties:
Properties | Definitions |
type_id | This is like the primary key for the hazard type. This is the value that will be found on the hazard object. |
type_name | A human readable value for the hazard e.g. Volcano. |
type_icon | This is the url for the hazard type icon’s image e.g. avalanche.png. The hazard icons are hosted at: https://static.pdc.org/icons/hazard/large/. To construct the fully qualified location for the hazard type’s icon combine the host location with type_icon value. |