NAV
Shell Javascript Java

Introduction

Welcome to the KB GeoRisk API documentation! You can use the tabs at the top right to change the examples’ programming language.

Authentication

To authenticate, use this code:

class DistanceToCoastResponse {
    private Double distanceInMiles;
    private Point targetPoint;
    private Point coastalPoint;
    ... setters and getters ...
}
class Point {
    private Double lat;
    private Double lng;
    ... setters and getters ...
}

// With Spring
@Autowired RestTemplate restTemplate;

HttpHeaders headers = new HttpHeaders();
headers.add("kb-auth-token", "myauthtoken");
ResponseEntity<Source> response = restTemplate.exchange("https://api.kbgeo.com/coastal-distance/v2/coord?lat=43.045583&lng=-89.379995", HttpMethod.GET, new HttpEntity(headers), DistanceToCoastResponse.class);
// With jQuery
$.ajax({
    type: 'GET',
    headers: {
        "kb-auth-token": "myauthtoken"
    },
    url: "https://api.kbgeo.com/coastal-distance/v2/coord?lat=43.045583&lng=-89.379995"
}).done(function(data) {
    console.log(data.distanceInMiles);
});
# In the shell, you can pass the authentication header with each request
curl "https://api.kbgeo.com/coastal-distance/v2/coord?lat=43.045583&lng=-89.379995"
  -H "kb-auth-token: myauthtoken"

Make sure to replace myauthtoken with your API key.

KB GeoRisk uses authentication tokens to provide access to the API. Your authentication token is provided when your business starts using KB Geo.

We expect the authentication token to be sent in all API requests via the kb-auth-token header like this:

kb-auth-token: myauthtoken

API Methods

Distance to Coast by Lat/Lng

class DistanceToCoastResponse {
    private Double distanceInMiles;
    private Point targetPoint;
    private Point coastalPoint;
    ... setters and getters ...
}
class Point {
    private Double lat;
    private Double lng;
    ... setters and getters ...
}

// With Spring
@Autowired RestTemplate restTemplate;

HttpHeaders headers = new HttpHeaders();
headers.add("kb-auth-token", "myauthtoken");
ResponseEntity<Source> response = restTemplate.exchange("https://api.kbgeo.com/coastal-distance/v2/coord?lat=43.045583&lng=-89.379995", HttpMethod.GET, new HttpEntity(headers), DistanceToCoastResponse.class);
// With jQuery
$.ajax({
    type: 'GET',
    headers: {
        "kb-auth-token": "myauthtoken"
    },
    url: "https://api.kbgeo.com/coastal-distance/v2/coord?lat=43.045583&lng=-89.379995"
}).done(function(data) {
    console.log(data.distanceInMiles);
});
curl "https://api.kbgeo.com/coastal-distance/v2/coord?lat=43.045583&lng=-89.379995"
  -H "kb-auth-token: myauthtoken"

The response body is JSON structured like this:

{
    "distanceInMiles": 702.4893212372758,
    "targetPoint": {
        "lat": 43.045583,
        "lng": -89.3799951
    },
    "coastlinePoint": {
        "lat": 38.662389,
        "lng": -77.236111
    }
}

If you already have the latitude/longitude for the geographic point you’re interested in, you can pass them to the KB GeoRisk Distance to Coast service as querystring parameters.

HTTP Request

GET https://api.kbgeo.com/coastal-distance/v2/coord?lat=<latitude>&lng=<longitude>

Query Parameters

Parameter Required Example Description
lat yes 43.045583 The latitude of the target coordinate
lng yes -89.3799951 The longitude of the target coordinate

HTTP Response

Distance to Coast by Address

class DistanceToCoastResponse {
    private Double distanceInMiles;
    private Point targetPoint;
    private Point coastalPoint;
    ... setters and getters ...
}
class Point {
    private Double lat;
    private Double lng;
    ... setters and getters ...
}

// With Spring
@Autowired RestTemplate restTemplate;

HttpHeaders headers = new HttpHeaders();
headers.add("kb-auth-token", "myauthtoken");
ResponseEntity<Source> response = restTemplate.exchange("https://api.kbgeo.com/coastal-distance/v2/address?address=1919%20Alliant%20Energy%20Center%20Way%20Madison%20WI%2053713", HttpMethod.GET, new HttpEntity(headers), DistanceToCoastResponse.class);
// With jQuery
$.ajax({
    type: 'GET',
    headers: {
        "kb-auth-token": "myauthtoken"
    },
    url: "https://api.kbgeo.com/coastal-distance/v2/address?address=1919%20Alliant%20Energy%20Center%20Way%20Madison%20WI%2053713"
}).done(function(data) {
    console.log(data.distanceInMiles);
});
curl "https://api.kbgeo.com/coastal-distance/v2/address?address=1919%20Alliant%20Energy%20Center%20Way%20Madison%20WI%2053713"
  -H "kb-auth-token: myauthtoken"

The response body is JSON structured like this:

{
    "distanceInMiles": 702.4893212372758,
    "targetPoint": {
        "lat": 43.045583,
        "lng": -89.3799951
    },
    "coastlinePoint": {
        "lat": 38.662389,
        "lng": -77.236111
    }
}

If you don’t know the latitude/longitude for the geographic point you’re interested in, KB GeoRisk’s Distance to Coast API can geocode the address and find its distance to coast all in one step.

HTTP Request

GET https://api.kbgeo.com/coastal-distance/address?address=<full address>

URL Parameters

Parameter Example Description
address 1919 Alliant Energy Center Way, Madison, WI 53713 The address to look up

HTTP Response

Nearest Fire Station by Lat/Lng

class NearestFireStationResponse {
    private Double distanceInMiles;
    private Long drivingDurationInSeconds;
    private Point targetPoint;
    private FireStation fireDepartment;
    ... setters and getters ...
}
class Point {
    private Double lat;
    private Double lng;
    ... setters and getters ...
}
class FireStation {
    private String stateId;
    private String name;
    private String address;
    private String city;
    private String state;
    private String zip;
    private String county;
    private String staffType;
    private String organizationType;
    private String website;
    private Integer stationCount;
    private Integer careerFirefighterCount;
    private Integer volunteerFirefighterCount;
    private Integer paidPerCallFirefighterCount;
    private Integer paidCivilianCount;
    private Integer volunteerCivilianCount;
    private BigDecimal lat;
    private BigDecimal lng;
    ... setters and getters ...
}

// With Spring
@Autowired RestTemplate restTemplate;

HttpHeaders headers = new HttpHeaders();
headers.add("kb-auth-token", "myauthtoken");
ResponseEntity<Source> response = restTemplate.exchange("https://api.kbgeo.com/fire-station/v2/coord?lat=43.045583&lng=-89.379995", HttpMethod.GET, new HttpEntity(headers), NearestFireStationResponse.class);
// With jQuery
$.ajax({
    type: 'GET',
    headers: {
        "kb-auth-token": "myauthtoken"
    },
    url: "https://api.kbgeo.com/fire-station/v2/coord?lat=43.045583&lng=-89.379995"
}).done(function(data) {
    console.log(data.distanceInMiles);
});
curl "https://api.kbgeo.com/fire-station/v2/coord?lat=43.045583&lng=-89.379995"
  -H "kb-auth-token: myauthtoken"

If you already have the latitude/longitude for the geographic point you’re interested in, you can pass them to the KB GeoRisk Nearest Fire Station service as querystring parameters.

HTTP Request

GET https://api.kbgeo.com/coastal-distance/v2/coord?lat=<latitude>&lng=<longitude>

Query Parameters

Parameter Required Example Description
lat yes 43.045583 The latitude of the target coordinate
lng yes -89.3799951 The longitude of the target coordinate

HTTP Response

Nearest Fire Station by Address

class NearestFireStationResponse {
    private Double distanceInMiles;
    private Long drivingDurationInSeconds;
    private Point targetPoint;
    private FireStation fireDepartment;
    ... setters and getters ...
}
class Point {
    private Double lat;
    private Double lng;
    ... setters and getters ...
}
class FireStation {
    private String stateId;
    private String name;
    private String address;
    private String city;
    private String state;
    private String zip;
    private String county;
    private String staffType;
    private String organizationType;
    private String website;
    private Integer stationCount;
    private Integer careerFirefighterCount;
    private Integer volunteerFirefighterCount;
    private Integer paidPerCallFirefighterCount;
    private Integer paidCivilianCount;
    private Integer volunteerCivilianCount;
    private BigDecimal lat;
    private BigDecimal lng;
    ... setters and getters ...
}

// With Spring
@Autowired RestTemplate restTemplate;

HttpHeaders headers = new HttpHeaders();
headers.add("kb-auth-token", "myauthtoken");
ResponseEntity<Source> response = restTemplate.exchange("https://api.kbgeo.com/fire-station/v2/address?address=1919%20Alliant%20Energy%20Center%20Way%20Madison%20WI%2053713", HttpMethod.GET, new HttpEntity(headers), NearestFireStationResponse.class);
// With jQuery
$.ajax({
    type: 'GET',
    headers: {
        "kb-auth-token": "myauthtoken"
    },
    url: "https://api.kbgeo.com/fire-station/v2/address?address=1919%20Alliant%20Energy%20Center%20Way%20Madison%20WI%2053713"
}).done(function(data) {
    console.log(data.distanceInMiles);
});
curl "https://api.kbgeo.com/fire-station/v2/address?address=1919%20Alliant%20Energy%20Center%20Way%20Madison%20WI%2053713"
  -H "kb-auth-token: myauthtoken"

If you don’t know the latitude/longitude for the geographic point you’re interested in, KB GeoRisk’s Nearest Fire Station API can geocode the address and find the nearest fire station all in one step.

HTTP Request

GET https://api.kbgeo.com/fire-station/v2/address?address=1919%20Alliant%20Energy%20Center%20Way%20Madison%20WI%2053713;

Query Parameters

Parameter Example Description
address 1919 Alliant Energy Center Way, Madison, WI 53713 The address to look up

HTTP Response